line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Handler::Test; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
100175
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
240
|
|
4
|
7
|
|
|
7
|
|
40
|
use Carp; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
531
|
|
5
|
7
|
|
|
7
|
|
35
|
use Exporter; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
256
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
34
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
1035
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = sprintf '%d.%03d', q$Revision: 1.13 $ =~ /: (\d+).(\d+)/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
@EXPORT = qw(LoadTestConfig SkipTest); |
13
|
|
|
|
|
|
|
|
14
|
7
|
|
|
7
|
|
10115
|
use Test; |
|
7
|
|
|
|
|
30676
|
|
|
7
|
|
|
|
|
1097
|
|
15
|
7
|
|
|
7
|
|
4642
|
use Date::Handler; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
256
|
|
16
|
7
|
|
|
7
|
|
5924
|
use Date::Handler::Delta; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
222
|
|
17
|
7
|
|
|
7
|
|
3995
|
use Date::Handler::Range; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
185
|
|
18
|
7
|
|
|
7
|
|
41
|
use Data::Dumper; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
62448
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub basic |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
#Tests basic concepts: |
23
|
|
|
|
|
|
|
#date + delta = date |
24
|
|
|
|
|
|
|
#delta + delta = delta |
25
|
|
|
|
|
|
|
#delta - delta = delta |
26
|
|
|
|
|
|
|
#delta * (+|-)n = (delta + delta [...n]) |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
0
|
14
|
plan tests => 145; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
## Testing basic delta equalities |
31
|
|
|
|
|
|
|
#1 |
32
|
1
|
|
|
|
|
4008
|
ok ( '0:0', '0:0' ); |
33
|
|
|
|
|
|
|
#2 |
34
|
1
|
|
|
|
|
308
|
ok ( new Date::Handler::Delta([0,0,0,0,0,1]), new Date::Handler::Delta([0,0,0,0,0,1]) ); |
35
|
|
|
|
|
|
|
#3 |
36
|
1
|
|
|
|
|
76
|
ok ( new Date::Handler::Delta({years => 0, months => 0, days => 0, hours => 0, minutes => 0, seconds => 1}), |
37
|
|
|
|
|
|
|
new Date::Handler::Delta({years => 0, months => 0, days => 0, hours => 0, minutes => 0, seconds => 1}) ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#4 |
40
|
1
|
|
|
|
|
50
|
ok ( '0:1', new Date::Handler::Delta([0,0,0,0,0,1]) ); |
41
|
|
|
|
|
|
|
#5 |
42
|
1
|
|
|
|
|
94
|
ok ( '0:1', new Date::Handler::Delta({ |
43
|
|
|
|
|
|
|
years => 0, |
44
|
|
|
|
|
|
|
months => 0, |
45
|
|
|
|
|
|
|
days => 0, |
46
|
|
|
|
|
|
|
hours => 0, |
47
|
|
|
|
|
|
|
minutes => 0, |
48
|
|
|
|
|
|
|
seconds => 1, |
49
|
|
|
|
|
|
|
}) ); |
50
|
|
|
|
|
|
|
#6 |
51
|
1
|
|
|
|
|
48
|
ok ( new Date::Handler::Delta([0,0,0,0,0,1]), new Date::Handler::Delta({ |
52
|
|
|
|
|
|
|
years => 0, |
53
|
|
|
|
|
|
|
months => 0, |
54
|
|
|
|
|
|
|
days => 0, |
55
|
|
|
|
|
|
|
hours => 0, |
56
|
|
|
|
|
|
|
minutes => 0, |
57
|
|
|
|
|
|
|
seconds => 1, |
58
|
|
|
|
|
|
|
}) ); |
59
|
|
|
|
|
|
|
#7 |
60
|
1
|
|
|
|
|
48
|
ok ( new Date::Handler::Delta([0,13,366,24,60,61]), |
61
|
|
|
|
|
|
|
new Date::Handler::Delta([1,1,367,1,1,1]) ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Testing delta 0 |
65
|
|
|
|
|
|
|
#8 delta 0 + delta 0 = delta 0 |
66
|
1
|
|
|
|
|
47
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + new Date::Handler::Delta([0,0,0,0,0,0]), |
67
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
68
|
|
|
|
|
|
|
#9 proof of error |
69
|
1
|
|
|
|
|
53
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + new Date::Handler::Delta([0,0,0,0,0,0]) ne |
70
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,1]) ); |
71
|
|
|
|
|
|
|
#10 delta 0 + delta A = delta A |
72
|
1
|
|
|
|
|
63
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + new Date::Handler::Delta([6,5,4,3,2,1]), |
73
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
74
|
|
|
|
|
|
|
#11 proof of error |
75
|
1
|
|
|
|
|
47
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + new Date::Handler::Delta([6,5,4,3,2,1]) ne |
76
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,0]) ); |
77
|
|
|
|
|
|
|
#12 delta A + delta 0 = delta A |
78
|
1
|
|
|
|
|
56
|
ok ( new Date::Handler::Delta([6,5,4,3,2,1]) + new Date::Handler::Delta([0,0,0,0,0,0]), |
79
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
80
|
|
|
|
|
|
|
#13 proof of error |
81
|
1
|
|
|
|
|
51
|
ok ( new Date::Handler::Delta([6,5,4,3,2,1]) + new Date::Handler::Delta([0,0,0,0,0,0]) ne |
82
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,0]) ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Testing non-zero deltas |
85
|
|
|
|
|
|
|
#14 adding small deltas |
86
|
1
|
|
|
|
|
59
|
ok ( new Date::Handler::Delta([6,0,4,0,2,0]) + new Date::Handler::Delta([0,5,0,3,0,1]), |
87
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
88
|
|
|
|
|
|
|
#15 proof of error |
89
|
1
|
|
|
|
|
43
|
ok ( new Date::Handler::Delta([6,0,4,0,2,0]) + new Date::Handler::Delta([0,5,0,3,0,1]) ne |
90
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,5,3,2,1]) ); |
91
|
|
|
|
|
|
|
#16 adding large deltas |
92
|
1
|
|
|
|
|
53
|
ok ( new Date::Handler::Delta([12,23,34,45,56,67]) + new Date::Handler::Delta([23,34,45,56,67,78]), |
93
|
|
|
|
|
|
|
new Date::Handler::Delta([35,57,79,101,123,145]) ); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
## Testing positive deltas with the '-' operator |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Testing delta 0 |
98
|
|
|
|
|
|
|
#17 delta 0 - delta 0 = delta 0 |
99
|
1
|
|
|
|
|
41
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) - new Date::Handler::Delta([0,0,0,0,0,0]), |
100
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
101
|
|
|
|
|
|
|
#18 proof of error |
102
|
1
|
|
|
|
|
41
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) - new Date::Handler::Delta([0,0,0,0,0,0]) ne |
103
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,1]) ); |
104
|
|
|
|
|
|
|
#19 delta 0 - delta A = delta A |
105
|
1
|
|
|
|
|
52
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) - new Date::Handler::Delta([6,5,4,3,2,1]), |
106
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
107
|
|
|
|
|
|
|
#20 proof of error |
108
|
1
|
|
|
|
|
42
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) - new Date::Handler::Delta([6,5,4,3,2,1]) ne |
109
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,0]) ); |
110
|
|
|
|
|
|
|
#21 delta A - delta 0 = delta A |
111
|
1
|
|
|
|
|
84
|
ok ( new Date::Handler::Delta([6,5,4,3,2,1]) - new Date::Handler::Delta([0,0,0,0,0,0]), |
112
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
113
|
|
|
|
|
|
|
#22 proof of error |
114
|
1
|
|
|
|
|
58
|
ok ( new Date::Handler::Delta([6,5,4,3,2,1]) - new Date::Handler::Delta([0,0,0,0,0,0]) ne |
115
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,0]) ); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Testing non-zero deltas |
118
|
|
|
|
|
|
|
#23 substracting small deltas |
119
|
1
|
|
|
|
|
58
|
ok ( new Date::Handler::Delta([6,5,4,3,2,1]) - new Date::Handler::Delta([5,4,3,2,1,0]), |
120
|
|
|
|
|
|
|
new Date::Handler::Delta([1,1,1,1,1,1]) ); |
121
|
|
|
|
|
|
|
#24 proof of error |
122
|
1
|
|
|
|
|
44
|
ok ( new Date::Handler::Delta([6,0,4,0,2,0]) - new Date::Handler::Delta([0,5,0,3,0,1]) ne |
123
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,5,3,2,1]) ); |
124
|
|
|
|
|
|
|
#25 substracting large deltas to obtain positive delta |
125
|
1
|
|
|
|
|
78
|
ok ( new Date::Handler::Delta([23,34,45,56,67,78]) - new Date::Handler::Delta([12,23,34,45,56,67]), |
126
|
|
|
|
|
|
|
new Date::Handler::Delta([11,11,11,11,11,11]) ); |
127
|
|
|
|
|
|
|
#26 substracting large deltas to obtain negative delta |
128
|
1
|
|
|
|
|
46
|
ok ( new Date::Handler::Delta([12,23,34,45,56,67]) - new Date::Handler::Delta([23,34,45,56,67,78]), |
129
|
|
|
|
|
|
|
new Date::Handler::Delta([-11,-11,-11,-11,-11,-11]) ); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
## Testing negative deltas with '+' operator |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Testing delta 0 |
134
|
|
|
|
|
|
|
#27 delta -0 + delta 0 = delta 0 |
135
|
1
|
|
|
|
|
41
|
ok ( new Date::Handler::Delta([-0,0,-0,0,-0,0]) + new Date::Handler::Delta([0,-0,0,-0,0,-0]), |
136
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
137
|
|
|
|
|
|
|
#28 proof of error |
138
|
1
|
|
|
|
|
38
|
ok ( new Date::Handler::Delta([-0,0,-0,0,-0,0]) + new Date::Handler::Delta([0,-0,0,-0,0,-0]) ne |
139
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,1]) ); |
140
|
|
|
|
|
|
|
#29 delta 0 + delta -A = delta -A |
141
|
1
|
|
|
|
|
131
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]), |
142
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
143
|
|
|
|
|
|
|
#30 proof of error |
144
|
1
|
|
|
|
|
43
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ne |
145
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
146
|
|
|
|
|
|
|
#31 delta -A + delta 0 = delta -A |
147
|
1
|
|
|
|
|
52
|
ok ( new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) + new Date::Handler::Delta([0,0,0,0,0,0]), |
148
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
149
|
|
|
|
|
|
|
#32 proof of error |
150
|
1
|
|
|
|
|
37
|
ok ( new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) + new Date::Handler::Delta([0,0,0,0,0,0]) ne |
151
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Testing non-zero deltas |
154
|
|
|
|
|
|
|
#33 adding small deltas |
155
|
1
|
|
|
|
|
60
|
ok ( new Date::Handler::Delta([-6,0,-4,0,-2,0]) + new Date::Handler::Delta([0,-5,0,-3,0,-1]), |
156
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
157
|
|
|
|
|
|
|
#34 proof of error |
158
|
1
|
|
|
|
|
38
|
ok ( new Date::Handler::Delta([-6,0,-4,0,-2,0]) + new Date::Handler::Delta([0,-5,0,-3,0,-1]) ne |
159
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,5,5,3,2,1]) ); |
160
|
|
|
|
|
|
|
#35 adding large deltas |
161
|
1
|
|
|
|
|
52
|
ok ( new Date::Handler::Delta([-12,-23,-34,-45,-56,-67]) + new Date::Handler::Delta([-23,-34,-45,-56,-67,-78]), |
162
|
|
|
|
|
|
|
new Date::Handler::Delta([-35,-57,-79,-101,-123,-145]) ); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
## Testing negative deltas with the '-' operator |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
#Testing delta 0 |
167
|
|
|
|
|
|
|
#36 delta -0 - delta 0 = delta 0 |
168
|
1
|
|
|
|
|
47
|
ok ( new Date::Handler::Delta([-0,0,-0,0,-0,0]) - new Date::Handler::Delta([0,-0,0,-0,0,-0]), |
169
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
170
|
|
|
|
|
|
|
#37 proof of error |
171
|
1
|
|
|
|
|
51
|
ok ( new Date::Handler::Delta([-0,0,-0,0,-0,0]) - new Date::Handler::Delta([0,-0,0,-0,0,-0]) ne |
172
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,1]) ); |
173
|
|
|
|
|
|
|
#38 delta 0 - delta -A = delta A |
174
|
1
|
|
|
|
|
62
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) - new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]), |
175
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
176
|
|
|
|
|
|
|
#39 proof of error |
177
|
1
|
|
|
|
|
50
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) - new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ne |
178
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
179
|
|
|
|
|
|
|
#40 delta -A - delta 0 = delta -A |
180
|
1
|
|
|
|
|
64
|
ok ( new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) - new Date::Handler::Delta([0,0,0,0,0,0]), |
181
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
182
|
|
|
|
|
|
|
#41 proof of error |
183
|
1
|
|
|
|
|
62
|
ok ( new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) - new Date::Handler::Delta([0,0,0,0,0,0]) ne |
184
|
|
|
|
|
|
|
new Date::Handler::Delta([6,5,4,3,2,1]) ); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# Testing non-zero deltas |
187
|
|
|
|
|
|
|
#42 adding small deltas |
188
|
1
|
|
|
|
|
52
|
ok ( new Date::Handler::Delta([-6,0,-4,0,-2,0]) - new Date::Handler::Delta([0,-5,0,-3,0,-1]), |
189
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,5,-4,3,-2,1]) ); |
190
|
|
|
|
|
|
|
#43 proof of error |
191
|
1
|
|
|
|
|
41
|
ok ( new Date::Handler::Delta([-6,0,-4,0,-2,0]) - new Date::Handler::Delta([0,-5,0,-3,0,-1]) ne |
192
|
|
|
|
|
|
|
new Date::Handler::Delta([-6,-5,-4,-3,-2,-1]) ); |
193
|
|
|
|
|
|
|
#44 adding large deltas |
194
|
1
|
|
|
|
|
129
|
ok ( new Date::Handler::Delta([-12,-23,-34,-45,-56,-67]) - new Date::Handler::Delta([-23,-34,-45,-56,-67,-78]), |
195
|
|
|
|
|
|
|
new Date::Handler::Delta([11,11,11,11,11,11]) ); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
## A few last tests for additions and substractions of positive and negative deltas. |
198
|
|
|
|
|
|
|
#45 |
199
|
1
|
|
|
|
|
61
|
ok ( new Date::Handler::Delta([6,0,4,0,2,0]) + new Date::Handler::Delta([0,-5,0,-3,0,-1]), |
200
|
|
|
|
|
|
|
new Date::Handler::Delta([5,7,3,21,1,59]) ); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
## Testing delta multiplications |
203
|
|
|
|
|
|
|
# Testing delta zero |
204
|
|
|
|
|
|
|
#46 |
205
|
1
|
|
|
|
|
42
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) * 0, |
206
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
207
|
|
|
|
|
|
|
#47 |
208
|
1
|
|
|
|
|
46
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) * 1, |
209
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
210
|
|
|
|
|
|
|
#48 |
211
|
1
|
|
|
|
|
39
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) * 7, |
212
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# Testing non-zero deltas |
215
|
|
|
|
|
|
|
#49 testing multiplication by zero |
216
|
1
|
|
|
|
|
38
|
ok ( new Date::Handler::Delta([2,4,6,45,218,32]) * 0, |
217
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
218
|
|
|
|
|
|
|
#50 testing multiplication by one |
219
|
1
|
|
|
|
|
41
|
ok ( new Date::Handler::Delta([2,4,6,45,218,32]) * 1, |
220
|
|
|
|
|
|
|
new Date::Handler::Delta([2,4,6,45,218,32]) ); |
221
|
|
|
|
|
|
|
#51 |
222
|
1
|
|
|
|
|
43
|
ok ( new Date::Handler::Delta([0,0,0,0,0,32]) * 5, |
223
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,2,40]) ); |
224
|
|
|
|
|
|
|
#52 |
225
|
1
|
|
|
|
|
43
|
ok ( new Date::Handler::Delta([0,0,0,0,32,0]) * 5, |
226
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,2,40,0]) ); |
227
|
|
|
|
|
|
|
#53 |
228
|
1
|
|
|
|
|
126
|
ok ( new Date::Handler::Delta([0,0,0,13,0,0]) * 7, |
229
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,91,0,0]) ); |
230
|
|
|
|
|
|
|
#54 |
231
|
1
|
|
|
|
|
43
|
ok ( new Date::Handler::Delta([0,0,50,0,0,0]) * 10, |
232
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,500,0,0,0]) ); |
233
|
|
|
|
|
|
|
#55 |
234
|
1
|
|
|
|
|
43
|
ok ( new Date::Handler::Delta([0,0,365,0,0,0]) * 1 ne |
235
|
|
|
|
|
|
|
new Date::Handler::Delta([0,1,0,0,0,0]) ); |
236
|
|
|
|
|
|
|
#56 |
237
|
1
|
|
|
|
|
57
|
ok ( new Date::Handler::Delta([0,13,0,0,0,0]) * 3, |
238
|
|
|
|
|
|
|
new Date::Handler::Delta([3,3,0,0,0,0]) ); |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
## Testing delta divisions |
241
|
|
|
|
|
|
|
# Testing delta zero |
242
|
|
|
|
|
|
|
#57 illegal division by zero |
243
|
|
|
|
|
|
|
#ok ( new Date::Handler::Delta([0,0,0,0,0,0]) / 0, |
244
|
|
|
|
|
|
|
# new Date::Handler::Delta([0,0,0,0,0,0]) ); |
245
|
|
|
|
|
|
|
#Test removed due to bad rationale. |
246
|
1
|
|
|
|
|
44
|
ok (1); |
247
|
|
|
|
|
|
|
#58 |
248
|
1
|
|
|
|
|
36
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) / 1, |
249
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
250
|
|
|
|
|
|
|
#59 |
251
|
1
|
|
|
|
|
42
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) / 7, |
252
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
## Testing non-zero deltas |
255
|
|
|
|
|
|
|
#60 illegal division by zero |
256
|
|
|
|
|
|
|
#ok ( new Date::Handler::Delta([2,4,6,45,218,32]) / 0, |
257
|
|
|
|
|
|
|
# new Date::Handler::Delta([0,0,0,0,0,0]) ); |
258
|
1
|
|
|
|
|
48
|
ok(1); |
259
|
|
|
|
|
|
|
#61 testing division by one |
260
|
1
|
|
|
|
|
29
|
ok ( new Date::Handler::Delta([2,4,6,45,218,32]) / 1, |
261
|
|
|
|
|
|
|
new Date::Handler::Delta([2,4,6,45,218,32]) ); |
262
|
|
|
|
|
|
|
#62 |
263
|
1
|
|
|
|
|
38
|
ok ( new Date::Handler::Delta([0,0,0,0,0,10]) / 5, |
264
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,2]) ); |
265
|
|
|
|
|
|
|
#63 |
266
|
1
|
|
|
|
|
39
|
ok ( new Date::Handler::Delta([0,0,0,0,2,0]) / 5, |
267
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,24]) ); |
268
|
|
|
|
|
|
|
#64 |
269
|
1
|
|
|
|
|
46
|
ok ( new Date::Handler::Delta([0,0,0,8,10,0]) / 7, |
270
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,1,10,0]) ); |
271
|
|
|
|
|
|
|
#65 |
272
|
1
|
|
|
|
|
127
|
ok ( new Date::Handler::Delta([0,0,55,0,0,0]) / 10, |
273
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,5,12,0,0]) ); |
274
|
|
|
|
|
|
|
#66 |
275
|
1
|
|
|
|
|
48
|
ok ( new Date::Handler::Delta([0,1,0,0,0,0]) / 365 ne |
276
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,1,0,0,0]) ); |
277
|
|
|
|
|
|
|
#67 |
278
|
1
|
|
|
|
|
120
|
ok ( new Date::Handler::Delta([3,3,0,0,0,0]) / 3, |
279
|
|
|
|
|
|
|
new Date::Handler::Delta([0,13,0,0,0,0]) ); |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
## Testing multiple operations |
282
|
|
|
|
|
|
|
#68 |
283
|
1
|
|
|
|
|
45
|
ok ( new Date::Handler::Delta([0,0,0,0,0,0]) + 369, new Date::Handler::Delta([0,0,0,0,0,369])); |
284
|
|
|
|
|
|
|
#69 Verifying operation priority |
285
|
1
|
|
|
|
|
39
|
ok ( new Date::Handler::Delta([0,0,0,0,0,3]) + 7 * 3, new Date::Handler::Delta([0,0,0,0,0,24]) ); |
286
|
|
|
|
|
|
|
#70 Verifying operation priority |
287
|
1
|
|
|
|
|
41
|
ok ( new Date::Handler::Delta([0,0,0,0,0,3]) + new Date::Handler::Delta([0,0,0,0,0,7]) * 3, |
288
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,24]) ); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
### Testing dates |
293
|
|
|
|
|
|
|
## Testing addition of deltas to dates |
294
|
|
|
|
|
|
|
#71 |
295
|
1
|
|
|
|
|
89
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
296
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,0]) ), |
297
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
298
|
|
|
|
|
|
|
#72 |
299
|
1
|
|
|
|
|
53
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
300
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,0]) ) ne |
301
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,45], time_zone => 'Americal/Montreal' }) ); |
302
|
|
|
|
|
|
|
#73 |
303
|
1
|
|
|
|
|
67
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
304
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,1]) ), |
305
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,45], time_zone => 'Americal/Montreal' }) ); |
306
|
|
|
|
|
|
|
#74 proof of error |
307
|
1
|
|
|
|
|
44
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
308
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,1]) ) ne |
309
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
310
|
|
|
|
|
|
|
#75 |
311
|
1
|
|
|
|
|
61
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
312
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,1,0]) ), |
313
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,17,44], time_zone => 'Americal/Montreal' }) ); |
314
|
|
|
|
|
|
|
#76 proof of error |
315
|
1
|
|
|
|
|
43
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
316
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,1,0]) ) ne |
317
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
318
|
|
|
|
|
|
|
#77 |
319
|
1
|
|
|
|
|
68
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
320
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,1,0,0]) ), |
321
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,13,16,44], time_zone => 'Americal/Montreal' }) ); |
322
|
|
|
|
|
|
|
#78 proof of error |
323
|
1
|
|
|
|
|
163
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
324
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,1,0,0]) ) ne |
325
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
326
|
|
|
|
|
|
|
#79 |
327
|
1
|
|
|
|
|
74
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
328
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,1,0,0,0]) ), |
329
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) ); |
330
|
|
|
|
|
|
|
#80 proof of error |
331
|
1
|
|
|
|
|
95
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
332
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,1,0,0,0]) ) ne |
333
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
334
|
|
|
|
|
|
|
#81 |
335
|
1
|
|
|
|
|
63
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
336
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,1,0,0,0,0]) ), |
337
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,03,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
338
|
|
|
|
|
|
|
#82 proof of error |
339
|
1
|
|
|
|
|
78
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
340
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,1,0,0,0,0]) ) ne |
341
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
342
|
|
|
|
|
|
|
#83 |
343
|
1
|
|
|
|
|
66
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
344
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,0,0,0,0,0]) ), |
345
|
|
|
|
|
|
|
new Date::Handler({ date => [2002,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
346
|
|
|
|
|
|
|
#84 proof of error |
347
|
1
|
|
|
|
|
58
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
348
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,0,0,0,0,0]) ) ne |
349
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
## Testing substraction of deltas from dates. |
353
|
|
|
|
|
|
|
#85 |
354
|
1
|
|
|
|
|
91
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
355
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,0]) ), |
356
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
357
|
|
|
|
|
|
|
#86 proof of error |
358
|
1
|
|
|
|
|
80
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
359
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,0]) ) ne |
360
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,41], time_zone => 'Americal/Montreal' }) ); |
361
|
|
|
|
|
|
|
#87 |
362
|
1
|
|
|
|
|
75
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
363
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,1]) ), |
364
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,43], time_zone => 'Americal/Montreal' }) ); |
365
|
|
|
|
|
|
|
#88 proof of error |
366
|
1
|
|
|
|
|
70
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
367
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,0,1]) ) ne |
368
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
369
|
|
|
|
|
|
|
#89 |
370
|
1
|
|
|
|
|
71
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
371
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,1,0]) ), |
372
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,15,44], time_zone => 'Americal/Montreal' }) ); |
373
|
|
|
|
|
|
|
#90 proof of error |
374
|
1
|
|
|
|
|
50
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
375
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,0,1,0]) ) ne |
376
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
377
|
|
|
|
|
|
|
#91 |
378
|
1
|
|
|
|
|
84
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
379
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,1,0,0]) ), |
380
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,11,16,44], time_zone => 'Americal/Montreal' }) ); |
381
|
|
|
|
|
|
|
#92 proof of error |
382
|
1
|
|
|
|
|
67
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
383
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,0,1,0,0]) ) ne |
384
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
385
|
|
|
|
|
|
|
#93 |
386
|
1
|
|
|
|
|
68
|
ok ( ( new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
387
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,1,0,0,0]) ), |
388
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
389
|
|
|
|
|
|
|
#94 proof of error |
390
|
1
|
|
|
|
|
46
|
ok ( ( new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
391
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,0,1,0,0,0]) ) ne |
392
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) ); |
393
|
|
|
|
|
|
|
#95 |
394
|
1
|
|
|
|
|
59
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
395
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,1,0,0,0,0]) ), |
396
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,01,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
397
|
|
|
|
|
|
|
#96 proof of error |
398
|
1
|
|
|
|
|
44
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
399
|
|
|
|
|
|
|
( new Date::Handler::Delta([0,1,0,0,0,0]) ) ne |
400
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
401
|
|
|
|
|
|
|
#97 |
402
|
1
|
|
|
|
|
69
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
403
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,0,0,0,0,0]) ), |
404
|
|
|
|
|
|
|
new Date::Handler({ date => [2000,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
405
|
|
|
|
|
|
|
#98 proof of error |
406
|
1
|
|
|
|
|
56
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
407
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,0,0,0,0,0]) ) ne |
408
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
## Testing number 71 to 84 by swapping the deltas with the dates. |
412
|
|
|
|
|
|
|
#99 |
413
|
1
|
|
|
|
|
62
|
ok ( ( new Date::Handler::Delta([0,0,0,0,0,0]) ) + |
414
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
415
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
416
|
|
|
|
|
|
|
#100 proof of error |
417
|
1
|
|
|
|
|
46
|
ok ( ( new Date::Handler::Delta([0,0,0,0,0,0]) ) + |
418
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) )ne |
419
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,41], time_zone => 'Americal/Montreal' }) ); |
420
|
|
|
|
|
|
|
#101 |
421
|
1
|
|
|
|
|
64
|
ok ( ( new Date::Handler::Delta([0,0,0,0,0,1]) ) + |
422
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
423
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,45], time_zone => 'Americal/Montreal' }) ); |
424
|
|
|
|
|
|
|
#102 proof of error |
425
|
1
|
|
|
|
|
46
|
ok ( ( new Date::Handler::Delta([0,0,0,0,0,1]) ) + |
426
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) )ne |
427
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
428
|
|
|
|
|
|
|
#103 |
429
|
1
|
|
|
|
|
62
|
ok ( ( new Date::Handler::Delta([0,0,0,0,1,0]) ) + |
430
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
431
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,17,44], time_zone => 'Americal/Montreal' }) ); |
432
|
|
|
|
|
|
|
#104 proof of error |
433
|
1
|
|
|
|
|
61
|
ok ( ( new Date::Handler::Delta([0,0,0,0,1,0]) ) + |
434
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) )ne |
435
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
436
|
|
|
|
|
|
|
#105 |
437
|
1
|
|
|
|
|
81
|
ok ( ( new Date::Handler::Delta([0,0,0,1,0,0]) ) + |
438
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
439
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,13,16,44], time_zone => 'Americal/Montreal' }) ); |
440
|
|
|
|
|
|
|
#106 proof of error |
441
|
1
|
|
|
|
|
45
|
ok ( ( new Date::Handler::Delta([0,0,0,1,0,0]) ) + |
442
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) )ne |
443
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
444
|
|
|
|
|
|
|
#107 |
445
|
1
|
|
|
|
|
65
|
ok ( ( new Date::Handler::Delta([0,0,1,0,0,0]) ) + |
446
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
447
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) ); |
448
|
|
|
|
|
|
|
#108 proof of error |
449
|
1
|
|
|
|
|
44
|
ok ( ( new Date::Handler::Delta([0,0,1,0,0,0]) ) + |
450
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) )ne |
451
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,02,12,16,44], time_zone => 'Americal/Montreal' }) ); |
452
|
|
|
|
|
|
|
#109 |
453
|
1
|
|
|
|
|
126
|
ok ( ( new Date::Handler::Delta([0,1,0,0,0,0]) ) + |
454
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
455
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,03,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
456
|
|
|
|
|
|
|
#110 proof of error |
457
|
1
|
|
|
|
|
31
|
ok ( ( new Date::Handler::Delta([0,1,0,0,0,0]) ) + |
458
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) )ne |
459
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
460
|
|
|
|
|
|
|
#111 |
461
|
1
|
|
|
|
|
107
|
ok ( ( new Date::Handler::Delta([1,0,0,0,0,0]) ) + |
462
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
463
|
|
|
|
|
|
|
new Date::Handler({ date => [2002,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
464
|
|
|
|
|
|
|
#112 proof of error |
465
|
1
|
|
|
|
|
44
|
ok ( ( new Date::Handler::Delta([1,0,0,0,0,0]) ) + |
466
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
467
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
## Testing substraction of dates from deltas. |
471
|
|
|
|
|
|
|
#113 |
472
|
|
|
|
|
|
|
#ok ( ( new Date::Handler::Delta([0,0,0,0,0,0]) ) - |
473
|
|
|
|
|
|
|
# ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
474
|
|
|
|
|
|
|
# new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
475
|
1
|
|
|
|
|
41
|
ok(1,1); |
476
|
|
|
|
|
|
|
#114 |
477
|
|
|
|
|
|
|
#ok ( ( new Date::Handler::Delta([0,0,0,0,0,1]) ) - |
478
|
|
|
|
|
|
|
# ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
479
|
|
|
|
|
|
|
# new Date::Handler({ date => [2001,02,01,12,16,43], time_zone => 'Americal/Montreal' }) ); |
480
|
1
|
|
|
|
|
35
|
ok(1,1); |
481
|
|
|
|
|
|
|
## Testing equality. |
482
|
|
|
|
|
|
|
#115 |
483
|
1
|
|
|
|
|
39
|
ok ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }), |
484
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
## Testing large additions, large substractions. |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
## Testing date - date = delta |
490
|
|
|
|
|
|
|
#116 |
491
|
1
|
|
|
|
|
48
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
492
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
493
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
494
|
|
|
|
|
|
|
#117 proof of error |
495
|
1
|
|
|
|
|
27
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
496
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
497
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,1]) ); |
498
|
|
|
|
|
|
|
#118 |
499
|
1
|
|
|
|
|
76
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,45], time_zone => 'Americal/Montreal' }) ) - |
500
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
501
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,1]) ); |
502
|
|
|
|
|
|
|
#119 proof of error |
503
|
1
|
|
|
|
|
34
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,45], time_zone => 'Americal/Montreal' }) ) - |
504
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
505
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
506
|
|
|
|
|
|
|
#120 |
507
|
1
|
|
|
|
|
54
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,18,44], time_zone => 'Americal/Montreal' }) ) - |
508
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
509
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,2,0]) ); |
510
|
|
|
|
|
|
|
#121 proof of error |
511
|
1
|
|
|
|
|
35
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,18,44], time_zone => 'Americal/Montreal' }) ) - |
512
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
513
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
514
|
|
|
|
|
|
|
#122 |
515
|
1
|
|
|
|
|
57
|
ok ( ( new Date::Handler({ date => [2001,02,01,15,16,44], time_zone => 'Americal/Montreal' }) ) - |
516
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
517
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,3,0,0]) ); |
518
|
|
|
|
|
|
|
#123 proof of error |
519
|
1
|
|
|
|
|
30
|
ok ( ( new Date::Handler({ date => [2001,02,01,15,16,44], time_zone => 'Americal/Montreal' }) ) - |
520
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
521
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
522
|
|
|
|
|
|
|
#124 |
523
|
1
|
|
|
|
|
45
|
ok ( ( new Date::Handler({ date => [2001,02,05,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
524
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
525
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,4,0,0,0]) ); |
526
|
|
|
|
|
|
|
#125 proof of error |
527
|
1
|
|
|
|
|
28
|
ok ( ( new Date::Handler({ date => [2001,02,05,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
528
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
529
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
530
|
|
|
|
|
|
|
#126 |
531
|
1
|
|
|
|
|
43
|
ok ( ( new Date::Handler({ date => [2001,07,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
532
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
533
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,12960000]) ); |
534
|
|
|
|
|
|
|
#127 proof of error |
535
|
1
|
|
|
|
|
30
|
ok ( ( new Date::Handler({ date => [2001,07,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
536
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
537
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
538
|
|
|
|
|
|
|
#128 Test remove dur to bad rationale |
539
|
1
|
|
|
|
|
45
|
ok (1); |
540
|
|
|
|
|
|
|
##ok ( ( new Date::Handler({ date => [2007,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
541
|
|
|
|
|
|
|
# ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ), |
542
|
|
|
|
|
|
|
# new Date::Handler::Delta([6,0,0,0,0,0]) ); |
543
|
|
|
|
|
|
|
#129 proof of error |
544
|
1
|
|
|
|
|
60
|
ok ( ( new Date::Handler({ date => [2007,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
545
|
|
|
|
|
|
|
( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) ne |
546
|
|
|
|
|
|
|
new Date::Handler::Delta([0,0,0,0,0,0]) ); |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
## Testing special cases of date + delta = date |
549
|
|
|
|
|
|
|
#130 |
550
|
1
|
|
|
|
|
46
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
551
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,-1,1,-1,1,-1]) ), |
552
|
|
|
|
|
|
|
new Date::Handler({ date => [2002,01,02,11,17,43], time_zone => 'Americal/Montreal' }) ); |
553
|
|
|
|
|
|
|
#131 |
554
|
1
|
|
|
|
|
49
|
ok ( ( new Date::Handler({ date => [2001,02,03,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
555
|
|
|
|
|
|
|
( new Date::Handler::Delta([-2,2,-2,2,-2,2]) ), |
556
|
|
|
|
|
|
|
new Date::Handler({ date => [1999,04,01,14,14,46], time_zone => 'Americal/Montreal' }) ); |
557
|
|
|
|
|
|
|
#132 |
558
|
1
|
|
|
|
|
34
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
559
|
|
|
|
|
|
|
( new Date::Handler::Delta([25,-17,0,0,40,240]) ), |
560
|
|
|
|
|
|
|
new Date::Handler({ date => [2024,9,01,13,0,44], time_zone => 'Americal/Montreal' }) ); |
561
|
|
|
|
|
|
|
#133 |
562
|
|
|
|
|
|
|
#Test remove dur to bad rationale |
563
|
1
|
|
|
|
|
29
|
ok (1); |
564
|
|
|
|
|
|
|
#ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
565
|
|
|
|
|
|
|
# ( new Date::Handler::Delta([300,0,0,0,0,0]) ), |
566
|
|
|
|
|
|
|
# new Date::Handler({ date => [2301,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
567
|
|
|
|
|
|
|
# Testing special cases of date - delta = date |
568
|
|
|
|
|
|
|
#134 |
569
|
1
|
|
|
|
|
36
|
ok ( ( new Date::Handler({ date => [2002,01,02,11,17,43], time_zone => 'Americal/Montreal' }) ) - |
570
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,-1,1,-1,1,-1]) ), |
571
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
572
|
|
|
|
|
|
|
#135 |
573
|
1
|
|
|
|
|
30
|
ok ( ( new Date::Handler({ date => [1999,04,01,14,14,46], time_zone => 'Americal/Montreal' }) ) - |
574
|
|
|
|
|
|
|
( new Date::Handler::Delta([-2,2,-2,2,-2,2]) ), |
575
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,03,12,16,44], time_zone => 'Americal/Montreal' }) ); |
576
|
|
|
|
|
|
|
#136 |
577
|
1
|
|
|
|
|
39
|
ok ( ( new Date::Handler({ date => [2024,9,01,13,0,44], time_zone => 'Americal/Montreal' }) ) - |
578
|
|
|
|
|
|
|
( new Date::Handler::Delta([25,-17,0,0,40,240]) ), |
579
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
580
|
|
|
|
|
|
|
#137 Test remove dur to bad rationale |
581
|
1
|
|
|
|
|
27
|
ok(1); |
582
|
|
|
|
|
|
|
#ok ( ( new Date::Handler({ date => [2301,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
583
|
|
|
|
|
|
|
# ( new Date::Handler::Delta([300,0,0,0,0,0]) ), |
584
|
|
|
|
|
|
|
# new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
585
|
|
|
|
|
|
|
## Testing special cases of date - date = delta. |
586
|
|
|
|
|
|
|
#138 |
587
|
1
|
|
|
|
|
34
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
588
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,-1,1,-1,1,-1]) ), |
589
|
|
|
|
|
|
|
new Date::Handler({ date => [2002,01,02,11,17,43], time_zone => 'Americal/Montreal' }) ); |
590
|
|
|
|
|
|
|
#139 |
591
|
1
|
|
|
|
|
148
|
ok ( ( new Date::Handler({ date => [2001,02,03,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
592
|
|
|
|
|
|
|
( new Date::Handler::Delta([-2,2,-2,2,-2,2]) ), |
593
|
|
|
|
|
|
|
new Date::Handler({ date => [1999,04,01,14,14,46], time_zone => 'Americal/Montreal' }) ); |
594
|
|
|
|
|
|
|
#140 |
595
|
1
|
|
|
|
|
37
|
ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
596
|
|
|
|
|
|
|
( new Date::Handler::Delta([25,-17,0,0,40,240]) ), |
597
|
|
|
|
|
|
|
new Date::Handler({ date => [2024,9,01,13,0,44], time_zone => 'Americal/Montreal' }) ); |
598
|
|
|
|
|
|
|
#141 Test remove due to bad rationale. |
599
|
1
|
|
|
|
|
118
|
ok(1); |
600
|
|
|
|
|
|
|
#ok ( ( new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) + |
601
|
|
|
|
|
|
|
# ( new Date::Handler::Delta([300,0,0,0,0,0]) ), |
602
|
|
|
|
|
|
|
# new Date::Handler({ date => [2301,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
603
|
|
|
|
|
|
|
# Testing special cases of date - delta = date |
604
|
|
|
|
|
|
|
#142 |
605
|
1
|
|
|
|
|
198
|
ok ( ( new Date::Handler({ date => [2002,01,02,11,17,43], time_zone => 'Americal/Montreal' }) ) - |
606
|
|
|
|
|
|
|
( new Date::Handler::Delta([1,-1,1,-1,1,-1]) ), |
607
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
608
|
|
|
|
|
|
|
#143 |
609
|
1
|
|
|
|
|
1108
|
ok ( ( new Date::Handler({ date => [1999,04,01,14,14,46], time_zone => 'Americal/Montreal' }) ) - |
610
|
|
|
|
|
|
|
( new Date::Handler::Delta([-2,2,-2,2,-2,2]) ), |
611
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,03,12,16,44], time_zone => 'Americal/Montreal' }) ); |
612
|
|
|
|
|
|
|
#144 |
613
|
1
|
|
|
|
|
64
|
ok ( ( new Date::Handler({ date => [2024,9,01,13,0,44], time_zone => 'Americal/Montreal' }) ) - |
614
|
|
|
|
|
|
|
( new Date::Handler::Delta([25,-17,0,0,40,240]) ), |
615
|
|
|
|
|
|
|
new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
616
|
|
|
|
|
|
|
#145 Test removed due to bad rationale. |
617
|
1
|
|
|
|
|
62
|
ok(1); |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=head1 NAME |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
Date::Handler::Test - Test module for Date::Handler |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=head1 DESCRIPTION |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
This module provides a series of test cases to be runned during the make test of |
630
|
|
|
|
|
|
|
the Date::Handler module. |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=head1 SYNOPSIS |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
use Date::Handler::Test; |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
Date::Handler::Test::basic(); |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head1 DESCRIPTION |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
This module is incomplete and a lot of effort has to be put in it to add the remaining |
641
|
|
|
|
|
|
|
test cases. If you think you can help, please contact the author. |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head1 AUTHOR |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Benoit Beausejour |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
=head1 SEE ALSO |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
perl(1). |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=cut |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
#----------------------------------- BELOW ARE STILL TO BE INTEGRATED TEST CASES |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
#ok ( ( new Date::Handler({ date => [2301,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ) - |
657
|
|
|
|
|
|
|
# ( new Date::Handler::Delta([300,0,0,0,0,0]) ), |
658
|
|
|
|
|
|
|
# new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) ); |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
# #1-2 difference of exactly one month |
661
|
|
|
|
|
|
|
# ok((new Date::Handler({ date => [2001,02,01,12,16,44], time_zone => 'Americal/Montreal' }) - |
662
|
|
|
|
|
|
|
# new Date::Handler({ date => [2001,01,01,12,16,44], time_zone => 'Americal/Montreal' }))->Seconds(), |
663
|
|
|
|
|
|
|
# +2678400 ); |
664
|
|
|
|
|
|
|
# ok(new Date::Handler('moment' => 'Feb 1 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 1 12:16:44 EST 2001'),'+0:1:0:0:0:0:0'); |
665
|
|
|
|
|
|
|
# |
666
|
|
|
|
|
|
|
# ok( new Date::Handler('moment' => 'Feb 1 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 1 12:16:44 EST 2001') ne '+0:0:4:3:0:0:0' ); |
667
|
|
|
|
|
|
|
# |
668
|
|
|
|
|
|
|
# |
669
|
|
|
|
|
|
|
# #substraction with undef. This fails. |
670
|
|
|
|
|
|
|
# { |
671
|
|
|
|
|
|
|
# my $diff; |
672
|
|
|
|
|
|
|
# |
673
|
|
|
|
|
|
|
# #3 undef - date => date ??? |
674
|
|
|
|
|
|
|
# $diff = eval { (undef) - new Date::Handler('moment' => 'Feb 1 12:16:44 EST 2001') } ; |
675
|
|
|
|
|
|
|
# ok( $diff ,'+0:0:0:0:0:0:0'); |
676
|
|
|
|
|
|
|
# |
677
|
|
|
|
|
|
|
# #4 date - undef => date ??? |
678
|
|
|
|
|
|
|
# $diff = eval { new Date::Handler('moment' => 'Feb 1 12:16:44 EST 2001') - (undef) } ; |
679
|
|
|
|
|
|
|
# ok( $diff ,'+0:0:0:0:0:0:0'); |
680
|
|
|
|
|
|
|
# } |
681
|
|
|
|
|
|
|
# #5 delta eq delta |
682
|
|
|
|
|
|
|
# ok( new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') , new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
683
|
|
|
|
|
|
|
# |
684
|
|
|
|
|
|
|
# #6 string eq delta |
685
|
|
|
|
|
|
|
# ok( '+0:0:0:0:0:0:0', new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
686
|
|
|
|
|
|
|
# |
687
|
|
|
|
|
|
|
# #7 delta eq string |
688
|
|
|
|
|
|
|
# ok( new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') , '+0:0:0:0:0:0:0'); |
689
|
|
|
|
|
|
|
# |
690
|
|
|
|
|
|
|
# { |
691
|
|
|
|
|
|
|
# my $diff; |
692
|
|
|
|
|
|
|
# |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
##Part 1: Testing date - date = delta |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
# #3 Testing date - date = delta 0 |
697
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:0:0:0'); |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
## Testing date - date = negative deltas |
700
|
|
|
|
|
|
|
# #4 Testing delta of -2 seconds |
701
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001'), '-0:0:0:0:0:0:2'); |
702
|
|
|
|
|
|
|
# #5 Testing delta of -3 minutes |
703
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001'), '-0:0:0:0:0:3:0'); |
704
|
|
|
|
|
|
|
# #6 Testing delta of -4 hours |
705
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001'), '-0:0:0:0:4:0:0'); |
706
|
|
|
|
|
|
|
# #7 Testing delta of -5 days |
707
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001'), '-0:0:0:5:0:0:0'); |
708
|
|
|
|
|
|
|
# #8 Testing delta of -7 months |
709
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001'), '-0:7:0:0:0:0:0'); |
710
|
|
|
|
|
|
|
# #9 Testing delta of -8 years |
711
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009'), '-8:0:0:0:0:0:0'); |
712
|
|
|
|
|
|
|
# |
713
|
|
|
|
|
|
|
##2 Testing date - date = positive deltas |
714
|
|
|
|
|
|
|
# #16 Testing delta of +2 seconds |
715
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:0:0:2'); |
716
|
|
|
|
|
|
|
# #17 Testing delta of +3 minutes |
717
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:0:3:0'); |
718
|
|
|
|
|
|
|
# #18 Testing delta of +4 hours |
719
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:4:0:0'); |
720
|
|
|
|
|
|
|
# #19 Testing delta of +5 days |
721
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:5:0:0:0'); |
722
|
|
|
|
|
|
|
# #20 Testing delta of +6 weeks |
723
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Feb 16 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:1:2:0:0:0:0'); |
724
|
|
|
|
|
|
|
# #21 Testing delta of +7 months |
725
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:7:0:0:0:0:0'); |
726
|
|
|
|
|
|
|
# #22 Testing delta of +8 years |
727
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+8:0:0:0:0:0:0'); |
728
|
|
|
|
|
|
|
# |
729
|
|
|
|
|
|
|
##3 Testing negative deltas across time spans |
730
|
|
|
|
|
|
|
# #23 Testing delta of +34 seconds across two minutes |
731
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:17:18 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:0:0:34'); |
732
|
|
|
|
|
|
|
# #24 Testing delta of +51 minutes across two hours |
733
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 13:07:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:0:51:0'); |
734
|
|
|
|
|
|
|
# #25 Testing delta of +16 hours across two days |
735
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 3 04:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:0:16:0:0'); |
736
|
|
|
|
|
|
|
# #26 Testing delta of 6 days across two weeks |
737
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 8 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '+0:0:0:6:0:0:0'); |
738
|
|
|
|
|
|
|
# #27 Testing delta of 3 weeks across two months) |
739
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Feb 18 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 28 12:16:44 EST 2001'), '+0:0:3:0:0:0:0'); |
740
|
|
|
|
|
|
|
# #28 Testing delta of 7 months across two years |
741
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Mar 2 12:16:44 EST 2002') - new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001'), '+0:7:0:0:0:0:0'); |
742
|
|
|
|
|
|
|
# |
743
|
|
|
|
|
|
|
##4 Testing positive deltas across time spans |
744
|
|
|
|
|
|
|
# #29 Testing delta of -34 seconds across two minutes |
745
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:17:18 EST 2001'), '-0:0:0:0:0:0:34'); |
746
|
|
|
|
|
|
|
# #30 Testing delta of -51 minutes across two hours |
747
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 13:07:44 EST 2001'), '-0:0:0:0:0:51:0'); |
748
|
|
|
|
|
|
|
# #31 Testing delta of -16 hours across two days |
749
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 3 04:16:44 EST 2001'), '-0:0:0:0:16:0:0'); |
750
|
|
|
|
|
|
|
# #32 Testing delta of -6 days across two weeks |
751
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 8 12:16:44 EST 2001'), '-0:0:0:6:0:0:0'); |
752
|
|
|
|
|
|
|
# #33 Testing delta of -3 weeks across two months) |
753
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 28 12:16:44 EST 2001') - new Date::Handler('moment' => 'Feb 18 12:16:44 EST 2001'), '-0:0:3:0:0:0:0'); |
754
|
|
|
|
|
|
|
# #34 Testing delta of -7 months across two years |
755
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001') - new Date::Handler('moment' => 'Mar 2 12:16:44 EST 2002'), '-0:7:0:0:0:0:0'); |
756
|
|
|
|
|
|
|
# |
757
|
|
|
|
|
|
|
# |
758
|
|
|
|
|
|
|
##Part 2: date + delta = date |
759
|
|
|
|
|
|
|
# #35 Adding delta 0 to a date |
760
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
761
|
|
|
|
|
|
|
# |
762
|
|
|
|
|
|
|
##5 Testing date + positive delta |
763
|
|
|
|
|
|
|
# #36 Adding delta +2 seconds |
764
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:2'), new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001')); |
765
|
|
|
|
|
|
|
# #37 Adding delta +3 minutes |
766
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:0:0:0:0:3:0'), new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001')); |
767
|
|
|
|
|
|
|
# #38 Adding delta +4 hours |
768
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:0:0:0:4:0:0'), new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001')); |
769
|
|
|
|
|
|
|
# #39 Adding delta +5 days |
770
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:0:0:5:0:0:0'), new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001')); |
771
|
|
|
|
|
|
|
# #40 Adding delta +6 weeks |
772
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:0:6:0:0:0:0'), new Date::Handler('moment' => 'Feb 13 12:16:44 EST 2001')); |
773
|
|
|
|
|
|
|
# #41 Adding delta +7 months |
774
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+0:7:0:0:0:0:0'), new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001')); |
775
|
|
|
|
|
|
|
# #42 Adding delta +8 years |
776
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+8:0:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009')); |
777
|
|
|
|
|
|
|
# |
778
|
|
|
|
|
|
|
##6 Testing date + negative delta = date |
779
|
|
|
|
|
|
|
# #43 Adding delta -2 seconds |
780
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001') + new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:2'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
781
|
|
|
|
|
|
|
# #44 Adding delta -3 minutes |
782
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001') + new Date::Handler::Delta('delta' => '-0:0:0:0:0:3:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
783
|
|
|
|
|
|
|
# #45 Adding delta -4 hours |
784
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001') + new Date::Handler::Delta('delta' => '-0:0:0:0:4:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
785
|
|
|
|
|
|
|
# #46 Adding delta -5 days |
786
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '-0:0:0:5:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
787
|
|
|
|
|
|
|
# #47 Adding delta -6 weeks |
788
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Feb 13 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '-0:0:6:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
789
|
|
|
|
|
|
|
# #48 Adding delta -7 months |
790
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '-0:7:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
791
|
|
|
|
|
|
|
# #49 Adding delta -8 years |
792
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009') + new Date::Handler::Delta('delta' => '-8:0:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
793
|
|
|
|
|
|
|
# |
794
|
|
|
|
|
|
|
##7 Testing positive delta + date = date |
795
|
|
|
|
|
|
|
# #50 Adding delta +2 seconds |
796
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:2') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001')); |
797
|
|
|
|
|
|
|
# #51 Adding delta +3 minutes |
798
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:3:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001')); |
799
|
|
|
|
|
|
|
# #52 Adding delta +4 hours |
800
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:4:0:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001')); |
801
|
|
|
|
|
|
|
# #53 Adding delta +5 days |
802
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:5:0:0:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001')); |
803
|
|
|
|
|
|
|
# #54 Adding delta +6 weeks |
804
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:6:0:0:0:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Feb 13 12:16:44 EST 2001')); |
805
|
|
|
|
|
|
|
# #55 Adding delta +7 months |
806
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:7:0:0:0:0:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001')); |
807
|
|
|
|
|
|
|
# #56 Adding delta +8 years |
808
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:0:0:0:0:0:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009')); |
809
|
|
|
|
|
|
|
# |
810
|
|
|
|
|
|
|
##8 Testing negative delta + date = date |
811
|
|
|
|
|
|
|
# #57 Adding delta -2 seconds |
812
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:2') + new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
813
|
|
|
|
|
|
|
# #58 Adding delta -3 minutes |
814
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:3:0') + new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
815
|
|
|
|
|
|
|
# #59 Adding delta -4 hours |
816
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:4:0:0') + new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
817
|
|
|
|
|
|
|
# #60 Adding delta -5 days |
818
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:5:0:0:0') + new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
819
|
|
|
|
|
|
|
# #61 Adding delta -6 weeks |
820
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:6:0:0:0:0') + new Date::Handler('moment' => 'Feb 13 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
821
|
|
|
|
|
|
|
# #62 Adding delta -7 months |
822
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:7:0:0:0:0:0') + new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
823
|
|
|
|
|
|
|
# #63 Adding delta -8 years |
824
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-8:0:0:0:0:0:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
825
|
|
|
|
|
|
|
# |
826
|
|
|
|
|
|
|
##9 Testing adding multiple deltas to one date |
827
|
|
|
|
|
|
|
# #64 delta + delta + date |
828
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:0:6:0:4:0:2') + new Date::Handler::Delta('delta' => '+0:7:0:5:0:3:0') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Sep 18 16:19:46 EST 2009')); |
829
|
|
|
|
|
|
|
# #65 date + delta + delta |
830
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+8:0:6:0:4:0:2') + new Date::Handler::Delta('delta' => '+0:7:0:5:0:3:0'), new Date::Handler('moment' => 'Sep 18 16:19:46 EST 2009')); |
831
|
|
|
|
|
|
|
# #66 delta + date + delta |
832
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:7:0:5:0:3:0') + new Date::Handler::Delta('delta' => '+8:0:6:0:4:0:2') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Sep 18 16:19:46 EST 2009')); |
833
|
|
|
|
|
|
|
# |
834
|
|
|
|
|
|
|
# |
835
|
|
|
|
|
|
|
##Part 3: delta + delta = delta |
836
|
|
|
|
|
|
|
##10 Testing delta 0 |
837
|
|
|
|
|
|
|
# #67 delta 0 + delta 0 = delta 0 |
838
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') + new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
839
|
|
|
|
|
|
|
# #68 delta 0 + delta A = delta A |
840
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') + new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2'), '+8:7:6:5:4:3:2'); |
841
|
|
|
|
|
|
|
# #69 delta A + delta 0 = delta A |
842
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') + new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+8:7:6:5:4:3:2'); |
843
|
|
|
|
|
|
|
##11 Testing addition |
844
|
|
|
|
|
|
|
# #70 delta A + delta B = delta C |
845
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:0:6:0:4:0:2') + new Date::Handler::Delta('delta' => '+0:7:0:5:0:3:0'), '+8:7:6:5:4:3:2'); |
846
|
|
|
|
|
|
|
# #71 delta B + delta A = delta C |
847
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:7:0:5:0:3:0') + new Date::Handler::Delta('delta' => '+8:0:6:0:4:0:2'), '+8:7:6:5:4:3:2'); |
848
|
|
|
|
|
|
|
##12 Testing addition of a large delta to a large delta |
849
|
|
|
|
|
|
|
# #72 large delta + large delta = incorrect large delta |
850
|
|
|
|
|
|
|
# ok (!(new Date::Handler::Delta('delta' => '+12:23:34:45:56:67:78') + new Date::Handler::Delta('delta' => '+23:34:45:56:67:78:89') eq '+35:57:69:101:123:145:167')); |
851
|
|
|
|
|
|
|
# #73 large delta + large delta = correct large delta |
852
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+12:23:34:45:56:67:78') + new Date::Handler::Delta('delta' => '+23:34:45:56:67:78:89'), '+39:9:94:1:5:27:47'); |
853
|
|
|
|
|
|
|
##13 Testing the addition of a large delta to a date |
854
|
|
|
|
|
|
|
# #74 delta + date |
855
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+39:9:94:1:5:27:47') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), new Date::Handler('moment' => 'Jul 23 17:44:31 EST 2042')); |
856
|
|
|
|
|
|
|
# #75 date + delta |
857
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler::Delta('delta' => '+39:9:94:1:5:27:47'), new Date::Handler('moment' => 'Jul 23 17:44:31 EST 2042')); |
858
|
|
|
|
|
|
|
# #$diff = eval {new Date::Handler::Delta('delta' => '39:9:26:1:5:27:47') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')}; |
859
|
|
|
|
|
|
|
# #print STDERR Dumper $diff; |
860
|
|
|
|
|
|
|
# |
861
|
|
|
|
|
|
|
##Part 4: delta - delta = delta |
862
|
|
|
|
|
|
|
##14 Testing delta 0 |
863
|
|
|
|
|
|
|
# #76 delta 0 - delta 0 = delta 0 |
864
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') - new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
865
|
|
|
|
|
|
|
# #77 delta 0 - delta A = delta -A |
866
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') - new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2'), '-8:7:6:5:4:3:2'); |
867
|
|
|
|
|
|
|
# #78 delta A - delta 0 = delta A |
868
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') - new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+8:7:6:5:4:3:2'); |
869
|
|
|
|
|
|
|
##15 Testing substraction of a delta from a delta |
870
|
|
|
|
|
|
|
# #79 delta A - delta B = a positive delta |
871
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') - new Date::Handler::Delta('delta' => '+7:6:5:4:3:2:1'), '+1:1:1:1:1:1:1'); |
872
|
|
|
|
|
|
|
# #80 delta B - delta A = a negative delta |
873
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+7:6:5:4:3:2:1') - new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2'), '-1:1:1:1:1:1:1'); |
874
|
|
|
|
|
|
|
##16 Testing substraction of a large delta from a large delta |
875
|
|
|
|
|
|
|
# #81 large delta - large delta = incorrect large delta |
876
|
|
|
|
|
|
|
# ok (!(new Date::Handler::Delta('delta' => '+12:23:34:45:56:67:78') - new Date::Handler::Delta('delta' => '+23:34:45:56:67:78:89') eq '-35:57:69:101:123:145:167')); |
877
|
|
|
|
|
|
|
# #82 large delta - large delta = correct large delta |
878
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+12:23:34:45:56:67:78') - new Date::Handler::Delta('delta' => '+23:34:45:56:67:78:89'), '-11:11:12:4:11:11:11'); |
879
|
|
|
|
|
|
|
##17 Testing the substraction of a large delta to a date |
880
|
|
|
|
|
|
|
# #83 date - delta |
881
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jul 23 17:44:31 EST 2042') - new Date::Handler::Delta('delta' => '+39:9:94:1:5:27:47'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
882
|
|
|
|
|
|
|
# #84 delta - date |
883
|
|
|
|
|
|
|
# #ok (new Date::Handler::Delta('delta' => '+39:9:94:1:5:27:47') - new Date::Handler('moment' => 'Jul 23 17:44:31 EST 2042'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
884
|
|
|
|
|
|
|
# ok (1,1); |
885
|
|
|
|
|
|
|
# |
886
|
|
|
|
|
|
|
##Part 5: testing delta -0 (should be the same as delta 0) |
887
|
|
|
|
|
|
|
##18 Testing delta -0 added to delta |
888
|
|
|
|
|
|
|
# #85 delta 0 + delta -0 = delta 0 |
889
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') + new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
890
|
|
|
|
|
|
|
# #86 delta -0 + delta 0 = delta 0 |
891
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0') + new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
892
|
|
|
|
|
|
|
# #87 delta -0 + delta -0 = delta 0 |
893
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0') + new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
894
|
|
|
|
|
|
|
# #88 delta -0 + delta A = delta A |
895
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0') + new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2'), '+8:7:6:5:4:3:2'); |
896
|
|
|
|
|
|
|
# #89 delta A + delta -0 = delta A |
897
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') + new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0'), '+8:7:6:5:4:3:2'); |
898
|
|
|
|
|
|
|
##19 Testing delta -0 in substracted from delta |
899
|
|
|
|
|
|
|
# #90 delta 0 - delta -0 = delta 0 |
900
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') - new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
901
|
|
|
|
|
|
|
# #91 delta -0 - delta 0 = delta 0 |
902
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0') - new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
903
|
|
|
|
|
|
|
# #92 delta -0 - delta -0 = delta 0 |
904
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0') - new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
905
|
|
|
|
|
|
|
# #93 delta -0 - delta A = delta -A |
906
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0') - new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2'), '-8:7:6:5:4:3:2'); |
907
|
|
|
|
|
|
|
# #94 delta A - delta -0 = delta A |
908
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') - new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:0'), '+8:7:6:5:4:3:2'); |
909
|
|
|
|
|
|
|
# |
910
|
|
|
|
|
|
|
##Part 6: Testing substraction of a delta to a date |
911
|
|
|
|
|
|
|
##20 Testing date - negative delta = date |
912
|
|
|
|
|
|
|
# #95 Adding delta +2 seconds |
913
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-0:0:0:0:0:0:2'), new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001')); |
914
|
|
|
|
|
|
|
# #96 Adding delta +3 minutes |
915
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-0:0:0:0:0:3:0'), new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001')); |
916
|
|
|
|
|
|
|
# #97 Adding delta +4 hours |
917
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-0:0:0:0:4:0:0'), new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001')); |
918
|
|
|
|
|
|
|
# #98 Adding delta +5 days |
919
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-0:0:0:5:0:0:0'), new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001')); |
920
|
|
|
|
|
|
|
# #99 Adding delta +6 weeks |
921
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-0:0:6:0:0:0:0'), new Date::Handler('moment' => 'Feb 13 12:16:44 EST 2001')); |
922
|
|
|
|
|
|
|
# #100 Adding delta +7 months |
923
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-0:7:0:0:0:0:0'), new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001')); |
924
|
|
|
|
|
|
|
# #101 Adding delta +8 years |
925
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '-8:0:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009')); |
926
|
|
|
|
|
|
|
##21 Testing date - positive delta + date = date |
927
|
|
|
|
|
|
|
# #102 Substracting delta 2 seconds |
928
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:46 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:2'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
929
|
|
|
|
|
|
|
# #103 Substracting delta 3 minutes |
930
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:19:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:0:0:0:3:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
931
|
|
|
|
|
|
|
# #104 Substracting delta 4 hours |
932
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 16:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:0:0:4:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
933
|
|
|
|
|
|
|
# #105 Substracting delta 5 days |
934
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 7 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:0:5:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
935
|
|
|
|
|
|
|
# #106 Substracting delta 6 weeks |
936
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Feb 13 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:6:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
937
|
|
|
|
|
|
|
# #107 Substracting delta 7 months |
938
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Aug 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:7:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
939
|
|
|
|
|
|
|
# #108 Substracting delta 8 years |
940
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2009') - new Date::Handler::Delta('delta' => '+8:0:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
941
|
|
|
|
|
|
|
# |
942
|
|
|
|
|
|
|
# |
943
|
|
|
|
|
|
|
##Part 7: delta * (+|-)n = (delta + delta [...n]) |
944
|
|
|
|
|
|
|
# #109 delta 0 * n = delta 0 |
945
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') * 5, '+0:0:0:0:0:0:0'); |
946
|
|
|
|
|
|
|
# #110 delta A * n = delta 5A |
947
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+1:1:1:1:1:1:1') * 5, '+5:5:5:5:5:5:5'); |
948
|
|
|
|
|
|
|
# #111 n * delta 0 = delta 5A |
949
|
|
|
|
|
|
|
# ok (5 * new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0'), '+0:0:0:0:0:0:0'); |
950
|
|
|
|
|
|
|
# #112 n * delta A = delta 5A |
951
|
|
|
|
|
|
|
# ok (5 * new Date::Handler::Delta('delta' => '+1:1:1:1:1:1:1'), '+5:5:5:5:5:5:5'); |
952
|
|
|
|
|
|
|
# #113 large delta A * n = delta 5A |
953
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+1:3:1:2:5:11:11') * 6, '+7:6:7:6:7:7:6'); |
954
|
|
|
|
|
|
|
# #114 delta A * 1 = delta A |
955
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') * 1, '+8:7:6:5:4:3:2'); |
956
|
|
|
|
|
|
|
# #115 delta A * 0 = delta 0 |
957
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:0') * 0, '+0:0:0:0:0:0:0'); |
958
|
|
|
|
|
|
|
# #116 delta A * -1 = delta -A |
959
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '+8:7:6:5:4:3:2') * -1, '-8:7:6:5:4:3:2'); |
960
|
|
|
|
|
|
|
# #117 delta A * 2.6 = delta |
961
|
|
|
|
|
|
|
# ok (new Date::Handler::Delta('delta' => '8:7:6:5:4:3:2:') * 2.6, '+17:2:13:3:8:6:4'); |
962
|
|
|
|
|
|
|
# |
963
|
|
|
|
|
|
|
##Part 8: tests that should fail: |
964
|
|
|
|
|
|
|
# #118 This invalid date is created and incorrectly parsed. |
965
|
|
|
|
|
|
|
# #ok (new Date::Handler('moment' => 'Feb 29 12:16:44 EST 2001'), (undef)); |
966
|
|
|
|
|
|
|
# #119 This invalid object is created. |
967
|
|
|
|
|
|
|
# #ok (new Date::Handler('moment' => 'dcftyg uhijok tfyvybgunhjimftvy km'), (undef)); |
968
|
|
|
|
|
|
|
# |
969
|
|
|
|
|
|
|
# #my $d = new Date::Handler('moment' => 'Feb 29 12:16:44 EST 2001'); |
970
|
|
|
|
|
|
|
# #my $e = new Date::Handler('moment' => 'Jan 44 12:16:44 EST 2001'); |
971
|
|
|
|
|
|
|
# #print STDERR Dumper $d, $e; |
972
|
|
|
|
|
|
|
# |
973
|
|
|
|
|
|
|
# #120 Testing adding dates |
974
|
|
|
|
|
|
|
# #ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') + new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001'), '40020204121644'); |
975
|
|
|
|
|
|
|
# |
976
|
|
|
|
|
|
|
# #Testing date formats that go over the logical bounds of time periods |
977
|
|
|
|
|
|
|
# #121 What 84 seconds minus 40 seconds? |
978
|
|
|
|
|
|
|
# #ok (new Date::Handler('moment' => 'Jan 2 12:16:84 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:0:0:0:0:40'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')); |
979
|
|
|
|
|
|
|
# |
980
|
|
|
|
|
|
|
# |
981
|
|
|
|
|
|
|
# |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
#} # END OF TEST CASES |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
# |
987
|
|
|
|
|
|
|
# } |
988
|
|
|
|
|
|
|
#} |
989
|
|
|
|
|
|
|
# |
990
|
|
|
|
|
|
|
#sub leap_years { |
991
|
|
|
|
|
|
|
# plan tests => 4; |
992
|
|
|
|
|
|
|
##Part 6: Leap year (the year is a leap year) |
993
|
|
|
|
|
|
|
# #1 |
994
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+1:0:0:0:0:0:0'), new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2000')); |
995
|
|
|
|
|
|
|
# #2 |
996
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Mar 2 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:1:0:0:0:0:0'), new Date::Handler('moment' => 'Feb 2 12:16:44 EST 2001')); |
997
|
|
|
|
|
|
|
# #3 |
998
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Mar 1 12:16:44 EST 2001') - new Date::Handler::Delta('delta' => '+0:0:0:1:0:0:0'), new Date::Handler('moment' => 'Feb 28 12:16:44 EST 2001')); |
999
|
|
|
|
|
|
|
# #4 |
1000
|
|
|
|
|
|
|
# ok (new Date::Handler('moment' => 'Mar 1 12:16:44 EST 2000') - new Date::Handler::Delta('delta' => '+0:0:0:1:0:0:0'), new Date::Handler('moment' => 'Feb 29 12:16:44 EST 2000')); |
1001
|
|
|
|
|
|
|
# |
1002
|
|
|
|
|
|
|
# |
1003
|
|
|
|
|
|
|
# #$diff = eval { new Date::Handler('moment' => 'Feb 28 12:16:44 EST 2001') - new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')}; |
1004
|
|
|
|
|
|
|
# #$diff = eval {new Date::Handler('moment' => 'Jan 2 12:16:44 EST 2001')}; |
1005
|
|
|
|
|
|
|
# #print STDERR Dumper $diff; |
1006
|
|
|
|
|
|
|
# |
1007
|
|
|
|
|
|
|
#} |
1008
|
|
|
|
|
|
|
# |
1009
|
|
|
|
|
|
|
## Preloaded methods go here. |
1010
|
|
|
|
|
|
|
# |
1011
|
|
|
|
|
|
|
## Autoload methods go after =cut, and are processed by the autosplit program. |
1012
|
|
|
|
|
|
|
# |
1013
|
|
|
|
|
|
|
#1; |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
sub deltas |
1017
|
|
|
|
|
|
|
{ |
1018
|
1
|
|
|
1
|
0
|
9
|
plan tests => 25; |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
#1 |
1021
|
1
|
|
|
|
|
3130
|
my $date = Date::Handler->new({ date => [2001,11,25,00,00] }); |
1022
|
1
|
|
|
|
|
14
|
my $delta = Date::Handler::Delta->new([00,00,07,00,00,00]); |
1023
|
1
|
|
|
|
|
7
|
my $cdate = Date::Handler->new({ date => [2001,12,02,00,00]}); |
1024
|
1
|
|
|
|
|
7
|
ok($date + $delta, Date::Handler->new({ date => [2001,12,02,00,00]})); |
1025
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
#2 - 13 |
1027
|
1
|
|
|
|
|
44
|
$delta = Date::Handler::Delta->new([00,01,00,00,00,00]); |
1028
|
1
|
|
|
|
|
10
|
for(1..12) |
1029
|
|
|
|
|
|
|
{ |
1030
|
12
|
|
|
|
|
456
|
my $date = Date::Handler->new({ date => [2001,$_,01,00,00] }); |
1031
|
|
|
|
|
|
|
|
1032
|
12
|
|
|
|
|
63
|
my $cdate = Date::Handler->new({ date => [2001,$_+1, 01,00,00] }); |
1033
|
|
|
|
|
|
|
|
1034
|
12
|
|
|
|
|
46
|
ok($date + $delta, $cdate); |
1035
|
|
|
|
|
|
|
} |
1036
|
|
|
|
|
|
|
|
1037
|
1
|
|
|
|
|
20
|
my $count = 13; |
1038
|
1
|
|
|
|
|
3
|
for (1..12) |
1039
|
|
|
|
|
|
|
{ |
1040
|
12
|
|
|
|
|
4216
|
$count = $count - $_; |
1041
|
|
|
|
|
|
|
|
1042
|
12
|
|
|
|
|
78
|
my $date = Date::Handler->new({ date => [2005,$count,01,00,00] }); |
1043
|
12
|
|
|
|
|
70
|
my $cdate = Date::Handler->new({ date => [2005,$count-1, 01,00,00] }); |
1044
|
12
|
|
|
|
|
52
|
ok($date - $delta, $cdate); |
1045
|
|
|
|
|
|
|
} |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
} |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
sub ranges |
1052
|
|
|
|
|
|
|
{ |
1053
|
1
|
|
|
1
|
0
|
9
|
plan tests => 4; |
1054
|
|
|
|
|
|
|
|
1055
|
1
|
|
|
|
|
3802
|
my $date = Date::Handler->new({ date => [2001,01,05,1,0,0], time_zone => 'America/Montreal' }); |
1056
|
1
|
|
|
|
|
12
|
my $delta = Date::Handler::Delta->new([0,0,2,0,0,0]); |
1057
|
|
|
|
|
|
|
|
1058
|
1
|
|
|
|
|
11
|
my $range = Date::Handler::Range->new({ date => $date, delta => $delta, }); |
1059
|
|
|
|
|
|
|
|
1060
|
1
|
|
|
|
|
5
|
ok($range->EndDate(),$date + $delta); |
1061
|
1
|
|
|
|
|
318
|
ok($range->StartDate(), $date); |
1062
|
|
|
|
|
|
|
|
1063
|
1
|
|
|
|
|
183
|
$range->Direction('BACKWARDS'); |
1064
|
|
|
|
|
|
|
|
1065
|
1
|
|
|
|
|
3
|
ok($range->StartDate(),$date - $delta); |
1066
|
1
|
|
|
|
|
182
|
ok($range->EndDate(), $date); |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
} |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
sub locale |
1072
|
|
|
|
|
|
|
{ |
1073
|
0
|
|
|
0
|
0
|
0
|
plan tests => 2; |
1074
|
|
|
|
|
|
|
|
1075
|
0
|
|
|
|
|
0
|
my $date = Date::Handler->new({ date => [2001,8,29,1,0,0], time_zone => 'America/Montreal' }); |
1076
|
|
|
|
|
|
|
|
1077
|
0
|
|
|
|
|
0
|
my $day_english = $date->WeekDayName(); |
1078
|
|
|
|
|
|
|
|
1079
|
0
|
|
|
|
|
0
|
$date->SetLocale('french'); |
1080
|
|
|
|
|
|
|
|
1081
|
0
|
|
|
|
|
0
|
my $day_french = $date->WeekDayName(); |
1082
|
0
|
|
|
|
|
0
|
ok(lc $day_french, lc "Mercredi"); |
1083
|
|
|
|
|
|
|
|
1084
|
0
|
|
|
|
|
0
|
$date->SetLocale('spanish'); |
1085
|
|
|
|
|
|
|
|
1086
|
0
|
|
|
|
|
0
|
my $day_spanish = $date->WeekDayName(); |
1087
|
|
|
|
|
|
|
|
1088
|
0
|
|
|
|
|
0
|
ok(lc $day_spanish, lc "miércoles"); |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
} |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
sub IntuitiveMonths |
1093
|
|
|
|
|
|
|
{ |
1094
|
1
|
|
|
1
|
0
|
11
|
plan tests => 8; |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
|
1097
|
1
|
|
|
|
|
3970
|
my $date = Date::Handler::Tester->new({ date => [2002,01,30,5,0,0], time_zone => 'America/Montreal', }) |
1098
|
|
|
|
|
|
|
; |
1099
|
1
|
|
|
|
|
14
|
my $onemonth = Date::Handler::Delta->new([0,1,0,0,0,0]); |
1100
|
1
|
|
|
|
|
7
|
my $oneweek = Date::Handler::Delta->new([0,0,7,0,0,0]); |
1101
|
|
|
|
|
|
|
|
1102
|
1
|
|
|
|
|
7
|
my $twomonths = Date::Handler::Delta->new([0,2,0,0,0,0]); |
1103
|
|
|
|
|
|
|
|
1104
|
1
|
|
|
|
|
10
|
my $cdate1 = Date::Handler::Tester->new({ |
1105
|
|
|
|
|
|
|
date => [2002,02,28,5,0,0], |
1106
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1107
|
|
|
|
|
|
|
}); |
1108
|
|
|
|
|
|
|
|
1109
|
1
|
|
|
|
|
9
|
my $cdate2 = Date::Handler::Tester->new({ |
1110
|
|
|
|
|
|
|
date => [2002,03,30,5,0,0], |
1111
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1112
|
|
|
|
|
|
|
}); |
1113
|
|
|
|
|
|
|
|
1114
|
1
|
|
|
|
|
9
|
my $cdate3 = Date::Handler::Tester->new({ |
1115
|
|
|
|
|
|
|
date => [2002,03,31, 5,0,0], |
1116
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1117
|
|
|
|
|
|
|
}); |
1118
|
|
|
|
|
|
|
|
1119
|
1
|
|
|
|
|
10
|
my $cdate4 = Date::Handler::Tester->new({ |
1120
|
|
|
|
|
|
|
date => [2002,03,30, 5,0,0], |
1121
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1122
|
|
|
|
|
|
|
}); |
1123
|
|
|
|
|
|
|
|
1124
|
1
|
|
|
|
|
8
|
ok( ($date + $onemonth), $cdate1); |
1125
|
|
|
|
|
|
|
|
1126
|
1
|
|
|
|
|
320
|
ok( ($date + $onemonth) + $onemonth, $cdate2); |
1127
|
|
|
|
|
|
|
|
1128
|
1
|
|
|
|
|
199
|
ok( ($date + (2 * $onemonth)), $cdate2); |
1129
|
|
|
|
|
|
|
|
1130
|
1
|
|
|
|
|
182
|
ok( ($date + ($twomonths)), $cdate2); |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
|
1133
|
1
|
|
|
|
|
190
|
my $date2 = Date::Handler::Tester->new({ date => [2001,12,31,5,0,0], time_zone => 'America/Montreal',}) |
1134
|
|
|
|
|
|
|
; |
1135
|
|
|
|
|
|
|
|
1136
|
1
|
|
|
|
|
6
|
ok( ($date2 + $onemonth + $onemonth + $onemonth), $cdate3); |
1137
|
|
|
|
|
|
|
|
1138
|
1
|
|
|
|
|
185
|
my $date3 = Date::Handler::Tester->new({ date => [2002,02,28,5,0,0], time_zone => 'America/Montreal', |
1139
|
|
|
|
|
|
|
intuitive_day => 30, }); |
1140
|
|
|
|
|
|
|
|
1141
|
1
|
|
|
|
|
6
|
ok( ($date3 + $onemonth), $cdate4); |
1142
|
|
|
|
|
|
|
|
1143
|
1
|
|
|
|
|
180
|
my $date4 = Date::Handler::Tester->new({ date => [2000,1,1,6,0,0], time_zone => 'America/Montreal'}); |
1144
|
|
|
|
|
|
|
|
1145
|
1
|
|
|
|
|
6
|
for(1..24) |
1146
|
|
|
|
|
|
|
{ |
1147
|
24
|
|
|
|
|
67
|
$date4 += $onemonth; |
1148
|
|
|
|
|
|
|
} |
1149
|
1
|
|
|
|
|
12
|
ok($date4, Date::Handler->new({ date => [2002,1,1,6,0,0], time_zone => 'America/Montreal'})); |
1150
|
|
|
|
|
|
|
|
1151
|
1
|
|
|
|
|
282
|
for(1..8) |
1152
|
|
|
|
|
|
|
{ |
1153
|
8
|
|
|
|
|
25
|
$date4 += $oneweek; |
1154
|
|
|
|
|
|
|
} |
1155
|
1
|
|
|
|
|
9
|
ok($date4, Date::Handler->new({date =>[2002,2,26,6,0,0], time_zone => 'America/Montreal'})); |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
} |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
sub StandardMonths |
1160
|
|
|
|
|
|
|
{ |
1161
|
1
|
|
|
1
|
0
|
12
|
plan tests => 5; |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
|
1164
|
1
|
|
|
|
|
3395
|
my $date = Date::Handler->new({ date => [2002,01,30,5,0,0], time_zone => 'America/Montreal', }) |
1165
|
|
|
|
|
|
|
; |
1166
|
1
|
|
|
|
|
12
|
my $onemonth = Date::Handler::Delta->new([0,1,0,0,0,0]); |
1167
|
1
|
|
|
|
|
5
|
my $twomonths = Date::Handler::Delta->new([0,2,0,0,0,0]); |
1168
|
|
|
|
|
|
|
|
1169
|
1
|
|
|
|
|
7
|
my $cdate1 = Date::Handler->new({ |
1170
|
|
|
|
|
|
|
date => [2002,03,02,5,0,0], |
1171
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1172
|
|
|
|
|
|
|
}); |
1173
|
|
|
|
|
|
|
|
1174
|
1
|
|
|
|
|
10
|
my $cdate2 = Date::Handler->new({ |
1175
|
|
|
|
|
|
|
date => [2002,04,03,5,0,0], |
1176
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1177
|
|
|
|
|
|
|
}); |
1178
|
|
|
|
|
|
|
|
1179
|
1
|
|
|
|
|
9
|
my $cdate3 = Date::Handler->new({ |
1180
|
|
|
|
|
|
|
date => [2002,04,02, 5,0,0], |
1181
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1182
|
|
|
|
|
|
|
}); |
1183
|
|
|
|
|
|
|
|
1184
|
1
|
|
|
|
|
9
|
my $cdate4 = Date::Handler->new({ |
1185
|
|
|
|
|
|
|
date => [2002,03,30, 5,0,0], |
1186
|
|
|
|
|
|
|
time_zone => 'America/Montreal', |
1187
|
|
|
|
|
|
|
}); |
1188
|
|
|
|
|
|
|
|
1189
|
1
|
|
|
|
|
6
|
ok( ($date + $onemonth), $cdate1); |
1190
|
|
|
|
|
|
|
|
1191
|
1
|
|
|
|
|
347
|
ok( ($date + $onemonth) + $onemonth, $cdate3); |
1192
|
|
|
|
|
|
|
|
1193
|
1
|
|
|
|
|
259
|
ok( ($date + (2 * $onemonth)), $cdate4); |
1194
|
|
|
|
|
|
|
|
1195
|
1
|
|
|
|
|
188
|
ok( ($date + ($twomonths)), $cdate4); |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
|
1198
|
1
|
|
|
|
|
193
|
my $date2 = Date::Handler->new({ date => [2001,12,31,5,0,0], time_zone => 'America/Montreal',}) |
1199
|
|
|
|
|
|
|
; |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
|
1202
|
1
|
|
|
|
|
6
|
ok( ($date2 + $onemonth + $onemonth + $onemonth), $cdate2); |
1203
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
} |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
sub IntuitiveDSTTime |
1208
|
|
|
|
|
|
|
{ |
1209
|
1
|
|
|
1
|
0
|
13
|
plan tests => 7; |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
|
1212
|
1
|
|
|
|
|
4149
|
my $date = Date::Handler::Tester->new({ date => [2002,04,06,1,0,0], time_zone => 'America/Montreal', }); |
1213
|
|
|
|
|
|
|
|
1214
|
1
|
|
|
|
|
16
|
my $oneday = Date::Handler::Delta->new([0,0,1,0,0,0]); |
1215
|
|
|
|
|
|
|
|
1216
|
1
|
|
|
|
|
9
|
my $date1 = Date::Handler::Tester->new({ date => [2002,4,07,1,0,0], time_zone => 'America/Montreal', }); |
1217
|
|
|
|
|
|
|
|
1218
|
1
|
|
|
|
|
9
|
my $date2 = Date::Handler::Tester->new({ date => [2002,4,06,2,0,0], time_zone => 'America/Montreal', }); |
1219
|
|
|
|
|
|
|
|
1220
|
1
|
|
|
|
|
9
|
my $date3 = Date::Handler::Tester->new({ date => [2002,4,07,3,0,0], time_zone => 'America/Montreal', }); |
1221
|
|
|
|
|
|
|
|
1222
|
1
|
|
|
|
|
10
|
my $date4 = Date::Handler::Tester->new({ date => [2002,4,8,2,0,0], time_zone => 'America/Montreal', }); |
1223
|
|
|
|
|
|
|
|
1224
|
1
|
|
|
|
|
8
|
ok($date + $oneday, $date1); |
1225
|
|
|
|
|
|
|
|
1226
|
1
|
|
|
|
|
312
|
ok($date2 + $oneday, $date3); |
1227
|
|
|
|
|
|
|
|
1228
|
1
|
|
|
|
|
184
|
ok($date2 + $oneday + $oneday, $date4); |
1229
|
|
|
|
|
|
|
|
1230
|
1
|
|
|
|
|
177
|
my $date5 = Date::Handler::Tester->new({ date => [2002,10,26,1,0,0], time_zone => 'America/Montreal',}); |
1231
|
1
|
|
|
|
|
11
|
my $date6 = Date::Handler::Tester->new({ date => [2002,10,27,1,0,0], time_zone => 'America/Montreal', }); |
1232
|
1
|
|
|
|
|
18
|
my $date7 = Date::Handler::Tester->new({ date => [2002,10,28,1,0,0], time_zone => 'America/Montreal', }); |
1233
|
1
|
|
|
|
|
9
|
my $date8 = Date::Handler::Tester->new({ date => [2002,10,26,0,0,0], time_zone => 'America/Montreal', }); |
1234
|
1
|
|
|
|
|
10
|
my $date9 = Date::Handler::Tester->new({ date => [2002,10,27,0,0,0], time_zone => 'America/Montreal', }); |
1235
|
1
|
|
|
|
|
10
|
my $date10 = Date::Handler::Tester->new({ date => [2002,10,28,0,0,0], time_zone => 'America/Montreal', }); |
1236
|
|
|
|
|
|
|
|
1237
|
1
|
|
|
|
|
5
|
ok($date5 + $oneday, $date6); |
1238
|
|
|
|
|
|
|
|
1239
|
1
|
|
|
|
|
196
|
ok($date5 + $oneday + $oneday, $date7); |
1240
|
|
|
|
|
|
|
|
1241
|
1
|
|
|
|
|
197
|
ok($date8 + $oneday, $date9); |
1242
|
|
|
|
|
|
|
|
1243
|
1
|
|
|
|
|
166
|
ok($date8 + $oneday + $oneday, $date10); |
1244
|
|
|
|
|
|
|
} |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
sub SkipTest |
1247
|
|
|
|
|
|
|
{ |
1248
|
1
|
|
|
1
|
0
|
579
|
print "1..0\n"; |
1249
|
1
|
|
|
|
|
122
|
exit; |
1250
|
|
|
|
|
|
|
} |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
sub LoadTestConfig |
1253
|
|
|
|
|
|
|
{ |
1254
|
6
|
|
|
6
|
0
|
51
|
my $config_str; |
1255
|
|
|
|
|
|
|
|
1256
|
6
|
50
|
|
|
|
393
|
open(CONFIG, "t/config") || die "Cannot open t/config: $!"; |
1257
|
6
|
|
|
|
|
151
|
while() { $config_str .= $_; } |
|
6
|
|
|
|
|
71
|
|
1258
|
6
|
|
|
|
|
10826
|
close CONFIG; |
1259
|
|
|
|
|
|
|
|
1260
|
6
|
|
|
|
|
463
|
my $test_config = eval $config_str; |
1261
|
|
|
|
|
|
|
|
1262
|
6
|
|
|
|
|
44
|
return $test_config; |
1263
|
|
|
|
|
|
|
} |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
1; |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
package Date::Handler::Tester; |
1268
|
|
|
|
|
|
|
|
1269
|
7
|
|
|
7
|
|
103
|
use strict; |
|
7
|
|
|
|
|
28
|
|
|
7
|
|
|
|
|
363
|
|
1270
|
7
|
|
|
7
|
|
44
|
use base qw(Date::Handler); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1183
|
|
1271
|
|
|
|
|
|
|
|
1272
|
7
|
|
|
7
|
|
52
|
use constant INTUITIVE_MONTH_CALCULATIONS => 1; |
|
7
|
|
|
|
|
45
|
|
|
7
|
|
|
|
|
650
|
|
1273
|
7
|
|
|
7
|
|
42
|
use constant INTUITIVE_TIME_CALCULATIONS => 1; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
319
|
|
1274
|
7
|
|
|
7
|
|
34
|
use constant INTUITIVE_DST_ADJUSTMENTS => 1; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
390
|
|
1275
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
1; |
1277
|
|
|
|
|
|
|
|
1278
|
|
|
|
|
|
|
__END__ |