Filename | /usr/lib/perl5/Date/Calc.pm |
Statements | Executed 17 statements in 1.42ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 193µs | 193µs | bootstrap (xsub) | Date::Calc::
1 | 1 | 1 | 22µs | 22µs | BEGIN@14 | Date::Calc::
1 | 1 | 1 | 11µs | 16µs | BEGIN@15 | Date::Calc::
1 | 1 | 1 | 9µs | 95µs | BEGIN@16 | Date::Calc::
0 | 0 | 0 | 0s | 0s | Decode_Date_EU2 | Date::Calc::
0 | 0 | 0 | 0s | 0s | Decode_Date_US2 | Date::Calc::
0 | 0 | 0 | 0s | 0s | Parse_Date | Date::Calc::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | ############################################################################### | ||||
3 | ## ## | ||||
4 | ## Copyright (c) 1995 - 2009 by Steffen Beyer. ## | ||||
5 | ## All rights reserved. ## | ||||
6 | ## ## | ||||
7 | ## This package is free software; you can redistribute it ## | ||||
8 | ## and/or modify it under the same terms as Perl itself. ## | ||||
9 | ## ## | ||||
10 | ############################################################################### | ||||
11 | |||||
12 | package Date::Calc; | ||||
13 | |||||
14 | 2 | 37µs | 1 | 22µs | # spent 22µs within Date::Calc::BEGIN@14 which was called:
# once (22µs+0s) by C4::Dates::BEGIN@29 at line 14 # spent 22µs making 1 call to Date::Calc::BEGIN@14 |
15 | 3 | 36µs | 2 | 22µs | # spent 16µs (11+5) within Date::Calc::BEGIN@15 which was called:
# once (11µs+5µs) by C4::Dates::BEGIN@29 at line 15 # spent 16µs making 1 call to Date::Calc::BEGIN@15
# spent 5µs making 1 call to strict::import |
16 | 3 | 1.27ms | 2 | 181µs | # spent 95µs (9+86) within Date::Calc::BEGIN@16 which was called:
# once (9µs+86µs) by C4::Dates::BEGIN@29 at line 16 # spent 95µs making 1 call to Date::Calc::BEGIN@16
# spent 86µs making 1 call to vars::import |
17 | |||||
18 | 1 | 900ns | require Exporter; | ||
19 | 1 | 800ns | require DynaLoader; | ||
20 | |||||
21 | 1 | 17µs | @ISA = qw(Exporter DynaLoader); | ||
22 | |||||
23 | 1 | 400ns | @EXPORT = qw(); | ||
24 | |||||
25 | 1 | 16µs | @EXPORT_OK = qw( | ||
26 | Days_in_Year | ||||
27 | Days_in_Month | ||||
28 | Weeks_in_Year | ||||
29 | leap_year | ||||
30 | check_date | ||||
31 | check_time | ||||
32 | check_business_date | ||||
33 | Day_of_Year | ||||
34 | Date_to_Days | ||||
35 | Day_of_Week | ||||
36 | Week_Number | ||||
37 | Week_of_Year | ||||
38 | Monday_of_Week | ||||
39 | Nth_Weekday_of_Month_Year | ||||
40 | Standard_to_Business | ||||
41 | Business_to_Standard | ||||
42 | Delta_Days | ||||
43 | Delta_DHMS | ||||
44 | Delta_YMD | ||||
45 | Delta_YMDHMS | ||||
46 | N_Delta_YMD | ||||
47 | N_Delta_YMDHMS | ||||
48 | Normalize_DHMS | ||||
49 | Add_Delta_Days | ||||
50 | Add_Delta_DHMS | ||||
51 | Add_Delta_YM | ||||
52 | Add_Delta_YMD | ||||
53 | Add_Delta_YMDHMS | ||||
54 | Add_N_Delta_YMD | ||||
55 | Add_N_Delta_YMDHMS | ||||
56 | System_Clock | ||||
57 | Today | ||||
58 | Now | ||||
59 | Today_and_Now | ||||
60 | This_Year | ||||
61 | Gmtime | ||||
62 | Localtime | ||||
63 | Mktime | ||||
64 | Timezone | ||||
65 | Date_to_Time | ||||
66 | Time_to_Date | ||||
67 | Easter_Sunday | ||||
68 | Decode_Month | ||||
69 | Decode_Day_of_Week | ||||
70 | Decode_Language | ||||
71 | Decode_Date_EU | ||||
72 | Decode_Date_US | ||||
73 | Fixed_Window | ||||
74 | Moving_Window | ||||
75 | Compress | ||||
76 | Uncompress | ||||
77 | check_compressed | ||||
78 | Compressed_to_Text | ||||
79 | Date_to_Text | ||||
80 | Date_to_Text_Long | ||||
81 | English_Ordinal | ||||
82 | Calendar | ||||
83 | Month_to_Text | ||||
84 | Day_of_Week_to_Text | ||||
85 | Day_of_Week_Abbreviation | ||||
86 | Language_to_Text | ||||
87 | Language | ||||
88 | Languages | ||||
89 | Decode_Date_EU2 | ||||
90 | Decode_Date_US2 | ||||
91 | Parse_Date | ||||
92 | ISO_LC | ||||
93 | ISO_UC | ||||
94 | ); | ||||
95 | |||||
96 | 1 | 13µs | %EXPORT_TAGS = (all => [@EXPORT_OK]); | ||
97 | |||||
98 | ################################################## | ||||
99 | ## ## | ||||
100 | ## "Version()" is available but not exported ## | ||||
101 | ## in order to avoid possible name clashes. ## | ||||
102 | ## Call with "Date::Calc::Version()" instead! ## | ||||
103 | ## ## | ||||
104 | ################################################## | ||||
105 | |||||
106 | 1 | 500ns | $VERSION = '6.0'; | ||
107 | |||||
108 | 1 | 9µs | 1 | 531µs | bootstrap Date::Calc $VERSION; # spent 531µs making 1 call to DynaLoader::bootstrap |
109 | |||||
110 | sub Decode_Date_EU2 | ||||
111 | { | ||||
112 | die "Usage: (\$year,\$month,\$day) = Decode_Date_EU2(\$date[,\$lang]);\n" | ||||
113 | unless ((@_ == 1) or (@_ == 2)); | ||||
114 | |||||
115 | my($buffer) = shift; | ||||
116 | my($lang) = shift || 0; | ||||
117 | my($year,$month,$day,$length); | ||||
118 | |||||
119 | $lang = Language() unless (($lang >= 1) and ($lang <= Languages())); | ||||
120 | if ($buffer =~ /^\D* (\d+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D*$/x) | ||||
121 | { | ||||
122 | ($day,$month,$year) = ($1,$2,$3); | ||||
123 | $month = Decode_Month($month,$lang); | ||||
124 | unless ($month > 0) | ||||
125 | { | ||||
126 | return(); # can't decode month! | ||||
127 | } | ||||
128 | } | ||||
129 | elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x) | ||||
130 | { | ||||
131 | $buffer = $1; | ||||
132 | $length = length($buffer); | ||||
133 | if ($length == 3) | ||||
134 | { | ||||
135 | $day = substr($buffer,0,1); | ||||
136 | $month = substr($buffer,1,1); | ||||
137 | $year = substr($buffer,2,1); | ||||
138 | } | ||||
139 | elsif ($length == 4) | ||||
140 | { | ||||
141 | $day = substr($buffer,0,1); | ||||
142 | $month = substr($buffer,1,1); | ||||
143 | $year = substr($buffer,2,2); | ||||
144 | } | ||||
145 | elsif ($length == 5) | ||||
146 | { | ||||
147 | $day = substr($buffer,0,1); | ||||
148 | $month = substr($buffer,1,2); | ||||
149 | $year = substr($buffer,3,2); | ||||
150 | } | ||||
151 | elsif ($length == 6) | ||||
152 | { | ||||
153 | $day = substr($buffer,0,2); | ||||
154 | $month = substr($buffer,2,2); | ||||
155 | $year = substr($buffer,4,2); | ||||
156 | } | ||||
157 | elsif ($length == 7) | ||||
158 | { | ||||
159 | $day = substr($buffer,0,1); | ||||
160 | $month = substr($buffer,1,2); | ||||
161 | $year = substr($buffer,3,4); | ||||
162 | } | ||||
163 | elsif ($length == 8) | ||||
164 | { | ||||
165 | $day = substr($buffer,0,2); | ||||
166 | $month = substr($buffer,2,2); | ||||
167 | $year = substr($buffer,4,4); | ||||
168 | } | ||||
169 | else { return(); } # wrong number of digits! | ||||
170 | } | ||||
171 | elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x) | ||||
172 | { | ||||
173 | ($day,$month,$year) = ($1,$2,$3); | ||||
174 | } | ||||
175 | else { return(); } # no match at all! | ||||
176 | $year = Moving_Window($year); | ||||
177 | if (check_date($year,$month,$day)) | ||||
178 | { | ||||
179 | return($year,$month,$day); | ||||
180 | } | ||||
181 | else { return(); } # not a valid date! | ||||
182 | } | ||||
183 | |||||
184 | sub Decode_Date_US2 | ||||
185 | { | ||||
186 | die "Usage: (\$year,\$month,\$day) = Decode_Date_US2(\$date[,\$lang]);\n" | ||||
187 | unless ((@_ == 1) or (@_ == 2)); | ||||
188 | |||||
189 | my($buffer) = shift; | ||||
190 | my($lang) = shift || 0; | ||||
191 | my($year,$month,$day,$length); | ||||
192 | |||||
193 | $lang = Language() unless (($lang >= 1) and ($lang <= Languages())); | ||||
194 | if ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* 0*(\d+) \D*$/x) | ||||
195 | { | ||||
196 | ($month,$buffer) = ($1,$2); | ||||
197 | $month = Decode_Month($month,$lang); | ||||
198 | unless ($month > 0) | ||||
199 | { | ||||
200 | return(); # can't decode month! | ||||
201 | } | ||||
202 | $length = length($buffer); | ||||
203 | if ($length == 2) | ||||
204 | { | ||||
205 | $day = substr($buffer,0,1); | ||||
206 | $year = substr($buffer,1,1); | ||||
207 | } | ||||
208 | elsif ($length == 3) | ||||
209 | { | ||||
210 | $day = substr($buffer,0,1); | ||||
211 | $year = substr($buffer,1,2); | ||||
212 | } | ||||
213 | elsif ($length == 4) | ||||
214 | { | ||||
215 | $day = substr($buffer,0,2); | ||||
216 | $year = substr($buffer,2,2); | ||||
217 | } | ||||
218 | elsif ($length == 5) | ||||
219 | { | ||||
220 | $day = substr($buffer,0,1); | ||||
221 | $year = substr($buffer,1,4); | ||||
222 | } | ||||
223 | elsif ($length == 6) | ||||
224 | { | ||||
225 | $day = substr($buffer,0,2); | ||||
226 | $year = substr($buffer,2,4); | ||||
227 | } | ||||
228 | else { return(); } # wrong number of digits! | ||||
229 | } | ||||
230 | elsif ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D+ (\d+) \D*$/x) | ||||
231 | { | ||||
232 | ($month,$day,$year) = ($1,$2,$3); | ||||
233 | $month = Decode_Month($month,$lang); | ||||
234 | unless ($month > 0) | ||||
235 | { | ||||
236 | return(); # can't decode month! | ||||
237 | } | ||||
238 | } | ||||
239 | elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x) | ||||
240 | { | ||||
241 | $buffer = $1; | ||||
242 | $length = length($buffer); | ||||
243 | if ($length == 3) | ||||
244 | { | ||||
245 | $month = substr($buffer,0,1); | ||||
246 | $day = substr($buffer,1,1); | ||||
247 | $year = substr($buffer,2,1); | ||||
248 | } | ||||
249 | elsif ($length == 4) | ||||
250 | { | ||||
251 | $month = substr($buffer,0,1); | ||||
252 | $day = substr($buffer,1,1); | ||||
253 | $year = substr($buffer,2,2); | ||||
254 | } | ||||
255 | elsif ($length == 5) | ||||
256 | { | ||||
257 | $month = substr($buffer,0,1); | ||||
258 | $day = substr($buffer,1,2); | ||||
259 | $year = substr($buffer,3,2); | ||||
260 | } | ||||
261 | elsif ($length == 6) | ||||
262 | { | ||||
263 | $month = substr($buffer,0,2); | ||||
264 | $day = substr($buffer,2,2); | ||||
265 | $year = substr($buffer,4,2); | ||||
266 | } | ||||
267 | elsif ($length == 7) | ||||
268 | { | ||||
269 | $month = substr($buffer,0,1); | ||||
270 | $day = substr($buffer,1,2); | ||||
271 | $year = substr($buffer,3,4); | ||||
272 | } | ||||
273 | elsif ($length == 8) | ||||
274 | { | ||||
275 | $month = substr($buffer,0,2); | ||||
276 | $day = substr($buffer,2,2); | ||||
277 | $year = substr($buffer,4,4); | ||||
278 | } | ||||
279 | else { return(); } # wrong number of digits! | ||||
280 | } | ||||
281 | elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x) | ||||
282 | { | ||||
283 | ($month,$day,$year) = ($1,$2,$3); | ||||
284 | } | ||||
285 | else { return(); } # no match at all! | ||||
286 | $year = Moving_Window($year); | ||||
287 | if (check_date($year,$month,$day)) | ||||
288 | { | ||||
289 | return($year,$month,$day); | ||||
290 | } | ||||
291 | else { return(); } # not a valid date! | ||||
292 | } | ||||
293 | |||||
294 | sub Parse_Date | ||||
295 | { | ||||
296 | die "Usage: (\$year,\$month,\$day) = Parse_Date(\$date[,\$lang]);\n" | ||||
297 | unless ((@_ == 1) or (@_ == 2)); | ||||
298 | |||||
299 | my($date) = shift; | ||||
300 | my($lang) = shift || 0; | ||||
301 | my($year,$month,$day); | ||||
302 | |||||
303 | $lang = Language() unless (($lang >= 1) and ($lang <= Languages())); | ||||
304 | unless ($date =~ /\b([\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF]{3})\s+([0123]??\d)\b/) | ||||
305 | { | ||||
306 | return(); | ||||
307 | } | ||||
308 | $month = $1; | ||||
309 | $day = $2; | ||||
310 | unless ($date =~ /\b(19\d\d|20\d\d)\b/) | ||||
311 | { | ||||
312 | return(); | ||||
313 | } | ||||
314 | $year = $1; | ||||
315 | $month = Decode_Month($month,$lang); | ||||
316 | unless ($month > 0) | ||||
317 | { | ||||
318 | return(); | ||||
319 | } | ||||
320 | unless (check_date($year,$month,$day)) | ||||
321 | { | ||||
322 | return(); | ||||
323 | } | ||||
324 | return($year,$month,$day); | ||||
325 | } | ||||
326 | |||||
327 | 1 | 14µs | 1; | ||
328 | |||||
329 | __END__ | ||||
# spent 193µs within Date::Calc::bootstrap which was called:
# once (193µs+0s) by DynaLoader::bootstrap at line 215 of DynaLoader.pm |