当前位置: 首页>>代码示例>>C#>>正文


C# Time.ToString方法代码示例

本文整理汇总了C#中Time.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Time.ToString方法的具体用法?C# Time.ToString怎么用?C# Time.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Time的用法示例。


在下文中一共展示了Time.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CacheEngineValues

        public override void CacheEngineValues(IEngine iEngine)
        {
            // Am expecting this to be called just once to initialise values
            // prior to pull run

            var iEngineTime = iEngine as IEngineTime;

            if (iEngineTime == null)
                throw new Exception("IEngine not IEngineTime");

            var at = new Time(iEngineTime.GetCurrentTime());

            if (_cache.Count > 0)
            {
                if (at.StampAsModifiedJulianDay < _cache.Last().Time.StampAsModifiedJulianDay)
                    throw new Exception(string.Format("Engine moving back in time, {0} < {1}",
                        at.ToString(), _cache.Last().Time.ToString()));
                else if (at.StampAsModifiedJulianDay == _cache.Last().Time.StampAsModifiedJulianDay)
                    _cache.RemoveAt(_cache.Count - 1);
            }

            var vs = _link.SourceComponent.GetValues(Utilities.Standard1.ToTime1(at), _link.ID);

            var record = ToTimeRecord(at, vs, _missingValue);

            if (HasItemChangedEvents)
                SendItemChangedEvent(string.Format("Standard1.ValueSetConvertorTarget: Cached from v1.link at {0}", at.ToString()));

            _cache.Add(record);

            if (_counts[(int)Counts.CacheMaxSize] < _cache.Count)
                _counts[(int)Counts.CacheMaxSize] = _cache.Count;
        }
开发者ID:CNH-Hyper-Extractive,项目名称:parallel-sdk,代码行数:33,代码来源:ValueSetConverterTimeEngineDoubleStandard1.cs

示例2: can_format_24hour_time

 public void can_format_24hour_time()
 {
     var compareTime = new Time(13, 59, 58, "HH:mm:ss");
     var time = compareTime.ToString();
     string timeValue = "13:59:58";
     Assert.AreEqual(time, timeValue);
 }
开发者ID:kappy,项目名称:DateTimeExtensions,代码行数:7,代码来源:TimeTests.cs

示例3: can_format_12hour_time

 public void can_format_12hour_time()
 {
     var compareTime = new Time(13, 59, 58, "h:mm:ss tt");
     var time = compareTime.ToString();
     string timeValue = "1:59:58 " + Thread.CurrentThread.CurrentCulture.DateTimeFormat.PMDesignator;
     Assert.AreEqual(time, timeValue);
 }
开发者ID:kappy,项目名称:DateTimeExtensions,代码行数:7,代码来源:TimeTests.cs

示例4: AddHourMoreThan_23_hour

        public void AddHourMoreThan_23_hour()
        {
            int hour = 1;
            int mins = 0;
            int second = 0;
            var target = new Time(hour, mins, second);
            int hour1 = 29;
            target = target.AddHours(hour1);

            Assert.AreEqual("6:0:0", target.ToString());
        }
开发者ID:mirror222,项目名称:qi4net,代码行数:11,代码来源:TimeTest.cs

