Lines 133-139
my $day_after_christmas = DateTime->new(
Link Here
|
133 |
year => 2012, |
133 |
year => 2012, |
134 |
month => 12, |
134 |
month => 12, |
135 |
day => 26 |
135 |
day => 26 |
136 |
); # for testing negative addDate |
136 |
); # for testing negative addDuration |
137 |
|
137 |
|
138 |
my $holiday_for_another_branch = DateTime->new( |
138 |
my $holiday_for_another_branch = DateTime->new( |
139 |
year => 2012, |
139 |
year => 2012, |
Lines 218-240
my $holiday_excepted = DateTime->new(
Link Here
|
218 |
|
218 |
|
219 |
$cal = Koha::Calendar->new( branchcode => 'MPL', days_mode => 'Datedue' ); |
219 |
$cal = Koha::Calendar->new( branchcode => 'MPL', days_mode => 'Datedue' ); |
220 |
|
220 |
|
221 |
is($cal->addDate( $dt, $one_day_dur, 'days' ), # tuesday |
221 |
is($cal->addDuration( $dt, $one_day_dur, 'days' ), # tuesday |
222 |
dt_from_string('2012-07-05','iso'), |
222 |
dt_from_string('2012-07-05','iso'), |
223 |
'Single day add (Datedue, matches holiday, shift)' ); |
223 |
'Single day add (Datedue, matches holiday, shift)' ); |
224 |
|
224 |
|
225 |
is($cal->addDate( $dt, $two_day_dur, 'days' ), |
225 |
is($cal->addDuration( $dt, $two_day_dur, 'days' ), |
226 |
dt_from_string('2012-07-05','iso'), |
226 |
dt_from_string('2012-07-05','iso'), |
227 |
'Two days add, skips holiday (Datedue)' ); |
227 |
'Two days add, skips holiday (Datedue)' ); |
228 |
|
228 |
|
229 |
cmp_ok($cal->addDate( $test_dt, $seven_day_dur, 'days' ), 'eq', |
229 |
cmp_ok($cal->addDuration( $test_dt, $seven_day_dur, 'days' ), 'eq', |
230 |
'2012-07-30T11:53:00', |
230 |
'2012-07-30T11:53:00', |
231 |
'Add 7 days (Datedue)' ); |
231 |
'Add 7 days (Datedue)' ); |
232 |
|
232 |
|
233 |
is( $cal->addDate( $saturday, $one_day_dur, 'days' )->day_of_week, 1, |
233 |
is( $cal->addDuration( $saturday, $one_day_dur, 'days' )->day_of_week, 1, |
234 |
'addDate skips closed Sunday (Datedue)' ); |
234 |
'addDuration skips closed Sunday (Datedue)' ); |
235 |
|
235 |
|
236 |
is( $cal->addDate($day_after_christmas, -1, 'days')->ymd(), '2012-12-24', |
236 |
is( $cal->addDuration($day_after_christmas, -1, 'days')->ymd(), '2012-12-24', |
237 |
'Negative call to addDate (Datedue)' ); |
237 |
'Negative call to addDuration (Datedue)' ); |
238 |
|
238 |
|
239 |
## Note that the days_between API says closed days are not considered. |
239 |
## Note that the days_between API says closed days are not considered. |
240 |
## This tests are here as an API test. |
240 |
## This tests are here as an API test. |
Lines 251-269
my $holiday_excepted = DateTime->new(
Link Here
|
251 |
|
251 |
|
252 |
$dt = dt_from_string('2012-07-03','iso'); |
252 |
$dt = dt_from_string('2012-07-03','iso'); |
253 |
|
253 |
|
254 |
is($cal->addDate( $dt, $one_day_dur, 'days' ), |
254 |
is($cal->addDuration( $dt, $one_day_dur, 'days' ), |
255 |
dt_from_string('2012-07-05','iso'), |
255 |
dt_from_string('2012-07-05','iso'), |
256 |
'Single day add (Calendar)' ); |
256 |
'Single day add (Calendar)' ); |
257 |
|
257 |
|
258 |
cmp_ok($cal->addDate( $test_dt, $seven_day_dur, 'days' ), 'eq', |
258 |
cmp_ok($cal->addDuration( $test_dt, $seven_day_dur, 'days' ), 'eq', |
259 |
'2012-08-01T11:53:00', |
259 |
'2012-08-01T11:53:00', |
260 |
'Add 7 days (Calendar)' ); |
260 |
'Add 7 days (Calendar)' ); |
261 |
|
261 |
|
262 |
is( $cal->addDate( $saturday, $one_day_dur, 'days' )->day_of_week, 1, |
262 |
is( $cal->addDuration( $saturday, $one_day_dur, 'days' )->day_of_week, 1, |
263 |
'addDate skips closed Sunday (Calendar)' ); |
263 |
'addDuration skips closed Sunday (Calendar)' ); |
264 |
|
264 |
|
265 |
is( $cal->addDate($day_after_christmas, -1, 'days')->ymd(), '2012-12-24', |
265 |
is( $cal->addDuration($day_after_christmas, -1, 'days')->ymd(), '2012-12-24', |
266 |
'Negative call to addDate (Calendar)' ); |
266 |
'Negative call to addDuration (Calendar)' ); |
267 |
|
267 |
|
268 |
cmp_ok( $cal->days_between( $test_dt, $later_dt )->in_units('days'), |
268 |
cmp_ok( $cal->days_between( $test_dt, $later_dt )->in_units('days'), |
269 |
'==', 40, 'days_between calculates correctly (Calendar)' ); |
269 |
'==', 40, 'days_between calculates correctly (Calendar)' ); |
Lines 279-297
my $holiday_excepted = DateTime->new(
Link Here
|
279 |
|
279 |
|
280 |
$dt = dt_from_string('2012-07-03','iso'); |
280 |
$dt = dt_from_string('2012-07-03','iso'); |
281 |
|
281 |
|
282 |
is($cal->addDate( $dt, $one_day_dur, 'days' ), |
282 |
is($cal->addDuration( $dt, $one_day_dur, 'days' ), |
283 |
dt_from_string('2012-07-04','iso'), |
283 |
dt_from_string('2012-07-04','iso'), |
284 |
'Single day add (Days)' ); |
284 |
'Single day add (Days)' ); |
285 |
|
285 |
|
286 |
cmp_ok($cal->addDate( $test_dt, $seven_day_dur, 'days' ),'eq', |
286 |
cmp_ok($cal->addDuration( $test_dt, $seven_day_dur, 'days' ),'eq', |
287 |
'2012-07-30T11:53:00', |
287 |
'2012-07-30T11:53:00', |
288 |
'Add 7 days (Days)' ); |
288 |
'Add 7 days (Days)' ); |
289 |
|
289 |
|
290 |
is( $cal->addDate( $saturday, $one_day_dur, 'days' )->day_of_week, 7, |
290 |
is( $cal->addDuration( $saturday, $one_day_dur, 'days' )->day_of_week, 7, |
291 |
'addDate doesn\'t skip closed Sunday (Days)' ); |
291 |
'addDuration doesn\'t skip closed Sunday (Days)' ); |
292 |
|
292 |
|
293 |
is( $cal->addDate($day_after_christmas, -1, 'days')->ymd(), '2012-12-25', |
293 |
is( $cal->addDuration($day_after_christmas, -1, 'days')->ymd(), '2012-12-25', |
294 |
'Negative call to addDate (Days)' ); |
294 |
'Negative call to addDuration (Days)' ); |
295 |
|
295 |
|
296 |
## Note that the days_between API says closed days are not considered. |
296 |
## Note that the days_between API says closed days are not considered. |
297 |
## This tests are here as an API test. |
297 |
## This tests are here as an API test. |
298 |
- |
|
|