Skip to content

Commit c060e9c

Browse files
authored
Merge pull request haf#193 from mj1856/master
Repair leap year bugs in unit test
2 parents bbea98c + 311d391 commit c060e9c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Zip Tests/Selector.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void ClassInit(TestContext a)
5353
tomorrow = todayAtMidnight + new TimeSpan(1, 0, 0, 0);
5454
threeDaysAgo = todayAtMidnight - new TimeSpan(3, 0, 0, 0);
5555
twoDaysAgo = todayAtMidnight - new TimeSpan(2, 0, 0, 0);
56-
threeYearsAgo = new DateTime(DateTime.Now.Year - 3, DateTime.Now.Month, DateTime.Now.Day);
56+
threeYearsAgo = todayAtMidnight.AddYears(-3);
5757

5858
oneDay = new TimeSpan(1,0,0,0);
5959
yesterdayAtMidnight = todayAtMidnight - oneDay;
@@ -967,9 +967,7 @@ public void Selector_SelectEntries_ByTime()
967967

968968
// None of the files should have been created
969969
// more than 20 years ago
970-
var twentyYearsAgo = new DateTime(DateTime.Now.Year - 20,
971-
DateTime.Now.Month,
972-
DateTime.Now.Day);
970+
var twentyYearsAgo = todayAtMidnight.AddYears(-20);
973971
crit = String.Format("ctime < {0}",
974972
twentyYearsAgo.ToString("yyyy-MM-dd"));
975973
var selected5 = zip1.SelectEntries(crit);

0 commit comments

Comments
 (0)