示例5: TestFloatingConstructorMinus

 public void TestFloatingConstructorMinus()
 {
     var times = 1000;
     Time baseTime = new Time() { Hours = times / 2 };
     for ( int i = times; i >= 0; i-- )
     {
         Time test = new Time( ( (float)( i / 2 ) ) + ( (float)( ( i % 2 ) == 0 ? 0 : 0.30 ) ) );
         if ( test != baseTime )
         {
             Assert.Fail( "Base Time:'" + baseTime.ToString() + "' is not the same as '" + test.ToString() + "'" );
         }
         baseTime -= Time.FromMinutes( 30 );
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:14,代码来源:TestTime.cs

示例6: RunTimeCode

    public static void RunTimeCode()
    {
        Console.WriteLine( "Time object created with object initializer" );

          // create a Time object and initialize its properties
          Time aTime = new Time { Hour = 14, Minute = 145, Second = 12 };

          // display the time in both standard and universal format
          Console.WriteLine( "Standard time: {0}", aTime.ToString() );
          Console.WriteLine( "Universal time: {0}\n",
         aTime.ToUniversalString() );

          Console.WriteLine( "Time object created with Minute property set" );

          // create a Time object and initialize its Minute property only
          Time anotherTime = new Time { Minute = 45 };

          // display the time in both standard and universal format
          Console.WriteLine( "Standard time: {0}", anotherTime.ToString() );
          Console.WriteLine( "Universal time: {0}",
         anotherTime.ToUniversalString() );
    }
开发者ID:jcolas,项目名称:CodeProjects,代码行数:22,代码来源:ObjectInitializerTest.cs

示例7: ToStringTest

 public void ToStringTest()
 {
     double value = 10F;
     Time target = new Time(value);
     string expected = "10 Seconds";
     string actual;
     actual = target.ToString();
     Assert.AreEqual(expected, actual);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:9,代码来源:TimeTest.cs

示例8: ToStringSecondPrecisionTest

 public void ToStringSecondPrecisionTest()
 {
     double value = 10F;
     Time target = new Time(value);
     int secondPrecision = 2;
     string expected = "10.00 Seconds";
     string actual;
     actual = target.ToString(secondPrecision);
     Assert.AreEqual(expected, actual);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:10,代码来源:TimeTest.cs

示例9: ToStringProviderTest

 public void ToStringProviderTest()
 {
     double value = 10F;
     Time target = new Time(value);
     IFormatProvider provider = null;
     string expected = value.ToString();
     string actual;
     actual = target.ToString(provider);
     Assert.AreEqual(expected, actual);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:10,代码来源:TimeTest.cs

示例10: ToStringSecondPrecisionTimeNamesTest

 public void ToStringSecondPrecisionTimeNamesTest()
 {
     Time target = new Time(10F);
     int secondPrecision = 2;
     string[] timeNames = { "Year", "Years", "Day", "Days", "Hour", "Hours", "Minute", "Minutes", "Second", "Seconds", "Less Than 60 Seconds", "0 Seconds" };
     string expected = "10.00 Seconds";
     string actual;
     actual = target.ToString(secondPrecision, timeNames);
     Assert.AreEqual(expected, actual);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:10,代码来源:TimeTest.cs

示例11: TestToString

 public void TestToString()
 {
     Time a = new Time() { Hours = 23, Minutes = 22, Seconds = 21 };
     if ( a.ToString() != "23:22:21" )
     {
         Assert.Fail( "The ToString() of '23:22:21' was given as '" + a.ToString() + "' instead!" );
     }
     a.Seconds = 0;
     if ( a.ToString() != "23:22" )
     {
         Assert.Fail( "The ToString() of '23:22' was given as '" + a.ToString() + "' instead!" );
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:13,代码来源:TestTime.cs

示例12: ToYaml

 public static Node/*!*/ ToYaml(Time self, [NotNull]RubyRepresenter/*!*/ rep) {
     string format = (self.DateTime.Millisecond != 0) ? "yyyy-MM-dd HH:mm:ss.fffffff K" : "yyyy-MM-dd HH:mm:ss K";
     return rep.Scalar(self, MutableString.CreateAscii(self.ToString(format, CultureInfo.InvariantCulture)));
 }
开发者ID:mstram,项目名称:ironruby,代码行数:4,代码来源:BuiltinsOps.cs

示例13: TestFloatingConstructorPlus

 public void TestFloatingConstructorPlus()
 {
     Time baseTime = new Time();
     for ( int i = 0; i < 1000; i++ )
     {
         Time test = new Time( ( (float)( i / 2 ) ) + ( (float)( ( i % 2 ) == 0 ? 0 : 0.30 ) ) );
         if ( test != baseTime )
         {
             Assert.Fail( "Base Time:'" + baseTime.ToString() + "' is not the same as '" + test.ToString() + "'" );
         }
         baseTime += Time.FromMinutes( 30 );
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:13,代码来源:TestTime.cs

示例14: TestParseByWords

 public void TestParseByWords()
 {
     Time a = new Time( "15 minutes" );
     if ( a.Minutes != 15 )
     {
         Assert.Fail( "We were expecting 15 minutes, instead we found " + a.ToString() );
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:8,代码来源:TestTime.cs

示例15: UpdateEngine

        //private readonly object syncLock = new object();
        protected virtual void UpdateEngine()
        {
            // synchronize access to this method to ensure serial execution
            // in case it is called in parallel
            //lock (syncLock)
            {

                // Update engine with values from input exchange item

                var engineTime = new Time(((IEngineTime)Engine).GetCurrentTime());

                // For active time based inputs set required time and get values

                // parallel
                Dictionary<ITimeSpaceExchangeItem, IBaseValueSet> valueSets = new Dictionary<ITimeSpaceExchangeItem, IBaseValueSet>();
                List<System.Threading.Thread> threadList = new List<System.Threading.Thread>();
                _activeInputs.ForEach(a =>
                {
                    var thread = new System.Threading.Thread(delegate()
                    {
                        var timeInput = a as ITimeSpaceExchangeItem;

                        // If not a time input just get next set of values

                        if (timeInput != null)
                        {
                            // change to request inputs at timestep being calculated
                            timeInput.TimeSet.Times.Clear();
                            //timeInput.TimeSet.Times.Add(engineTime);
                            timeInput.TimeSet.Times.Add(new Time(engineTime.StampAsModifiedJulianDay + 1));
                        }

                        var values = a.Values as IBaseValueSet;

                        valueSets[timeInput] = values;

                    });
                    thread.IsBackground = true;
                    thread.Start();
                    threadList.Add(thread);
                });
                foreach (System.Threading.Thread thread in threadList)
                {
                    thread.Join();
                }
                foreach (ITimeSpaceExchangeItem nextExchangeItem in valueSets.Keys)
                {
                    IBaseValueSet nextValueSet = valueSets[nextExchangeItem];
                    EngineConvertor(nextExchangeItem).ToEngine(Engine, nextValueSet);
                }

                /*
                // serial
                _activeInputs.ForEach(a =>
                    {
                        var timeInput = a as ITimeSpaceExchangeItem;

                        // If not a time input just get next set of values

                        if (timeInput != null)
                        {
                            // change to request inputs at timestep being calculated
                            timeInput.TimeSet.Times.Clear();
                            //timeInput.TimeSet.Times.Add(engineTime);
                            timeInput.TimeSet.Times.Add(new Time(engineTime.StampAsModifiedJulianDay + 1));
                        }

                        var values = a.Values as IBaseValueSet;

                        EngineConvertor(a).ToEngine(Engine, values);
                    });
                */

                Engine.Update();

                var updatedEngineTime = new Time(((IEngineTime)Engine).GetCurrentTime());

                if (updatedEngineTime == null)
                    throw new Exception("Engine current time is null");

                if (updatedEngineTime.StampAsModifiedJulianDay <= engineTime.StampAsModifiedJulianDay)
                    throw new Exception("Engine update failed to progress in time. Failed at " + updatedEngineTime.ToString());

                // Update output cache with values from engine
                // Update all not just required, as could improve interpolations

                _activeOutputs.ForEach(o =>
                    EngineConvertor(o).CacheEngineValues(Engine));

                _timeExtent.Times.Add(updatedEngineTime);

                _engineDone = updatedEngineTime.StampAsModifiedJulianDay >=
                    Time.EndTime(_timeExtent.TimeHorizon);

                Trace.TraceInformation(string.Format("Completed \"{0}\" engine update: {1} => {2}, [{3}]",
                    Caption,
                    Time.ToDateTimeString(engineTime.StampAsModifiedJulianDay),
                    Time.ToDateTimeString(updatedEngineTime.StampAsModifiedJulianDay),
                    new TimeInterval(updatedEngineTime.StampAsModifiedJulianDay - engineTime.StampAsModifiedJulianDay).ToString()));
//.........这里部分代码省略.........
开发者ID:CNH-Hyper-Extractive,项目名称:parallel-sdk,代码行数:101,代码来源:BaseComponentTimeWithEngine.cs


注:本文中的Time.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。