1Date(3)               User Contributed Perl Documentation              Date(3)
2
3
4

NAME

6       Class::Date - Class for easy date and time manipulation
7

SYNOPSIS

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

DESCRIPTION

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 date‐
210       time, 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

USAGE

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
224       You can create a date object by the "date", "localdate" or "gmdate"
225       function, or by calling the Class::Date constructor.
226
227       "date" and "Class::Date->new" are equivalent, both has two arguments:
228       The date and the timezone.
229
230         $date1= date [2000,11,12];
231         $date2= Class::Date->new([2000,06,11,13,11,22],'GMT');
232         $date2= $date1->new([2000,06,11,13,11,22]);
233
234       If the timezone information is omitted, then it first check if "new" is
235       called as an object method or a class method. If it is an object
236       method, then it inherits the timezone from the base object, otherwise
237       the default timezone is used ($Class::Date::DEFAULT_TIMEZONE), which is
238       usually set to the local timezone (which is stored in
239       $Class::Date::LOCAL_TIMEZONE). These two variables are set only once to
240       the value, which is returned by the Class::Date::local_timezone() func‐
241       tion. You can change these values whenever you want.
242
243       "localdate $x" is equivalent to "date $x, $Class::Date::LOCAL_TIME‐
244       ZONE", "gmdate $x" is equivalent to "date $x, $Class::Date::GMT_TIME‐
245       ZONE".
246
247       $Class::Date::GMT_TIMEZONE is set to 'GMT' by default.
248
249         $date1= localdate [2000,11,12];
250         $date2= gmdate [2000,4,2,3,33,33];
251
252         $date = localdate(time);
253
254       The format of the accepted input date can be:
255
256       [$year,$month,$day,$hour,$min,$sec]
257           An array reference with 6 elements. The missing elements have
258           default values (year: 2000, month, day: 1, hour, min, sec: 0)
259
260       { year => $year, month => $month, day => $day, hour => $hour, min =>
261       $min, sec => $sec }
262           A hash reference with the same 6 elements as above.
263
264       "YYYYMMDDhhmmss"
265           A mysql-style timestamp value, which consist of at least 14 digit.
266
267       "973897262"
268           A valid 32-bit integer: This is parsed as a unix time.
269
270       "YYYY-MM-DD hh:mm:ss"
271           A standard ISO(-like) date format. Additional ".fraction" part is
272           ignored, ":ss" can be omitted.
273
274       additional input formats
275           You can specify "-DateParse" as  an import parameter, e.g:
276
277             use Class::Date qw(date -DateParse);
278
279           With this, the module will try to load Date::Parse module, and if
280           it find it then all these formats can be used as an input. Please
281           refer to the Date::Parse documentation.
282
283       Operations
284
285       addition
286           You can add the following to a Class::Date object:
287
288             - a valid Class::Date::Rel object
289             - anything, that can be used for creating a new Class::Date::Rel object
290
291           It means that you don't need to create a new Class::Date::Rel
292           object every time when you add something to the Class::Date object,
293           it creates them automatically:
294
295             $date= Class::Date->new('2001-12-11')+Class::Date::Rel->new('3Y');
296
297           is the same as:
298
299             $date= date('2001-12-11')+'3Y';
300
301           You can provide a Class::Date::Rel object in the following form:
302
303           array ref
304               The same format as seen in Class::Date format, except the
305               default values are different: all zero.
306
307           hash ref
308               The same format as seen in Class::Date format, except the
309               default values are different: all zero.
310
311           "973897262"
312               A valid 32-bit integer is parsed as seconds.
313
314           "YYYY-MM-DD hh:mm:ss"
315               A standard ISO date format, but this is parsed as relative date
316               date and time, so month, day and year can be zero (and defaults
317               to zero).
318
319           "12Y 6M 6D 20h 12m 5s"
320               This special string can be used if you don't want to use the
321               ISO format. This string consists of whitespace separated tags,
322               each tag consists of a number and a unit. The units can be:
323
324                 Y: year
325                 M: month
326                 D: day
327                 h: hour
328                 m: min
329                 s: sec
330
331               The number and unit must be written with no space between them.
332
333       substraction
334           The same rules are true for substraction, except you can substract
335           two Class::Date object from each other, and you will get a
336           Class::Date::Rel object:
337
338             $reldate=$date1-$date2;
339             $reldate=date('2001-11-12 12:11:07')-date('2001-10-07 10:3:21');
340
341           In this case, the "month" field of the $reldate object will be 0,
342           and the other fields will contain the difference between two dates;
343
344       comparison
345           You can compare two Class::Date objects, or one Class::Date object
346           and another data, which can be used for creating a new Class::Data
347           object.
348
349           It means that you don't need to bless both objects, one of them can
350           be a simple string, array ref, hash ref, etc (see how to create a
351           date object).
352
353             if ( date('2001-11-12') > date('2000-11-11') ) { ... }
354
355           or
356
357             if ( date('2001-11-12') > '2000-11-11' ) { ... }
358
359       truncate
360           You can chop the time value from this object (set hour, min and sec
361           to 0) with the "truncate" or "trunc" method. It does not modify the
362           specified object, it returns with a new one.
363
364       clone
365           You can create new date object based on an existing one, by using
366           the "clone" method. Note, this DOES NOT modify the base object.
367
368             $new_date = $date->clone( year => 2001, hour => 14 );
369
370           The valid keys are: year, _year, month, mon, _month, _mon, day,
371           mday, day_of_month, hour, min, minute, sec, second, tz.
372
373           There is a "set" method, which does the same as the "clone", it
374           exists only for compatibility.
375
376       to_tz
377           You can use "to_tz" to create a new object, which means the same
378           time as the base object, but in the different timezone.
379
380           Note that $date->clone( tz => 'Iceland') and $date->to_tz('Ice‐
381           land') is not the same! Cloning a new object with setting timezone
382           will preserve the time information (hour, minute, second, etc.),
383           but transfer the time into other timezone, while to_tz usually
384           change these values based on the difference between the source and
385           the destination timezone.
386
387       Operations with Class::Date::Rel
388           The Class::Date::Rel object consists of a month part and a day
389           part. Most people only use the "day" part of it. If you use both
390           part, then you can get these parts with the "sec_part" and
391           "mon_part" method. If you use "sec", "month", etc. methods or if
392           you use this object in a mathematical conent, then this object is
393           converted to one number, which is interpreted as second.  The con‐
394           version is based on a 30.436 days month. Don't use it too often,
395           because it is confusing...
396
397           If you use Class::Date::Rel in an expression with other Class::Date
398           or Class::Date::Rel objects, then it does what is expected:
399
400             date('2001-11-12')+'1M' will be '2001-12-12'
401
402           and
403
404             date('1996-02-11')+'2M' will be '1996-04-11'
405
406       Accessing data from a Class::Date and Class::Date::Rel object
407
408       You can use the methods methods described at the top of the document if
409       you want to access parts of the data which is stored in a Class::Date
410       and Class::Date::Rel object.
411
412       Error handling
413
414       If a date object became invalid, then the object will be reblessed to
415       Class::Date::Invalid. This object is false in boolean environment, so
416       you can test the date validity like this:
417
418         $a = date($input_date);
419         if ($a) { # valid date
420             ...
421         } else { # invalid date
422             if ($a->error == E_INVALID) { ... }
423             print $a->errstr;
424         }
425
426       Note even the date is invalid, the expression "defined $a" always
427       returns true, so the following is wrong:
428
429         $a = date($input_date);
430         if (defined $a) ... # WRONG!!!!
431
432       You can test the error by getting the $date->error value. You might
433       import the ":errors" tag:
434
435         use Class::Date qw(:errors);
436
437       Possible error values are:
438
439       E_OK
440           No errors.
441
442       E_INVALID
443           Invalid date. It is set when some of the parts of the date are
444           invalid, and Time::Local functions cannot convert them to a valid
445           date.
446
447       E_RANGE
448           This error is set, when parts of the date are valid, but the whole
449           date is not valid, e.g. 2001-02-31. When the
450           $Class::Date::RANGE_CHECK is not set, then these date values are
451           automatically converted to a valid date: 2001-03-03, but the
452           $date->error value are set to E_RANGE. If $Class::Date::RANGE_CHECK
453           is set, then a date "2001-02-31" became invalid date.
454
455       E_UNPARSABLE
456           This error is set, when the constructor cannot be created from a
457           scalar, e.g:
458
459             $a = date("4kd sdlsdf lwekrmk");
460
461       E_UNDEFINED
462           This error is set, when you want to create a date object from an
463           undefined value:
464
465             $a = new Class::Date (undef);
466
467           Note, that localdate(undef) will create a valid object, because it
468           calls $Class::Date(time).
469
470       You can get the error in string form by calling the "errstr" method.
471

DST_ADJUST

473       $DST_ADJUST is an importable variable, and is a very important configu‐
474       ration option.
475
476       If it is set to true (default), then it adjusts the date and time when
477       the operation switches the border of DST. You will see the difference
478       if you run this code:
479
480         $Class::Date::DST_ADJUST=0;
481         for (my $date=localdate("2000-06-11");$date<"2001-4-5";$date+='1D') {
482           print $date."\n";
483         }
484
485         $Class::Date::DST_ADJUST=1;
486         for (my $date=localdate("2000-06-11");$date<"2001-4-5";$date+='1D') {
487           print $date."\n";
488         }
489

MONTHS AND YEARS

491       If you add or subtract "months" and "years" to a date, you may get
492       wrong dates, e.g when you add one month to 2001-01-31, you expect to
493       get 2001-02-31, but this date is invalid and converted to 2001-03-03.
494       Thats' why
495
496         date("2001-01-31") + '1M' - '1M' != "2001-01-31"
497
498       This problem can occur only with months and years, because others can
499       easily be converted to seconds.
500

MONTH_BORDER_ADJUST

502       $MONTH_BORDER_ADJUST variable is used to switch on or off the month-
503       adjust feature. This is used only when someone adds months or years to
504       a date and then the resulted date became invalid. An example: adding
505       one month to "2001-01-31" will result "2001-02-31", and this is an
506       invalid date.
507
508       When $MONTH_BORDER_ADJUST is false, this result simply normalized, and
509       becomes "2001-03-03". This is the default behaviour.
510
511       When $MONTH_BORDER_ADJUST is true, this result becomes "2001-02-28". So
512       when the date overflows, then it returns the last day insted.
513
514       Both settings keeps the time information.
515

WORKING WITHOUT A C COMPILER

517       Class::Date can be used without a C compiler since 1.0.8. If you want
518       to do this, you only need to copy the "Date.pm" whereever your perl
519       compiler searches for it. You must make a "Class" directory for it
520       before.
521
522       In Debian GNU/Linux system (woody) , a good choice can be the follow‐
523       ing:
524
525         mkdir /usr/local/share/perl/5.6.1/Class
526         cp Date.pm /usr/local/share/perl/5.6.1/Class
527
528       And the module will work.
529
530       You can use the $WARNINGS switch to switch off the complains about the
531       missing XS part from your perl program:
532
533           BEGIN { $Class::Date::WARNINGS=0; }
534           use Class::Date;
535           ...
536

TIMEZONE SUPPORT

538       Since 1.0.11, Class::Date handle timezones natively on most platforms
539       (see the BUGS AND LIMITATIONS section for more info).
540
541       When the module is loaded, then it determines the local base timezone
542       by calling the Class::Date::local_timezone() function, and stores these
543       values into two variables, these are: $Class::Date::LOCAL_TIMEZONE and
544       $Class::Date::DEFAULT_TIMEZONE. The first value is used, when you call
545       the "localdate" function, the second value is used, when you call the
546       "date" function and you don't specify the timezone. There is a
547       $Class::Date::GMT_TIMEZONE function also, which is used by the "gmdate"
548       function, this is set to 'GMT'.
549
550       You can query the timezone of a date object by calling the $date->tz
551       method. Note this value returns the timezone as you specify, so if you
552       create the object with an unknown timezone, you will get this back. If
553       you want to query the effective timezone, you can call the $date->tzdst
554       method.  This method returns only valid timezones, but it is not neces‐
555       sarily the timezone, which can be used to create a new object. For
556       example $date->tzdst can return 'CEST', which is not a valid base time‐
557       zone, because it contains daylight savings information also. On Linux
558       systems, you can see the possible base timezones in the
559       /usr/share/zoneinfo directory.
560
561       In Class::Date 1.1.6, a new environment variable is introduced:
562       $Class::Date::NOTZ_TIMEZONE. This variable stores the local timezone,
563       which is used, when the TZ environment variable is not set. It is
564       introduced, because there are some systems, which cannot handle the
565       queried timezone well. For example the local timezone is CST, it is
566       returned by the tzname() perl function, but when I set the TZ environ‐
567       ment variable to CST, it works like it would be GMT.  The workaround is
568       NOTZ_TIMEZONE: if a date object has a timezone, which is the same as
569       NOTZ_TIMEZONE, then the TZ variable will be removed before each calcu‐
570       lation. In normal case, it would be the same as setting TZ to
571       $NOTZ_TIMEZONE, but some systems don't like it, so I decided to intro‐
572       duce this variable. The $Class::Date::NOTZ_TIMEZONE variable is set in
573       the initialization of the module by removing the TZ variable from the
574       environment and querying the tzname variable.
575

INTERNALS

577       This module uses operator overloading very heavily. I've found it quite
578       stable, but I am afraid of it a bit.
579
580       A Class::Date object is an array reference.
581
582       A Class::Date::Rel object is an array reference, which contains month
583       and second information. I need to store it as an array ref, because
584       array and month values cannot be converted into seconds, because of our
585       super calendar.
586
587       You can add code references to the @Class::Date::NEW_FROM_SCALAR and
588       @Class::Date::Rel::NEW_FROM_SCALAR. These arrays are iterated through
589       when a scalar-format date must be parsed. These arrays only have one or
590       two values at initialization. The parameters which the code references
591       got are the same as the "new" method of each class. In this way, you
592       can personalize the date parses as you want.
593
594       As of 0.90, the Class::Date has been rewritten. A lot of code and
595       design decision has been borrowed from Matt Sergeant's Time::Object,
596       and there will be some incompatibility with the previous public version
597       (0.5). I tried to keep compatibility methods in Class::Date. If you
598       have problems regarding this, please drop me an email with the descrip‐
599       tion of the problem, and I will set the compatibility back.
600
601       Invalid dates are Class::Date::Invalid objects. Every method call on
602       this object and every operation with this object returns undef or 0.
603

DEVELOPMENT FOCUS

605       This module tries to be as full-featured as can be. It currently lacks
606       business-day calculation, which is planned to be implemented in the
607       1.0.x series.
608
609       I try to keep this module not to depend on other modules and I want
610       this module usable without a C compiler.
611
612       Currently the module uses the POSIX localtime function very exten‐
613       sively.  This makes the date calculation a bit slow, but provides a
614       rich interface, which is not provided by any other module. When I tried
615       to redesign the internals to not depend on localtime, I failed, because
616       there are no other way to determine the daylight savings information.
617

SPEED ISSUES

619       There are two kind of adjustment in this module, DST_ADJUST and
620       MONTH_BORDER_ADJUST. Both of them makes the "+" and "-" operations
621       slower. If you don't need them, switch them off to achieve faster cal‐
622       culations.
623
624       In general, if you really need fast date and datetime calculation,
625       don't use this module. As you see in the previous section, the focus of
626       development is not the speed in 1.0.  For fast date and datetime calcu‐
627       lations, use Date::Calc module instead.
628

THREAD SAFETY and MOD_PERL

630       This module is NOT thread-safe, since it uses C library functions,
631       which are not thread-safe. Using this module in a multi-threaded envi‐
632       ronment can cause timezones to be messed up. I did not put any warning
633       about it, you have to make sure that you understand this!
634
635       Under some circumstances in a mod_perl environment, you require the
636       Env::C module to set the TZ variable properly before calling the time
637       functions. I added the -EnvC import option to automatically load this
638       module if it is not loaded already. Please read the mod_perl documenta‐
639       tion about the environment variables and mod_perl to get the idea why
640       it is required sometimes:
641
642         http://perl.apache.org/docs/2.0/user/troubleshooting/troubleshooting.html#C_Libraries_Don_t_See_C__ENV__Entries_Set_by_Perl_Code
643
644       You are sure have this problem if the $Class::Date::NOTZ_TIMEZONE vari‐
645       able is set to 'UTC', althought you are sure that your timezone is not
646       that. Try -EnvC in this case, but make sure that you are not using it
647       in a multi-threaded environment!
648

OTHER BUGS AND LIMITATIONS

650       ·   I cannot manage to get the timezone code working properly on
651           ActivePerl 5.8.0 on win XP and earlier versions possibly have this
652           problem also. If you have a system like this, then you will have
653           only two timezones, the local and the GMT. Every timezone, which is
654           not equal to $Class::Date::GMT_TIMEZONE is assumed to be local.
655           This seems to be caused by the win32 implementation of timezone
656           routines. I don't really know how to make this thing working, so I
657           gave up this issue. If anyone know a working solution, then I will
658           integrate it into Class::Date, but until then, the timezone support
659           will not be available for these platforms.
660
661       ·   Perl 5.8.0 and earlier versions has a bug in the strftime code on
662           some operating systems (for example Linux), which is timezone
663           related. I recommend using the strftime, which is provided with
664           Class::Date, so don't try to use the module without the compiled
665           part. The module will not work with a buggy strftime - the test is
666           hardcoded into the beginning of the code. If you anyway want to use
667           the module, remove the hardcoded "die" from the module, but do it
668           for your own risk.
669
670       ·   This module uses the POSIX functions for date and time calcula‐
671           tions, so it is not working for dates beyond 2038 and before 1902.
672
673           I don't know what systems support dates in 1902-1970 range, it may
674           not work on your system. I know it works on the Linux glibc system
675           with perl 5.6.1 and 5.7.2. I know it does not work with perl
676           5.005_03 (it may be the bug of the Time::Local module). Please
677           report if you know any system where it does _not_ work with perl
678           5.6.1 or later.
679
680           I hope that someone will fix this with new time_t in libc. If you
681           really need dates over 2038 and before 1902, you need to completely
682           rewrite this module or use Date::Calc or other date modules.
683
684       ·   This module uses Time::Local, and when it croaks, Class::Date
685           returns "Invalid date or time" error message. Time::Local is dif‐
686           ferent in the 5.005 and 5.6.x (and even 5.7.x) version of perl, so
687           the following code will return different results:
688
689             $a = date("2006-11-11")->clone(year => -1);
690
691           In perl 5.6.1, it returns an invalid date with error message
692           "Invali date or time", in perl 5.005 it returns an invalid date
693           with range check error. Both are false if you use them in boolean
694           context though, only the error message is different, but don't rely
695           on the error message in this case. It however works in the same way
696           if you change other fields than "year" to an invalid field.
697

SUPPORT

699       Class::Date is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
700
701       If you have questions, you can send questions directly to me:
702
703         dlux@dlux.hu
704

WIN32 notes

706       You can get a binary win32 version of Class::Date from Chris Winters'
707       .ppd repository with the following commands:
708
709       For people using PPM2:
710
711         c:\> ppm
712         PPM> set repository oi http://openinteract.sourceforge.net/ppmpackages/
713         PPM> set save
714         PPM> install Class-Date
715
716       For people using PPM3:
717
718         c:\> ppm
719         PPM> repository http://openinteract.sourceforge.net/ppmpackages/
720         PPM> install Class-Date
721
722       The first steps in PPM only needs to be done at the first time. Next
723       time you just run the 'install'.
724
726       Copyright (c) 2001 Szabó, Balázs (dLux)
727
728       All rights reserved. This program is free software; you can redis‐
729       tribute it and/or modify it under the same terms as Perl itself.
730
731       Portions Copyright (c) Matt Sergeant
732

AUTHOR

734         dLux (Szabó, Balázs) <dlux@dlux.hu>
735

CREDITS

737         - Matt Sergeant <matt@sergeant.org>
738           (Lots of code are borrowed from the Time::Object module)
739         - Tatsuhiko Miyagawa <miyagawa@cpan.org> (bugfixes)
740         - Stas Bekman <stas@stason.org> (suggestions, bugfix)
741         - Chris Winters <chris@cwinters.com> (win32 .ppd version)
742         - Benoit Beausejour <bbeausej@pobox.com>
743           (Parts of the timezone code is borrowed from his Date::Handler module)
744

SEE ALSO

746       perl(1).  Date::Calc(3pm).  Time::Object(3pm).  Date::Handler(3pm).
747
748
749
750perl v5.8.8                       2007-10-16                           Date(3)
Impressum