@@ -41,9 +41,9 @@ public function testDayDifference()
41
41
42
42
$ left = Timestamp::create ('2008-03-29 03:00:00 ' );
43
43
$ right = Timestamp::create ('2008-03-30 03:00:00 ' );
44
-
44
+
45
45
$ this ->dayDifferenceTest ($ left , $ right , 1 );
46
-
46
+
47
47
// unsolved giv's case
48
48
// $left = Timestamp::create('2008-10-25 03:00:00');
49
49
// $right = Timestamp::create('2008-10-26 02:59:00');
@@ -67,6 +67,38 @@ public function testDateComparsion()
67
67
return $ this ;
68
68
}
69
69
70
+ /**
71
+ * @test
72
+ **/
73
+ public function testWeekCount ()
74
+ {
75
+ $ weekCount = Date::getWeekCountInYear (2012 );
76
+ $ this ->assertEquals ($ weekCount , 52 , "Week count is incorrect " );
77
+
78
+ $ dateFromWeekNumberStamp = Date::makeFromWeek (5 , 2012 )->toStamp ();
79
+ $ expectedDate = Date::create ('2012-01-30 00:00:00 ' )->toStamp ();
80
+ $ this ->assertEquals ($ dateFromWeekNumberStamp , $ expectedDate , 'Creating date from week number is incorrect. ' );
81
+
82
+ $ weekCount2009 = Date::getWeekCountInYear (2009 );
83
+ $ expectedCount2009 = 53 ;
84
+ $ this ->assertEquals ($ weekCount2009 , $ expectedCount2009 , 'Week count for 2009 year is incorrect. ' );
85
+
86
+ $ weekBegin2009Stamp = Date::makeFromWeek (53 , 2009 )->toStamp ();
87
+ $ expectedDate2009 = Date::create ('2009-12-28 00:00:00 ' )->toStamp ();
88
+ $ this ->assertEquals ($ weekBegin2009Stamp , $ expectedDate2009 , 'Week 53 for 2009 starts with incorrect date. ' );
89
+
90
+ $ this ->
91
+ assertEquals (
92
+ Date::makeFromWeek (1 ,2010 )->toStamp (),
93
+ Date::create ('2010-01-04 ' )->toStamp (),
94
+ 'Week 1 for 2010 starts with incorrect date. '
95
+ );
96
+
97
+ $ this ->assertEquals (Date::getWeekCountInYear (1996 ), 52 , 'Incorrect week count in 1996 year ' );
98
+
99
+ $ this ->assertEquals (Date::getWeekCountInYear (1976 ), 53 , 'Incorrect week count in 1976 year ' );
100
+ }
101
+
70
102
public function testMakeFromWeek ()
71
103
{
72
104
$ this ->makeFromWeekTest (Date::create ('2009-12-28 ' ));
0 commit comments