當前位置: 首頁>>代碼示例>>C#>>正文


C# DateTime.GetTime方法代碼示例

本文整理匯總了C#中System.DateTime.GetTime方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.GetTime方法的具體用法?C# DateTime.GetTime怎麽用?C# DateTime.GetTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.GetTime方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Format

		/// <param name="when">
		/// <see cref="System.DateTime">System.DateTime</see>
		/// to format
		/// </param>
		/// <returns>
		/// age of given
		/// <see cref="System.DateTime">System.DateTime</see>
		/// compared to now formatted in the same
		/// relative format as returned by
		/// <code>git log --relative-date</code>
		/// </returns>
		public static string Format(DateTime when)
		{
			long ageMillis = (Runtime.CurrentTimeMillis() - when.GetTime());
			// shouldn't happen in a perfect world
			if (ageMillis < 0)
			{
				return JGitText.Get().inTheFuture;
			}
			// seconds
			if (ageMillis < UpperLimit(MINUTE_IN_MILLIS))
			{
				return MessageFormat.Format(JGitText.Get().secondsAgo, Round(ageMillis, SECOND_IN_MILLIS
					));
			}
			// minutes
			if (ageMillis < UpperLimit(HOUR_IN_MILLIS))
			{
				return MessageFormat.Format(JGitText.Get().minutesAgo, Round(ageMillis, MINUTE_IN_MILLIS
					));
			}
			// hours
			if (ageMillis < UpperLimit(DAY_IN_MILLIS))
			{
				return MessageFormat.Format(JGitText.Get().hoursAgo, Round(ageMillis, HOUR_IN_MILLIS
					));
			}
			// up to 14 days use days
			if (ageMillis < 14 * DAY_IN_MILLIS)
			{
				return MessageFormat.Format(JGitText.Get().daysAgo, Round(ageMillis, DAY_IN_MILLIS
					));
			}
			// up to 10 weeks use weeks
			if (ageMillis < 10 * WEEK_IN_MILLIS)
			{
				return MessageFormat.Format(JGitText.Get().weeksAgo, Round(ageMillis, WEEK_IN_MILLIS
					));
			}
			// months
			if (ageMillis < YEAR_IN_MILLIS)
			{
				return MessageFormat.Format(JGitText.Get().monthsAgo, Round(ageMillis, MONTH_IN_MILLIS
					));
			}
			// up to 5 years use "year, months" rounded to months
			if (ageMillis < 5 * YEAR_IN_MILLIS)
			{
				long years = ageMillis / YEAR_IN_MILLIS;
				string yearLabel = (years > 1) ? JGitText.Get().years : JGitText.Get().year;
				//
				long months = Round(ageMillis % YEAR_IN_MILLIS, MONTH_IN_MILLIS);
				string monthLabel = (months > 1) ? JGitText.Get().months : JGitText.Get().month;
				//
				return MessageFormat.Format(JGitText.Get().yearsMonthsAgo, new object[] { years, 
					yearLabel, months, monthLabel });
			}
			// years
			return MessageFormat.Format(JGitText.Get().yearsAgo, Round(ageMillis, YEAR_IN_MILLIS
				));
		}
開發者ID:yayanyang,項目名稱:monodevelop,代碼行數:71,代碼來源:RelativeDateFormatter.cs

示例2: PersonIdent

		/// <summary>Construct a PersonIdent from simple data</summary>
		/// <param name="aName"></param>
		/// <param name="aEmailAddress"></param>
		/// <param name="aWhen">local time stamp</param>
		/// <param name="aTZ">time zone</param>
		public PersonIdent(string aName, string aEmailAddress, DateTime aWhen, TimeZoneInfo
			 aTZ)
		{
			name = aName;
			emailAddress = aEmailAddress;
			when = aWhen.GetTime();
			tzOffset = aTZ.GetOffset(when) / (60 * 1000);
		}
