1Date(3) User Contributed Perl Documentation Date(3)
2
3
4
6 Class::Date - Class for easy date and time manipulation
7
9 use Class::Date qw(:errors date localdate gmdate now -DateParse -EnvC);
10
11 # creating absolute date object (local time)
12 $date = new Class::Date [$year,$month,$day,$hour,$min,$sec];
13 $date = date [$year,$month,$day,$hour,$min,$sec];
14 # ^- "date" is an exportable function, the same as Class::Date->new
15 $date = date { year => $year, month => $month, day => $day,
16 hour => $hour, min => $min, sec => $sec };
17 $date = date "2001-11-12 07:13:12";
18 $date = localdate "2001-12-11";
19 $date = now; # the same as date(time)
20 $date = date($other_date_object); # cloning
21 ...
22
23 # creating absolute date object (GMT)
24 $date = new Class::Date [$year,$month,$day,$hour,$min,$sec],'GMT';
25 $date = gmdate "2001-11-12 17:13";
26 ...
27
28 # creating absolute date object in any other timezone
29 $date = new Class::Date [$year,$month,$day,$hour,$min,$sec],'Iceland';
30 $date = date "2001-11-12 17:13", 'Iceland';
31 $date2 = $date->new([$y2, $m2, $d2, $h2, $m2, $s2]);
32 # ^- timezone is inherited from the $date object
33
34 # creating relative date object
35 # (normally you don't need to create this object explicitly)
36 $reldate = new Class::Date::Rel "3Y 1M 3D 6h 2m 4s";
37 $reldate = new Class::Date::Rel "6Y";
38 $reldate = new Class::Date::Rel $secs; # secs
39 $reldate = new Class::Date::Rel [$year,$month,$day,$hour,$min,$sec];
40 $reldate = new Class::Date::Rel { year => $year, month => $month, day => $day,
41 hour => $hour, min => $min, sec => $sec };
42 $reldate = new Class::Date::Rel "2001-11-12 07:13:12";
43 $reldate = new Class::Date::Rel "2001-12-11";
44
45 # getting values of an absolute date object
46 $date; # prints the date in default output format (see below)
47 $date->year; # year, e.g: 2001
48 $date->_year; # year - 1900, e.g. 101
49 $date->yr; # 2-digit year 0-99, e.g 1
50 $date->mon; # month 1..12
51 $date->month; # same as prev.
52 $date->_mon; # month 0..11
53 $date->_month; # same as prev.
54 $date->day; # day of month
55 $date->mday; # day of month
56 $date->day_of_month;# same as prev.
57 $date->hour;
58 $date->min;
59 $date->minute; # same as prev.
60 $date->sec;
61 $date->second; # same as prev.
62 $date->wday; # 1 = Sunday
63 $date->_wday; # 0 = Sunday
64 $date->day_of_week; # same as prev.
65 $date->yday;
66 $date->day_of_year; # same as prev.
67 $date->isdst; # DST?
68 $date->daylight_savings; # same as prev.
69 $date->epoch; # UNIX time_t
70 $date->monname; # name of month, eg: March
71 $date->monthname; # same as prev.
72 $date->wdayname; # Thursday
73 $date->day_of_weekname # same as prev.
74 $date->hms # 01:23:45
75 $date->ymd # 2000/02/29
76 $date->mdy # 02/29/2000
77 $date->dmy # 29/02/2000
78 $date->meridiam # 01:23 AM
79 $date->ampm # AM/PM
80 $date->string # 2000-02-29 12:21:11 (format can be changed, look below)
81 "$date" # same as prev.
82 $date->tzoffset # timezone-offset
83 $date->strftime($format) # POSIX strftime (without the huge POSIX.pm)
84 $date->tz # returns the base timezone as you specify, eg: CET
85 $date->tzdst # returns the real timezone with dst information, eg: CEST
86
87 ($year,$month,$day,$hour,$min,$sec)=$date->array;
88 ($year,$month,$day,$hour,$min,$sec)=@{ $date->aref };
89 # !! $year: 1900-, $month: 1-12
90
91 ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=$date->struct;
92 ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=@{ $date->sref };
93 # !! $year: 0-, $month: 0-11
94
95 $hash=$date->href; # $href can be reused as a constructor
96 print $hash->{year}."-".$hash->{month}. ... $hash->{sec} ... ;
97
98 %hash=$date->hash;
99 # !! $hash{year}: 1900-, $hash{month}: 1-12
100
101 $date->month_begin # First day of the month (date object)
102 $date->month_end # Last day of the month
103 $date->days_in_month # 28..31
104
105 # constructing new date based on an existing one:
106 $new_date = $date->clone;
107 $new_date = $date->clone( year => 1977, sec => 14 );
108 # valid keys: year, _year, month, mon, _month, _mon, day, mday, day_of_month,
109 # hour, min, minute, sec, second, tz
110 # constructing a new date, which is the same as the original, but in
111 # another timezone:
112 $new_date = $date->to_tz('Iceland');
113
114 # changing date format
115 {
116 local $Class::Date::DATE_FORMAT="%Y%m%d%H%M%S";
117 print $date # result: 20011222000000
118 $Class::Date::DATE_FORMAT=undef;
119 print $date # result: Thu Oct 13 04:54:34 1994
120 $Class::Date::DATE_FORMAT="%Y/%m/%d"
121 print $date # result: 1994/10/13
122 }
123
124 # error handling
125 $a = date($date_string);
126 if ($a) { # valid date
127 ...
128 } else { # invalid date
129 if ($a->error == E_INVALID) { ... }
130 print $a->errstr;
131 }
132
133 # adjusting DST in calculations (see the doc)
134 $Class::Date::DST_ADJUST = 1; # this is the default
135 $Class::Date::DST_ADJUST = 0;
136
137 # "month-border adjust" flag
138 $Class::Date::MONTH_BORDER_ADJUST = 0; # this is the default
139 print date("2001-01-31")+'1M'; # will print 2001-03-03
140 $Class::Date::MONTH_BORDER_ADJUST = 1;
141 print date("2001-01-31")+'1M'; # will print 2001-02-28
142
143 # date range check
144 $Class::Date::RANGE_CHECK = 0; # this is the default
145 print date("2001-02-31"); # will print 2001-03-03
146 $Class::Date::RANGE_CHECK = 1;
147 print date("2001-02-31"); # will print nothing
148
149 # getting values of a relative date object
150 $reldate; # reldate in seconds (assumed 1 month = 2_629_744 secs)
151 $reldate->year;
152 $reldate->mon;
153 $reldate->month; # same as prev.
154 $reldate->day;
155 $reldate->hour;
156 $reldate->min;
157 $reldate->minute; # same as prev.
158 $reldate->sec; # same as $reldate
159 $reldate->second; # same as prev.
160 $reldate->sec_part; # "second" part of the relative date
161 $reldate->mon_part; # "month" part of the relative date
162
163 # arithmetic with dates:
164 print date([2001,12,11,4,5,6])->truncate;
165 # will print "2001-12-11"
166 $new_date = $date+$reldate;
167 $date2 = $date+'3Y 2D'; # 3 Years and 2 days
168 $date3 = $date+[1,2,3]; # $date plus 1 year, 2 months, 3 days
169 $date4 = $date+'3-1-5' # $date plus 3 years, 1 months, 5 days
170
171 $new_date = $date-$reldate;
172 $date2 = $date-'3Y'; # 3 Yearss
173 $date3 = $date-[1,2,3]; # $date minus 1 year, 2 months, 3 days
174 $date4 = $date-'3-1-5' # $date minus 3 years, 1 month, 5 days
175
176 $new_reldate = $date1-$date2;
177 $reldate2 = Class::Date->new('2000-11-12')-'2000-11-10';
178 $reldate3 = $date3-'1977-11-10';
179
180 $days_between = (Class::Date->new('2001-11-12')-'2001-07-04')->day;
181
182 # comparison between absolute dates
183 print $date1 > $date2 ? "I am older" : "I am younger";
184
185 # comparison between relative dates
186 print $reldate1 > $reldate2 ? "I am faster" : "I am slower";
187
188 # Adding / Subtracting months and years are sometimes tricky:
189 print date("2001-01-29") + '1M' - '1M'; # gives "2001-02-01"
190 print date("2000-02-29") + '1Y' - '1Y'; # gives "2000-03-01"
191
192 # Named interface ($date2 does not necessary to be a Class::Date object)
193 $date1->string; # same as $date1 in scalar context
194 $date1->subtract($date2); # same as $date1 - $date2
195 $date1->add($date2); # same as $date1 + $date2
196 $date1->compare($date2); # same as $date1 <=> $date2
197
198 $reldate1->sec; # same as $reldate1 in numeric or scalar context
199 $reldate1->compare($reldate2);# same as $reldate1 <=> $reldate2
200 $reldate1->add($reldate2); # same as $reldate1 + $reldate2
201 $reldate1->neg # used for subtraction
202
203 # Disabling Class::Date warnings at load time
204 BEGIN { $Class::Date::WARNINGS=0; }
205 use Class::Date;
206
208 This module is intended to provide a general-purpose date and datetime
209 type for perl. You have a Class::Date class for absolute date and
210 datetime, and have a Class::Date::Rel class for relative dates.
211
212 You can use "+", "-", "<" and ">" operators as with native perl data
213 types.
214
216 If you want to use a date object, you need to do the following:
217
218 - create a new object
219 - do some operations (+, -, comparison)
220 - get result back
221
222 Creating a new date object
223 You can create a date object by the "date", "localdate" or "gmdate"
224 function, or by calling the Class::Date constructor.
225
226 "date" and "Class::Date->new" are equivalent, both has two arguments:
227 The date and the timezone.
228
229 $date1= date [2000,11,12];
230 $date2= Class::Date->new([2000,06,11,13,11,22],'GMT');
231 $date2= $date1->new([2000,06,11,13,11,22]);
232
233 If the timezone information is omitted, then it first check if "new" is
234 called as an object method or a class method. If it is an object
235 method, then it inherits the timezone from the base object, otherwise
236 the default timezone is used ($Class::Date::DEFAULT_TIMEZONE), which is
237 usually set to the local timezone (which is stored in
238 $Class::Date::LOCAL_TIMEZONE). These two variables are set only once to
239 the value, which is returned by the Class::Date::local_timezone()
240 function. You can change these values whenever you want.
241
242 "localdate $x" is equivalent to "date $x,
243 $Class::Date::LOCAL_TIMEZONE", "gmdate $x" is equivalent to "date $x,
244 $Class::Date::GMT_TIMEZONE".
245
246 $Class::Date::GMT_TIMEZONE is set to 'GMT' by default.
247
248 $date1= localdate [2000,11,12];
249 $date2= gmdate [2000,4,2,3,33,33];
250
251 $date = localdate(time);
252
253 The format of the accepted input date can be:
254
255 [$year,$month,$day,$hour,$min,$sec]
256 An array reference with 6 elements. The missing elements have
257 default values (year: 2000, month, day: 1, hour, min, sec: 0)
258
259 { year => $year, month => $month, day => $day, hour => $hour, min =>
260 $min, sec => $sec }
261 A hash reference with the same 6 elements as above.
262
263 "YYYYMMDDhhmmss"
264 A mysql-style timestamp value, which consist of at least 14 digit.
265
266 "973897262"
267 A valid 32-bit integer: This is parsed as a unix time.
268
269 "YYYY-MM-DD hh:mm:ss"
270 A standard ISO(-like) date format. Additional ".fraction" part is
271 ignored, ":ss" can be omitted.
272
273 additional input formats
274 You can specify "-DateParse" as an import parameter, e.g:
275
276 use Class::Date qw(date -DateParse);
277
278 With this, the module will try to load Date::Parse module, and if
279 it find it then all these formats can be used as an input. Please
280 refer to the Date::Parse documentation.
281
282 Operations
283 addition
284 You can add the following to a Class::Date object:
285
286 - a valid Class::Date::Rel object
287 - anything, that can be used for creating a new Class::Date::Rel object
288
289 It means that you don't need to create a new Class::Date::Rel
290 object every time when you add something to the Class::Date object,
291 it creates them automatically:
292
293 $date= Class::Date->new('2001-12-11')+Class::Date::Rel->new('3Y');
294
295 is the same as:
296
297 $date= date('2001-12-11')+'3Y';
298
299 You can provide a Class::Date::Rel object in the following form:
300
301 array ref
302 The same format as seen in Class::Date format, except the
303 default values are different: all zero.
304
305 hash ref
306 The same format as seen in Class::Date format, except the
307 default values are different: all zero.
308
309 "973897262"
310 A valid 32-bit integer is parsed as seconds.
311
312 "YYYY-MM-DD hh:mm:ss"
313 A standard ISO date format, but this is parsed as relative date
314 date and time, so month, day and year can be zero (and defaults
315 to zero).
316
317 "12Y 6M 6D 20h 12m 5s"
318 This special string can be used if you don't want to use the
319 ISO format. This string consists of whitespace separated tags,
320 each tag consists of a number and a unit. The units can be:
321
322 Y: year
323 M: month
324 D: day
325 h: hour
326 m: min
327 s: sec
328
329 The number and unit must be written with no space between them.
330
331 substraction
332 The same rules are true for substraction, except you can substract
333 two Class::Date object from each other, and you will get a
334 Class::Date::Rel object:
335
336 $reldate=$date1-$date2;
337 $reldate=date('2001-11-12 12:11:07')-date('2001-10-07 10:3:21');
338
339 In this case, the "month" field of the $reldate object will be 0,
340 and the other fields will contain the difference between two dates;
341
342 comparison
343 You can compare two Class::Date objects, or one Class::Date object
344 and another data, which can be used for creating a new Class::Data
345 object.
346
347 It means that you don't need to bless both objects, one of them can
348 be a simple string, array ref, hash ref, etc (see how to create a
349 date object).
350
351 if ( date('2001-11-12') > date('2000-11-11') ) { ... }
352
353 or
354
355 if ( date('2001-11-12') > '2000-11-11' ) { ... }
356
357 truncate
358 You can chop the time value from this object (set hour, min and sec
359 to 0) with the "truncate" or "trunc" method. It does not modify the
360 specified object, it returns with a new one.
361
362 clone
363 You can create new date object based on an existing one, by using
364 the "clone" method. Note, this DOES NOT modify the base object.
365
366 $new_date = $date->clone( year => 2001, hour => 14 );
367
368 The valid keys are: year, _year, month, mon, _month, _mon, day,
369 mday, day_of_month, hour, min, minute, sec, second, tz.
370
371 There is a "set" method, which does the same as the "clone", it
372 exists only for compatibility.
373
374 to_tz
375 You can use "to_tz" to create a new object, which means the same
376 time as the base object, but in the different timezone.
377
378 Note that $date->clone( tz => 'Iceland') and
379 $date->to_tz('Iceland') is not the same! Cloning a new object with
380 setting timezone will preserve the time information (hour, minute,
381 second, etc.), but transfer the time into other timezone, while
382 to_tz usually change these values based on the difference between
383 the source and the destination timezone.
384
385 Operations with Class::Date::Rel
386 The Class::Date::Rel object consists of a month part and a day
387 part. Most people only use the "day" part of it. If you use both
388 part, then you can get these parts with the "sec_part" and
389 "mon_part" method. If you use "sec", "month", etc. methods or if
390 you use this object in a mathematical conent, then this object is
391 converted to one number, which is interpreted as second. The
392 conversion is based on a 30.436 days month. Don't use it too often,
393 because it is confusing...
394
395 If you use Class::Date::Rel in an expression with other Class::Date
396 or Class::Date::Rel objects, then it does what is expected:
397
398 date('2001-11-12')+'1M' will be '2001-12-12'
399
400 and
401
402 date('1996-02-11')+'2M' will be '1996-04-11'
403
404 Accessing data from a Class::Date and Class::Date::Rel object
405 You can use the methods methods described at the top of the document if
406 you want to access parts of the data which is stored in a Class::Date
407 and Class::Date::Rel object.
408
409 Error handling
410 If a date object became invalid, then the object will be reblessed to
411 Class::Date::Invalid. This object is false in boolean environment, so
412 you can test the date validity like this:
413
414 $a = date($input_date);
415 if ($a) { # valid date
416 ...
417 } else { # invalid date
418 if ($a->error == E_INVALID) { ... }
419 print $a->errstr;
420 }
421
422 Note even the date is invalid, the expression "defined $a" always
423 returns true, so the following is wrong:
424
425 $a = date($input_date);
426 if (defined $a) ... # WRONG!!!!
427
428 You can test the error by getting the $date->error value. You might
429 import the ":errors" tag:
430
431 use Class::Date qw(:errors);
432
433 Possible error values are:
434
435 E_OK
436 No errors.
437
438 E_INVALID
439 Invalid date. It is set when some of the parts of the date are
440 invalid, and Time::Local functions cannot convert them to a valid
441 date.
442
443 E_RANGE
444 This error is set, when parts of the date are valid, but the whole
445 date is not valid, e.g. 2001-02-31. When the
446 $Class::Date::RANGE_CHECK is not set, then these date values are
447 automatically converted to a valid date: 2001-03-03, but the
448 $date->error value are set to E_RANGE. If $Class::Date::RANGE_CHECK
449 is set, then a date "2001-02-31" became invalid date.
450
451 E_UNPARSABLE
452 This error is set, when the constructor cannot be created from a
453 scalar, e.g:
454
455 $a = date("4kd sdlsdf lwekrmk");
456
457 E_UNDEFINED
458 This error is set, when you want to create a date object from an
459 undefined value:
460
461 $a = new Class::Date (undef);
462
463 Note, that localdate(undef) will create a valid object, because it
464 calls $Class::Date(time).
465
466 You can get the error in string form by calling the "errstr" method.
467
469 $DST_ADJUST is an importable variable, and is a very important
470 configuration option.
471
472 If it is set to true (default), then it adjusts the date and time when
473 the operation switches the border of DST. You will see the difference
474 if you run this code:
475
476 $Class::Date::DST_ADJUST=0;
477 for (my $date=localdate("2000-06-11");$date<"2001-4-5";$date+='1D') {
478 print $date."\n";
479 }
480
481 $Class::Date::DST_ADJUST=1;
482 for (my $date=localdate("2000-06-11");$date<"2001-4-5";$date+='1D') {
483 print $date."\n";
484 }
485
487 If you add or subtract "months" and "years" to a date, you may get
488 wrong dates, e.g when you add one month to 2001-01-31, you expect to
489 get 2001-02-31, but this date is invalid and converted to 2001-03-03.
490 Thats' why
491
492 date("2001-01-31") + '1M' - '1M' != "2001-01-31"
493
494 This problem can occur only with months and years, because others can
495 easily be converted to seconds.
496
498 $MONTH_BORDER_ADJUST variable is used to switch on or off the month-
499 adjust feature. This is used only when someone adds months or years to
500 a date and then the resulted date became invalid. An example: adding
501 one month to "2001-01-31" will result "2001-02-31", and this is an
502 invalid date.
503
504 When $MONTH_BORDER_ADJUST is false, this result simply normalized, and
505 becomes "2001-03-03". This is the default behaviour.
506
507 When $MONTH_BORDER_ADJUST is true, this result becomes "2001-02-28". So
508 when the date overflows, then it returns the last day insted.
509
510 Both settings keeps the time information.
511
513 Class::Date can be used without a C compiler since 1.0.8. If you want
514 to do this, you only need to copy the "Date.pm" whereever your perl
515 compiler searches for it. You must make a "Class" directory for it
516 before.
517
518 In Debian GNU/Linux system (woody) , a good choice can be the
519 following:
520
521 mkdir /usr/local/share/perl/5.6.1/Class
522 cp Date.pm /usr/local/share/perl/5.6.1/Class
523
524 And the module will work.
525
526 You can use the $WARNINGS switch to switch off the complains about the
527 missing XS part from your perl program:
528
529 BEGIN { $Class::Date::WARNINGS=0; }
530 use Class::Date;
531 ...
532
534 Since 1.0.11, Class::Date handle timezones natively on most platforms
535 (see the BUGS AND LIMITATIONS section for more info).
536
537 When the module is loaded, then it determines the local base timezone
538 by calling the Class::Date::local_timezone() function, and stores these
539 values into two variables, these are: $Class::Date::LOCAL_TIMEZONE and
540 $Class::Date::DEFAULT_TIMEZONE. The first value is used, when you call
541 the "localdate" function, the second value is used, when you call the
542 "date" function and you don't specify the timezone. There is a
543 $Class::Date::GMT_TIMEZONE function also, which is used by the "gmdate"
544 function, this is set to 'GMT'.
545
546 You can query the timezone of a date object by calling the $date->tz
547 method. Note this value returns the timezone as you specify, so if you
548 create the object with an unknown timezone, you will get this back. If
549 you want to query the effective timezone, you can call the $date->tzdst
550 method. This method returns only valid timezones, but it is not
551 necessarily the timezone, which can be used to create a new object. For
552 example $date->tzdst can return 'CEST', which is not a valid base
553 timezone, because it contains daylight savings information also. On
554 Linux systems, you can see the possible base timezones in the
555 /usr/share/zoneinfo directory.
556
557 In Class::Date 1.1.6, a new environment variable is introduced:
558 $Class::Date::NOTZ_TIMEZONE. This variable stores the local timezone,
559 which is used, when the TZ environment variable is not set. It is
560 introduced, because there are some systems, which cannot handle the
561 queried timezone well. For example the local timezone is CST, it is
562 returned by the tzname() perl function, but when I set the TZ
563 environment variable to CST, it works like it would be GMT. The
564 workaround is NOTZ_TIMEZONE: if a date object has a timezone, which is
565 the same as NOTZ_TIMEZONE, then the TZ variable will be removed before
566 each calculation. In normal case, it would be the same as setting TZ to
567 $NOTZ_TIMEZONE, but some systems don't like it, so I decided to
568 introduce this variable. The $Class::Date::NOTZ_TIMEZONE variable is
569 set in the initialization of the module by removing the TZ variable
570 from the environment and querying the tzname variable.
571
573 This module uses operator overloading very heavily. I've found it quite
574 stable, but I am afraid of it a bit.
575
576 A Class::Date object is an array reference.
577
578 A Class::Date::Rel object is an array reference, which contains month
579 and second information. I need to store it as an array ref, because
580 array and month values cannot be converted into seconds, because of our
581 super calendar.
582
583 You can add code references to the @Class::Date::NEW_FROM_SCALAR and
584 @Class::Date::Rel::NEW_FROM_SCALAR. These arrays are iterated through
585 when a scalar-format date must be parsed. These arrays only have one or
586 two values at initialization. The parameters which the code references
587 got are the same as the "new" method of each class. In this way, you
588 can personalize the date parses as you want.
589
590 As of 0.90, the Class::Date has been rewritten. A lot of code and
591 design decision has been borrowed from Matt Sergeant's Time::Object,
592 and there will be some incompatibility with the previous public version
593 (0.5). I tried to keep compatibility methods in Class::Date. If you
594 have problems regarding this, please drop me an email with the
595 description of the problem, and I will set the compatibility back.
596
597 Invalid dates are Class::Date::Invalid objects. Every method call on
598 this object and every operation with this object returns undef or 0.
599
601 This module tries to be as full-featured as can be. It currently lacks
602 business-day calculation, which is planned to be implemented in the
603 1.0.x series.
604
605 I try to keep this module not to depend on other modules and I want
606 this module usable without a C compiler.
607
608 Currently the module uses the POSIX localtime function very
609 extensively. This makes the date calculation a bit slow, but provides
610 a rich interface, which is not provided by any other module. When I
611 tried to redesign the internals to not depend on localtime, I failed,
612 because there are no other way to determine the daylight savings
613 information.
614
616 There are two kind of adjustment in this module, DST_ADJUST and
617 MONTH_BORDER_ADJUST. Both of them makes the "+" and "-" operations
618 slower. If you don't need them, switch them off to achieve faster
619 calculations.
620
621 In general, if you really need fast date and datetime calculation,
622 don't use this module. As you see in the previous section, the focus of
623 development is not the speed in 1.0. For fast date and datetime
624 calculations, use Date::Calc module instead.
625
627 This module is NOT thread-safe, since it uses C library functions,
628 which are not thread-safe. Using this module in a multi-threaded
629 environment can cause timezones to be messed up. I did not put any
630 warning about it, you have to make sure that you understand this!
631
632 Under some circumstances in a mod_perl environment, you require the
633 Env::C module to set the TZ variable properly before calling the time
634 functions. I added the -EnvC import option to automatically load this
635 module if it is not loaded already. Please read the mod_perl
636 documentation about the environment variables and mod_perl to get the
637 idea why it is required sometimes:
638
639 http://perl.apache.org/docs/2.0/user/troubleshooting/troubleshooting.html#C_Libraries_Don_t_See_C__ENV__Entries_Set_by_Perl_Code
640
641 You are sure have this problem if the $Class::Date::NOTZ_TIMEZONE
642 variable is set to 'UTC', althought you are sure that your timezone is
643 not that. Try -EnvC in this case, but make sure that you are not using
644 it in a multi-threaded environment!
645
647 · I cannot manage to get the timezone code working properly on
648 ActivePerl 5.8.0 on win XP and earlier versions possibly have this
649 problem also. If you have a system like this, then you will have
650 only two timezones, the local and the GMT. Every timezone, which is
651 not equal to $Class::Date::GMT_TIMEZONE is assumed to be local.
652 This seems to be caused by the win32 implementation of timezone
653 routines. I don't really know how to make this thing working, so I
654 gave up this issue. If anyone know a working solution, then I will
655 integrate it into Class::Date, but until then, the timezone support
656 will not be available for these platforms.
657
658 · Perl 5.8.0 and earlier versions has a bug in the strftime code on
659 some operating systems (for example Linux), which is timezone
660 related. I recommend using the strftime, which is provided with
661 Class::Date, so don't try to use the module without the compiled
662 part. The module will not work with a buggy strftime - the test is
663 hardcoded into the beginning of the code. If you anyway want to use
664 the module, remove the hardcoded "die" from the module, but do it
665 for your own risk.
666
667 · This module uses the POSIX functions for date and time
668 calculations, so it is not working for dates beyond 2038 and before
669 1902.
670
671 I don't know what systems support dates in 1902-1970 range, it may
672 not work on your system. I know it works on the Linux glibc system
673 with perl 5.6.1 and 5.7.2. I know it does not work with perl
674 5.005_03 (it may be the bug of the Time::Local module). Please
675 report if you know any system where it does _not_ work with perl
676 5.6.1 or later.
677
678 I hope that someone will fix this with new time_t in libc. If you
679 really need dates over 2038 and before 1902, you need to completely
680 rewrite this module or use Date::Calc or other date modules.
681
682 · This module uses Time::Local, and when it croaks, Class::Date
683 returns "Invalid date or time" error message. Time::Local is
684 different in the 5.005 and 5.6.x (and even 5.7.x) version of perl,
685 so the following code will return different results:
686
687 $a = date("2006-11-11")->clone(year => -1);
688
689 In perl 5.6.1, it returns an invalid date with error message
690 "Invali date or time", in perl 5.005 it returns an invalid date
691 with range check error. Both are false if you use them in boolean
692 context though, only the error message is different, but don't rely
693 on the error message in this case. It however works in the same way
694 if you change other fields than "year" to an invalid field.
695
697 Class::Date is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
698
699 If you have questions, you can send questions directly to me:
700
701 dlux@dlux.hu
702
704 You can get a binary win32 version of Class::Date from Chris Winters'
705 .ppd repository with the following commands:
706
707 For people using PPM2:
708
709 c:\> ppm
710 PPM> set repository oi http://openinteract.sourceforge.net/ppmpackages/
711 PPM> set save
712 PPM> install Class-Date
713
714 For people using PPM3:
715
716 c:\> ppm
717 PPM> repository http://openinteract.sourceforge.net/ppmpackages/
718 PPM> install Class-Date
719
720 The first steps in PPM only needs to be done at the first time. Next
721 time you just run the 'install'.
722
724 Copyright (c) 2001 SzabA~X, BalA~Xzs (dLux)
725
726 All rights reserved. This program is free software; you can
727 redistribute it and/or modify it under the same terms as Perl itself.
728
729 Portions Copyright (c) Matt Sergeant
730
732 dLux (SzabA~X, BalA~Xzs) <dlux@dlux.hu>
733
735 - Matt Sergeant <matt@sergeant.org>
736 (Lots of code are borrowed from the Time::Object module)
737 - Tatsuhiko Miyagawa <miyagawa@cpan.org> (bugfixes)
738 - Stas Bekman <stas@stason.org> (suggestions, bugfix)
739 - Chris Winters <chris@cwinters.com> (win32 .ppd version)
740 - Benoit Beausejour <bbeausej@pobox.com>
741 (Parts of the timezone code is borrowed from his Date::Handler module)
742
744 perl(1). Date::Calc(3pm). Time::Object(3pm). Date::Handler(3pm).
745
746
747
748perl v5.12.0 2010-04-30 Date(3)