本文整理汇总了C#中System.DateTime.PrettyDate方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.PrettyDate方法的具体用法?C# DateTime.PrettyDate怎么用?C# DateTime.PrettyDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.PrettyDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FourteenDaysAgo
public void FourteenDaysAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 15, 0, 0, 0, 0);
Assert.AreEqual("2 weeks ago", d.PrettyDate(now));
}
示例2: WhenIsNow
public void WhenIsNow()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 1, 0, 0, 0, 0);
Assert.AreEqual("just now", d.PrettyDate(now));
}
示例3: FiftyNineSecondsAgo
public void FiftyNineSecondsAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 1, 0, 0, 59, 999);
Assert.AreEqual("just now", d.PrettyDate(now));
}
示例4: OneMinuteFiftyNineSecondsAgo
public void OneMinuteFiftyNineSecondsAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 1, 0, 1, 59, 999);
Assert.AreEqual("1 minute ago", d.PrettyDate(now));
}
示例5: WriteDate
private void WriteDate(DateTime eventDate)
{
_when.Text = eventDate.PrettyDate();
}
示例6: OneDayTwentyThreeHoursAgo
public void OneDayTwentyThreeHoursAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 2, 23, 59, 59, 999);
Assert.AreEqual("yesterday", d.PrettyDate(now));
}
示例7: OneHourFiftyNineMinutesAgo
public void OneHourFiftyNineMinutesAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 1, 1, 59, 59, 999);
Assert.AreEqual("1 hour ago", d.PrettyDate(now));
}
示例8: ThreeWeeksAgo
public void ThreeWeeksAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 28, 23, 59, 59, 999);
Assert.AreEqual("3 weeks ago", d.PrettyDate(now));
}
示例9: TwentyThreeHoursAgo
public void TwentyThreeHoursAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 1, 23, 59, 59, 999);
Assert.AreEqual("23 hours ago", d.PrettyDate(now));
}
示例10: SixDaysAgo
public void SixDaysAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 7, 23, 59, 59, 999);
Assert.AreEqual("6 days ago", d.PrettyDate(now));
}
示例11: ThirteenDaysAgo
public void ThirteenDaysAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 14, 23, 59, 59, 999);
Assert.AreEqual("last week", d.PrettyDate(now));
}
示例12: SevenDaysAgo
public void SevenDaysAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 1, 8, 0, 0, 0, 0);
Assert.AreEqual("last week", d.PrettyDate(now));
}
示例13: OneYearAgo
public void OneYearAgo()
{
var d = new DateTime(2009, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 2, 5, 0, 0, 0, 0);
Assert.AreEqual(d.ToString("d"), d.PrettyDate(now));
}
示例14: OneMonthAgoMin
public void OneMonthAgoMin()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 2, 5, 0, 0, 0, 0);
Assert.AreEqual("1 month ago", d.PrettyDate(now));
}
示例15: FourWeeksAgo
public void FourWeeksAgo()
{
var d = new DateTime(2010, 1, 1, 0, 0, 0, 0);
var now = new DateTime(2010, 2, 4, 23, 59, 59, 999);
Assert.AreEqual("4 weeks ago", d.PrettyDate(now));
}