示例#1
0
文件: ContentVM.cs 项目: flq/Rf.Sites
 private void SetTimeInfo(Entity content)
 {
     WrittenInTime = content.Created.ToString(Constants.CommonDateFormat);
     var o = new PeriodOfTimeOutput(content.Created, DateTime.Now).ToString();
     WrittenInPeriod = string.Format("{0}{1}", o, o == "today" ? "" : " ago");
 }
示例#2
0
 public void NextYearButLessThanAYear()
 {
   var t2 = new DateTime(2010, 7, 10);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("10 months, 1 week, 2 days", o.ToString());
 }
示例#3
0
 public void NextMonthButLessThanAMonth() // Worked without changing code
 {
   var thePast = new DateTime(2009, 9, 10);
   var t2 = new DateTime(2009, 10, 2);
   var o = new PeriodOfTimeOutput(thePast, t2);
   Assert.AreEqual("3 weeks, 1 day", o.ToString());
 }
示例#4
0
 public void YearsAreAlsoOutput()
 {
   var t2 = new DateTime(2010, 9, 1);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("1 year", o.ToString());
 }
示例#5
0
 public void CombinationOfYearMonthWeekAndDayIsPossible()
 {
   var t2 = new DateTime(2010, 11, 10);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("1 year, 2 months, 1 week, 2 days", o.ToString());
 }
示例#6
0
 public void MonthsAreAlsoOutput()
 {
   var t2 = new DateTime(2009, 10, 1);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("1 month", o.ToString()); 
 }
示例#7
0
 public void CombinationsOfMonthAndWeekAndDayArePossible()
 {
   var t2 = new DateTime(2009, 10, 10);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("1 month, 1 week, 2 days", o.ToString());
 }
示例#8
0
 public void WeeksAppearWhenMoreThanAWeek()
 {
   var t2 = new DateTime(2009, 9, 17);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("2 weeks, 2 days", o.ToString());
 }
示例#9
0
 public void WeeksAreCorrectlyInflected()
 {
   var t2 = new DateTime(2009, 9, 9);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("1 week, 1 day", o.ToString()); 
 }
示例#10
0
 public void SmallestUnitIsToday()
 {
   var t2 = basePast;
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("today", o.ToString());
 }
示例#11
0
 public void CorrectlyOutputsASmallPeriodWithinWeek()
 {
   var t2 = new DateTime(2009, 9, 6);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("5 days", o.ToString());
 }
示例#12
0
 public void IssueInFindingAMonthWhenPastDateIs31St()
 {
   var past = new DateTime(2009, 8, 31);
   var now = new DateTime(2009, 10, 1);
   var o = new PeriodOfTimeOutput(past, now);
   Assert.AreEqual("1 month, 1 day", o.ToString());
 }
示例#13
0
 public void AVariantOfALongInterval()
 {
   var t2 = new DateTime(2012, 8, 30);
   var o = new PeriodOfTimeOutput(basePast, t2);
   Assert.AreEqual("2 years, 11 months, 4 weeks, 1 day", o.ToString());
 }
示例#14
0
 public void NextYearButLessThanAYearVariant2()
 {
   var otherBase = new DateTime(2009, 9, 10);
   var t2 = new DateTime(2010, 6, 2);
   var o = new PeriodOfTimeOutput(otherBase, t2);
   Assert.AreEqual("8 months, 3 weeks, 2 days", o.ToString());
 }