本文整理汇总了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
));
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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))
{
}
示例8: GetTimeWorks
public void GetTimeWorks()
{
var dt = new DateTime(DateTime.Utc(1970, 1, 2));
Assert.AreEqual(dt.GetTime(), 1440 * 60 * 1000);
}
示例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);
}
}
}
示例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");
}
}
}