本文整理匯總了C#中System.TimeSpan.PrettyPrint方法的典型用法代碼示例。如果您正苦於以下問題:C# TimeSpan.PrettyPrint方法的具體用法?C# TimeSpan.PrettyPrint怎麽用?C# TimeSpan.PrettyPrint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.PrettyPrint方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Should_handle_positive_timespans_in_the_years_category
public void Should_handle_positive_timespans_in_the_years_category()
{
var ts = new TimeSpan(800, 0, 0, 0);
Assert.AreEqual("2 years ago", ts.PrettyPrint());
}
示例2: Should_handle_positive_timespans_in_the_singular_year_category
public void Should_handle_positive_timespans_in_the_singular_year_category()
{
var ts = new TimeSpan(365, 0, 0, 0);
Assert.AreEqual("one year ago", ts.PrettyPrint());
}
示例3: Should_handle_positive_timespans_in_the_singular_minute_category
public void Should_handle_positive_timespans_in_the_singular_minute_category()
{
var ts = new TimeSpan(0, 0, 1, 0);
Assert.AreEqual("a minute ago", ts.PrettyPrint());
}
示例4: Should_handle_positive_timespans_in_the_minutes_category
public void Should_handle_positive_timespans_in_the_minutes_category()
{
var ts = new TimeSpan(0, 0, 32, 0);
Assert.AreEqual("32 minutes ago", ts.PrettyPrint());
}
示例5: Should_handle_negative_timespans_of_1_second
public void Should_handle_negative_timespans_of_1_second()
{
var ts = new TimeSpan(0, 0, 0, 1).Negate();
Assert.AreEqual("recent", ts.PrettyPrint());
}