開發者ID:yayanyang,項目名稱:monodevelop,代碼行數:13,代碼來源:PersonIdent.cs

示例3: After

		/// <summary>Create a new filter to select commits after a given date/time.</summary>
		/// <remarks>Create a new filter to select commits after a given date/time.</remarks>
		/// <param name="ts">the point in time to cut on.</param>
		/// <returns>a new filter to select commits on or after <code>ts</code>.</returns>
		public static RevFilter After(DateTime ts)
		{
			return After(ts.GetTime());
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:8,代碼來源:CommitTimeRevFilter.cs

示例4: Before

		/// <summary>Create a new filter to select commits before a given date/time.</summary>
		/// <remarks>Create a new filter to select commits before a given date/time.</remarks>
		/// <param name="ts">the point in time to cut on.</param>
		/// <returns>a new filter to select commits on or before <code>ts</code>.</returns>
		public static RevFilter Before(DateTime ts)
		{
			return Before(ts.GetTime());
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:8,代碼來源:CommitTimeRevFilter.cs

示例5: Between

		/// <summary>
		/// Create a new filter to select commits after or equal a given date/time <code>since</code>
		/// and before or equal a given date/time <code>until</code>.
		/// </summary>
		/// <remarks>
		/// Create a new filter to select commits after or equal a given date/time <code>since</code>
		/// and before or equal a given date/time <code>until</code>.
		/// </remarks>
		/// <param name="since">the point in time to cut on.</param>
		/// <param name="until">the point in time to cut off.</param>
		/// <returns>a new filter to select commits between the given date/times.</returns>
		public static RevFilter Between(DateTime since, DateTime until)
		{
			return Between(since.GetTime(), until.GetTime());
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:15,代碼來源:CommitTimeRevFilter.cs

示例6: Finish

			internal virtual void Finish()
			{
				DateTime end = new DateTime();
				long elapsedMs = end.GetTime() - start.GetTime();
				Set(html, "results.testlist", Join(arguments.GetTestList()));
				Set(html, "results.skiplist", Join(arguments.GetSkipList()));
				string pct = new DecimalFormat("##0.00").Format((double)failures / (double)tests * 100.0);
				Set(html, "results.results", "Tests attempted: " + tests + " Failures: " + failures + " (" + pct + "%)");
				Set(html, "results.platform", "java.home=" + Runtime.GetProperty("java.home") + "\n" + "java.version=" + Runtime.GetProperty("java.version") + "\n" + "os.name=" + Runtime.GetProperty("os.name"));
				Set(html, "results.classpath", Runtime.GetProperty("java.class.path").Replace(FilePath.pathSeparatorChar, ' '));
				int elapsedSeconds = (int)(elapsedMs / 1000);
				int elapsedMinutes = elapsedSeconds / 60;
				elapsedSeconds = elapsedSeconds % 60;
				string elapsed = string.Empty + elapsedMinutes + " minutes, " + elapsedSeconds + " seconds";
				Set(html, "results.elapsed", elapsed);
				Set(html, "results.time", new SimpleDateFormat("MMMM d yyyy h:mm:ss aa").Format(new DateTime()));
				Write(html, false);
				Write(xml, true);
			}
開發者ID:hazzik,項目名稱:Rhino.Net,代碼行數:19,代碼來源:JsDriver.cs

示例7: PersonIdent

		/// <summary>Construct a PersonIdent from simple data</summary>
		/// <param name="aName"></param>
		/// <param name="aEmailAddress"></param>
		/// <param name="aWhen">local time stamp</param>
		/// <param name="aTZ">time zone</param>
		public PersonIdent(string aName, string aEmailAddress, DateTime aWhen, TimeZoneInfo
			 aTZ) : this(aName, aEmailAddress, aWhen.GetTime(), aTZ.GetOffset(aWhen.GetTime(
			)) / (60 * 1000))
		{
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:10,代碼來源:PersonIdent.cs

示例8: GetTimeWorks

 public void GetTimeWorks()
 {
     var dt = new DateTime(DateTime.Utc(1970, 1, 2));
     Assert.AreEqual(dt.GetTime(), 1440 * 60 * 1000);
 }
開發者ID:TinkerWorX,項目名稱:Bridge,代碼行數:5,代碼來源:JsDateTests.cs

示例9: flushQueue

        private void flushQueue()
        {
            var ind = 0;

            for (ind = 0; answerQueue.Count > 0 && ind < QUEUEPERTICK; ind++)
            {
                ServerLogger.LogDebug(string.Format("-- answer pop, queue length: {0}", answerQueue.Count), null);


                var answer = answerQueue[0];
                answerQueue.RemoveAt(0);

                var room = getRoomByPlayer(answer.Item1.UserName);
                if (room == null)
                {
                    ServerLogger.LogError("Room not found for user: " + answer.Item1.UserName, answer);

                    continue;
                    throw new Exception("idk");
                }

                var dict = new CardGameAnswer();
                dict.Value = answer.Item2.Answer;
                room.EmulatedAnswers.Add(dict);
                var answ = room.Fiber.Run<DebugFiberYieldResponse>(dict);

                //dataManager.GameData.Insert(new GameInfoModel() {GameName = room.Name, AnswerIndex = answ.Contents});
                processGameResponse(room, answ);
            }

            if (ind == 0)
                skipped__++;
            else
            {
                total__ += ind;
                if ((total__ + skipped__) % 20 == 0)
                {
                    var dt = new DateTime();
                    ServerLogger.LogDebug(string.Format("{0} =  tot: __{1}__ + shift: {2} + T: {3} + QSize: {4} + T Rooms: {5} + Per SecondL {6}",
                                             myServerManager.DebugGameServerIndex.Substring(0, 19),
                                             (total__ + skipped__),
                                             ind,
                                             total__,
                                             answerQueue.Count,
                                             rooms.Count,
                                             (gameData.TotalQuestionsAnswered / ((dt.GetTime() - startTime.GetTime()) / 1000d))),
                               null);
                }
            }
        }
開發者ID:Shuffle-Game,項目名稱:ShufflySharp,代碼行數:50,代碼來源:DebugGameManager.cs

示例10: Enc_time

		public static int Enc_time(DateTime date, byte[] dst, int di, int enc)
		{
			long t;
			switch (enc)
			{
				case Time1970Sec32Be:
				{
					return Enc_uint32be((int)(date.GetTime() / 1000L), dst, di);
				}

				case Time1970Sec32Le:
				{
					return Enc_uint32le((int)(date.GetTime() / 1000L), dst, di);
				}

				case Time1904Sec32Be:
				{
					return Enc_uint32be((int)((date.GetTime() / 1000L + SecBetweeen1904And1970) &
						 unchecked((int)(0xFFFFFFFF))), dst, di);
				}

				case Time1904Sec32Le:
				{
					return Enc_uint32le((int)((date.GetTime() / 1000L + SecBetweeen1904And1970) &
						 unchecked((int)(0xFFFFFFFF))), dst, di);
				}

				case Time1601Nanos64Be:
				{
					t = (date.GetTime() + MillisecondsBetween1970And1601) * 10000L;
					return Enc_uint64be(t, dst, di);
				}

				case Time1601Nanos64Le:
				{
					t = (date.GetTime() + MillisecondsBetween1970And1601) * 10000L;
					return Enc_uint64le(t, dst, di);
				}

				case Time1970Millis64Be:
				{
					return Enc_uint64be(date.GetTime(), dst, di);
				}

				case Time1970Millis64Le:
				{
					return Enc_uint64le(date.GetTime(), dst, di);
				}

				default:
				{
					throw new ArgumentException("Unsupported time encoding");
				}
			}
		}
開發者ID:Cyber-Forensic,項目名稱:Potato,代碼行數:55,代碼來源:Encdec.cs


注:本文中的System.DateTime.GetTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。