1DateTime(3) User Contributed Perl Documentation DateTime(3)
2
3
4
6 DateTime - A date and time object for Perl
7
9 version 1.59
10
12 use DateTime;
13
14 $dt = DateTime->new(
15 year => 1964,
16 month => 10,
17 day => 16,
18 hour => 16,
19 minute => 12,
20 second => 47,
21 nanosecond => 500000000,
22 time_zone => 'Asia/Taipei',
23 );
24
25 $dt = DateTime->from_epoch( epoch => $epoch );
26 $dt = DateTime->now; # same as ( epoch => time )
27
28 $year = $dt->year;
29 $month = $dt->month; # 1-12
30
31 $day = $dt->day; # 1-31
32
33 $dow = $dt->day_of_week; # 1-7 (Monday is 1)
34
35 $hour = $dt->hour; # 0-23
36 $minute = $dt->minute; # 0-59
37
38 $second = $dt->second; # 0-61 (leap seconds!)
39
40 $doy = $dt->day_of_year; # 1-366 (leap years)
41
42 $doq = $dt->day_of_quarter; # 1..
43
44 $qtr = $dt->quarter; # 1-4
45
46 # all of the start-at-1 methods above have corresponding start-at-0
47 # methods, such as $dt->day_of_month_0, $dt->month_0 and so on
48
49 $ymd = $dt->ymd; # 2002-12-06
50 $ymd = $dt->ymd('/'); # 2002/12/06
51
52 $mdy = $dt->mdy; # 12-06-2002
53 $mdy = $dt->mdy('/'); # 12/06/2002
54
55 $dmy = $dt->dmy; # 06-12-2002
56 $dmy = $dt->dmy('/'); # 06/12/2002
57
58 $hms = $dt->hms; # 14:02:29
59 $hms = $dt->hms('!'); # 14!02!29
60
61 $is_leap = $dt->is_leap_year;
62
63 # these are localizable, see Locales section
64 $month_name = $dt->month_name; # January, February, ...
65 $month_abbr = $dt->month_abbr; # Jan, Feb, ...
66 $day_name = $dt->day_name; # Monday, Tuesday, ...
67 $day_abbr = $dt->day_abbr; # Mon, Tue, ...
68
69 # May not work for all possible datetime, see the docs on this
70 # method for more details.
71 $epoch_time = $dt->epoch;
72
73 $dt2 = $dt + $duration_object;
74
75 $dt3 = $dt - $duration_object;
76
77 $duration_object = $dt - $dt2;
78
79 $dt->set( year => 1882 );
80
81 $dt->set_time_zone('America/Chicago');
82
83 $dt->set_formatter($formatter);
84
86 DateTime is a class for the representation of date/time combinations,
87 and is part of the Perl DateTime project.
88
89 It represents the Gregorian calendar, extended backwards in time before
90 its creation (in 1582). This is sometimes known as the "proleptic
91 Gregorian calendar". In this calendar, the first day of the calendar
92 (the epoch), is the first day of year 1, which corresponds to the date
93 which was (incorrectly) believed to be the birth of Jesus Christ.
94
95 The calendar represented does have a year 0, and in that way differs
96 from how dates are often written using "BCE/CE" or "BC/AD".
97
98 For infinite datetimes, please see the DateTime::Infinite module.
99
101 0-based Versus 1-based Numbers
102 The "DateTime" module follows a simple logic for determining whether or
103 not a given number is 0-based or 1-based.
104
105 Month, day of month, day of week, and day of year are 1-based. Any
106 method that is 1-based also has an equivalent 0-based method ending in
107 "_0". So for example, this class provides both "day_of_week" and
108 "day_of_week_0" methods.
109
110 The "day_of_week_0" method still treats Monday as the first day of the
111 week.
112
113 All time-related numbers such as hour, minute, and second are 0-based.
114
115 Years are neither, as they can be both positive or negative, unlike any
116 other datetime component. There is a year 0.
117
118 There is no "quarter_0" method.
119
120 Error Handling
121 Some errors may cause this module to die with an error string. This can
122 only happen when calling constructor methods, methods that change the
123 object, such as "set", or methods that take parameters. Methods that
124 retrieve information about the object, such as "year" or "epoch", will
125 never die.
126
127 Locales
128 All the object methods which return names or abbreviations return data
129 based on a locale. This is done by setting the locale when constructing
130 a DateTime object. If this is not set, then "en-US" is used.
131
132 Floating DateTimes
133 The default time zone for new DateTime objects, except where stated
134 otherwise, is the "floating" time zone. This concept comes from the
135 iCal standard. A floating datetime is one which is not anchored to any
136 particular time zone. In addition, floating datetimes do not include
137 leap seconds, since we cannot apply them without knowing the datetime's
138 time zone.
139
140 The results of date math and comparison between a floating datetime and
141 one with a real time zone are not really valid, because one includes
142 leap seconds and the other does not. Similarly, the results of datetime
143 math between two floating datetimes and two datetimes with time zones
144 are not really comparable.
145
146 If you are planning to use any objects with a real time zone, it is
147 strongly recommended that you do not mix these with floating datetimes.
148
149 Math
150 If you are going to be doing date math, please read the section "How
151 DateTime Math Works".
152
153 Determining the Local Time Zone Can Be Slow
154 If $ENV{TZ} is not set, it may involve reading a number of files in
155 /etc or elsewhere. If you know that the local time zone won't change
156 while your code is running, and you need to make many objects for the
157 local time zone, it is strongly recommended that you retrieve the local
158 time zone once and cache it:
159
160 our $App::LocalTZ = DateTime::TimeZone->new( name => 'local' );
161
162 # then everywhere else
163
164 my $dt = DateTime->new( ..., time_zone => $App::LocalTZ );
165
166 DateTime itself does not do this internally because local time zones
167 can change, and there's no good way to determine if it's changed
168 without doing all the work to look it up.
169
170 Far Future DST
171 Do not try to use named time zones (like "America/Chicago") with dates
172 very far in the future (thousands of years). The current implementation
173 of "DateTime::TimeZone" will use a huge amount of memory calculating
174 all the DST changes from now until the future date. Use UTC or the
175 floating time zone and you will be safe.
176
177 Globally Setting a Default Time Zone
178 Warning: This is very dangerous. Do this at your own risk!
179
180 By default, "DateTime" uses either the floating time zone or UTC for
181 newly created objects, depending on the constructor.
182
183 You can force "DateTime" to use a different time zone by setting the
184 "PERL_DATETIME_DEFAULT_TZ" environment variable.
185
186 As noted above, this is very dangerous, as it affects all code that
187 creates a "DateTime" object, including modules from CPAN. If those
188 modules expect the normal default, then setting this can cause
189 confusing breakage or subtly broken data. Before setting this variable,
190 you are strongly encouraged to audit your CPAN dependencies to see how
191 they use "DateTime". Try running the test suite for each dependency
192 with this environment variable set before using this in production.
193
194 Upper and Lower Bounds
195 Internally, dates are represented the number of days before or after
196 0001-01-01. This is stored as an integer, meaning that the upper and
197 lower bounds are based on your Perl's integer size ($Config{ivsize}).
198
199 The limit on 32-bit systems is around 2^29 days, which gets you to year
200 (+/-)1,469,903. On a 64-bit system you get 2^62 days, to year
201 (+/-)12,626,367,463,883,278 (12.626 quadrillion).
202
204 DateTime provides many methods. The documentation breaks them down into
205 groups based on what they do (constructor, accessors, modifiers, etc.).
206
207 Constructors
208 All constructors can die when invalid parameters are given.
209
210 Warnings
211
212 Currently, constructors will warn if you try to create a far future
213 DateTime (year >= 5000) with any time zone besides floating or UTC.
214 This can be very slow if the time zone has future DST transitions that
215 need to be calculated. If the date is sufficiently far in the future
216 this can be really slow (minutes).
217
218 All warnings from DateTime use the "DateTime" category and can be
219 suppressed with:
220
221 no warnings 'DateTime';
222
223 This warning may be removed in the future if DateTime::TimeZone is made
224 much faster.
225
226 DateTime->new( ... )
227
228 my $dt = DateTime->new(
229 year => 1966,
230 month => 10,
231 day => 25,
232 hour => 7,
233 minute => 15,
234 second => 47,
235 nanosecond => 500000000,
236 time_zone => 'America/Chicago',
237 );
238
239 This class method accepts the following parameters:
240
241 • year
242
243 An integer year for the DateTime. This can be any integer number
244 within the valid range for your system (See "Upper and Lower
245 Bounds"). This is required.
246
247 • month
248
249 An integer from 1-12. Defaults to 1.
250
251 • day
252
253 An integer from 1-31. The value will be validated based on the
254 month, to prevent creating invalid dates like February 30. Defaults
255 to 1.
256
257 • hour
258
259 An integer from 0-23. Hour 0 is midnight at the beginning of the
260 given date. Defaults to 0.
261
262 • minute
263
264 An integer from 0-59. Defaults to 0.
265
266 • second
267
268 An integer from 0-61. Values of 60 or 61 are only allowed when the
269 specified date and time have a leap second. Defaults to 0.
270
271 • nanosecond
272
273 An integer that is greater than or equal to 0. If this number is
274 greater than 1 billion, it will be normalized into the second value
275 for the DateTime object. Defaults to 0
276
277 • locale
278
279 A string containing a locale code, like "en-US" or "zh-Hant-TW", or
280 an object returned by "DateTime::Locale->load". See the
281 DateTime::Locale documentation for details. Defaults to the value
282 of "DateTime->DefaultLocale", or "en-US" if the class default has
283 not been set.
284
285 • time_zone
286
287 A string containing a time zone name like "America/Chicago" or a
288 DateTime::TimeZone object. Defaults to the value of
289 $ENV{PERL_DATETIME_DEFAULT_TZ} or "floating" if that env var is not
290 set. See "Globally Setting a Default Time Zone" for more details on
291 that env var (and why you should not use it).
292
293 A string will simply be passed to the "DateTime::TimeZone->new"
294 method as its "name" parameter. This string may be an Olson DB time
295 zone name ("America/Chicago"), an offset string ("+0630"), or the
296 words "floating" or "local". See the "DateTime::TimeZone"
297 documentation for more details.
298
299 • formatter
300
301 An object or class name with a "format_datetime" method. This will
302 be used to stringify the DateTime object. This is optional. If it
303 is not specified, then stringification calls "$self->iso8601".
304
305 Invalid parameter types (like an array reference) will cause the
306 constructor to die.
307
308 Parsing Dates
309
310 This module does not parse dates! That means there is no constructor to
311 which you can pass things like "March 3, 1970 12:34".
312
313 Instead, take a look at the various DateTime::Format::*
314 <https://metacpan.org/search?q=datetime%3A%3Aformat> modules on CPAN.
315 These parse all sorts of different date formats, and you're bound to
316 find something that can handle your particular needs.
317
318 Ambiguous Local Times
319
320 Because of Daylight Saving Time, it is possible to specify a local time
321 that is ambiguous. For example, in the US in 2003, the transition from
322 to saving to standard time occurred on October 26, at 02:00:00 local
323 time. The local clock changed from 01:59:59 (saving time) to 01:00:00
324 (standard time). This means that the hour from 01:00:00 through
325 01:59:59 actually occurs twice, though the UTC time continues to move
326 forward.
327
328 If you specify an ambiguous time, then the latest UTC time is always
329 used, in effect always choosing standard time. In this case, you can
330 simply subtract an hour from the object in order to move to saving
331 time, for example:
332
333 # This object represent 01:30:00 standard time
334 my $dt = DateTime->new(
335 year => 2003,
336 month => 10,
337 day => 26,
338 hour => 1,
339 minute => 30,
340 second => 0,
341 time_zone => 'America/Chicago',
342 );
343
344 print $dt->hms; # prints 01:30:00
345
346 # Now the object represent 01:30:00 saving time
347 $dt->subtract( hours => 1 );
348
349 print $dt->hms; # still prints 01:30:00
350
351 Alternately, you could create the object with the UTC time zone and
352 then call the "set_time_zone" method to change the time zone. This is a
353 good way to ensure that the time is not ambiguous.
354
355 Invalid Local Times
356
357 Another problem introduced by Daylight Saving Time is that certain
358 local times just do not exist. For example, in the US in 2003, the
359 transition from standard to saving time occurred on April 6, at the
360 change to 2:00:00 local time. The local clock changed from 01:59:59
361 (standard time) to 03:00:00 (saving time). This means that there is no
362 02:00:00 through 02:59:59 on April 6!
363
364 Attempting to create an invalid time currently causes a fatal error.
365
366 DateTime->from_epoch( epoch => $epoch, ... )
367
368 This class method can be used to construct a new DateTime object from
369 an epoch time instead of components. Just as with the "new" method, it
370 accepts "time_zone", "locale", and "formatter" parameters.
371
372 You can also call it with a single unnamed argument, which will be
373 treated as the epoch value.
374
375 If the epoch value is a non-integral value, it will be rounded to
376 nearest microsecond.
377
378 By default, the returned object will be in the UTC time zone.
379
380 If you pass a "time_zone", then this time zone will be applied after
381 the object is constructed. In other words, the epoch value is always
382 interpreted as being in the UTC time zone. Here's an example:
383
384 my $dt = DateTime->from_epoch(
385 epoch => 0,
386 time_zone => 'Asia/Tokyo'
387 );
388 say $dt; # Prints 1970-01-01T09:00:00 as Asia/Tokyo is +09:00 from UTC.
389 $dt->set_time_zone('UTC');
390 say $dt; # Prints 1970-01-01T00:00:00
391
392 DateTime->now( ... )
393
394 This class method is equivalent to calling "from_epoch" with the value
395 returned from Perl's "time" function. Just as with the "new" method, it
396 accepts "time_zone" and "locale" parameters.
397
398 By default, the returned object will be in the UTC time zone.
399
400 If you want sub-second resolution, use the DateTime::HiRes module's
401 "DateTime::HiRes->now" method instead.
402
403 DateTime->today( ... )
404
405 This class method is equivalent to:
406
407 DateTime->now(@_)->truncate( to => 'day' );
408
409 DateTime->last_day_of_month( ... )
410
411 This constructor takes the same arguments as can be given to the "new"
412 method, except for "day". Additionally, both "year" and "month" are
413 required.
414
415 DateTime->from_day_of_year( ... )
416
417 This constructor takes the same arguments as can be given to the "new"
418 method, except that it does not accept a "month" or "day" argument.
419 Instead, it requires both "year" and "day_of_year". The day of year
420 must be between 1 and 366, and 366 is only allowed for leap years.
421
422 DateTime->from_object( object => $object, ... )
423
424 This class method can be used to construct a new DateTime object from
425 any object that implements the "utc_rd_values" method. All
426 "DateTime::Calendar" modules must implement this method in order to
427 provide cross-calendar compatibility. This method accepts a "locale"
428 and "formatter" parameter
429
430 If the object passed to this method has a "time_zone" method, that is
431 used to set the time zone of the newly created "DateTime" object.
432
433 Otherwise, the returned object will be in the floating time zone.
434
435 $dt->clone
436
437 This object method returns a new object that is replica of the object
438 upon which the method is called.
439
440 "Get" Methods
441 This class has many methods for retrieving information about an object.
442
443 $dt->year
444
445 Returns the year.
446
447 $dt->ce_year
448
449 Returns the year according to the BCE/CE numbering system. The year
450 before year 1 in this system is year -1, aka "1 BCE".
451
452 $dt->era_name
453
454 Returns the long name of the current era, something like "Before
455 Christ". See the "Locales" section for more details.
456
457 $dt->era_abbr
458
459 Returns the abbreviated name of the current era, something like "BC".
460 See the "Locales" section for more details.
461
462 $dt->christian_era
463
464 Returns a string, either "BC" or "AD", according to the year.
465
466 $dt->secular_era
467
468 Returns a string, either "BCE" or "CE", according to the year.
469
470 $dt->year_with_era
471
472 Returns a string containing the year immediately followed by the
473 appropriate era abbreviation, based on the object's locale. The year is
474 the absolute value of "ce_year", so that year 1 is "1" and year 0 is
475 "1BC". See the "Locales" section for more details.
476
477 $dt->year_with_christian_era
478
479 Like "year_with_era", but uses the "christian_era" method to get the
480 era name.
481
482 $dt->year_with_secular_era
483
484 Like "year_with_era", but uses the "secular_era" method to get the era
485 name.
486
487 $dt->month
488
489 Returns the month of the year, from 1..12.
490
491 Also available as "$dt->mon".
492
493 $dt->month_name
494
495 Returns the name of the current month. See the "Locales" section for
496 more details.
497
498 $dt->month_abbr
499
500 Returns the abbreviated name of the current month. See the "Locales"
501 section for more details.
502
503 $dt->day
504
505 Returns the day of the month, from 1..31.
506
507 Also available as "$dt->mday" and "$dt->day_of_month".
508
509 $dt->day_of_week
510
511 Returns the day of the week as a number, from 1..7, with 1 being Monday
512 and 7 being Sunday.
513
514 Also available as "$dt->wday" and "$dt->dow".
515
516 $dt->local_day_of_week
517
518 Returns the day of the week as a number, from 1..7. The day
519 corresponding to 1 will vary based on the locale. See the "Locales"
520 section for more details.
521
522 $dt->day_name
523
524 Returns the name of the current day of the week. See the "Locales"
525 section for more details.
526
527 $dt->day_abbr
528
529 Returns the abbreviated name of the current day of the week. See the
530 "Locales" section for more details.
531
532 $dt->day_of_year
533
534 Returns the day of the year.
535
536 Also available as "$dt->doy".
537
538 $dt->quarter
539
540 Returns the quarter of the year, from 1..4.
541
542 $dt->quarter_name
543
544 Returns the name of the current quarter. See the "Locales" section for
545 more details.
546
547 $dt->quarter_abbr
548
549 Returns the abbreviated name of the current quarter. See the "Locales"
550 section for more details.
551
552 $dt->day_of_quarter
553
554 Returns the day of the quarter.
555
556 Also available as "$dt->doq".
557
558 $dt->weekday_of_month
559
560 Returns a number from 1..5 indicating which week day of the month this
561 is. For example, June 9, 2003 is the second Monday of the month, and so
562 this method returns 2 for that date.
563
564 $dt->ymd($optional_separator), $dt->mdy(...), $dt->dmy(...)
565
566 Each method returns the year, month, and day, in the order indicated by
567 the method name. Years are zero-padded to four digits. Months and days
568 are 0-padded to two digits.
569
570 By default, the values are separated by a dash (-), but this can be
571 overridden by passing a value to the method.
572
573 The "$dt->ymd" method is also available as "$dt->date".
574
575 $dt->hour
576
577 Returns the hour of the day, from 0..23.
578
579 $dt->hour_1
580
581 Returns the hour of the day, from 1..24.
582
583 $dt->hour_12
584
585 Returns the hour of the day, from 1..12.
586
587 $dt->hour_12_0
588
589 Returns the hour of the day, from 0..11.
590
591 $dt->am_or_pm
592
593 Returns the appropriate localized abbreviation, depending on the
594 current hour.
595
596 $dt->minute
597
598 Returns the minute of the hour, from 0..59.
599
600 Also available as "$dt->min".
601
602 $dt->second
603
604 Returns the second, from 0..61. The values 60 and 61 are used for leap
605 seconds.
606
607 Also available as "$dt->sec".
608
609 $dt->fractional_second
610
611 Returns the second, as a real number from 0.0 until 61.999999999
612
613 The values 60 and 61 are used for leap seconds.
614
615 $dt->millisecond
616
617 Returns the fractional part of the second as milliseconds (1E-3
618 seconds).
619
620 Half a second is 500 milliseconds.
621
622 This value will always be rounded down to the nearest integer.
623
624 $dt->microsecond
625
626 Returns the fractional part of the second as microseconds (1E-6
627 seconds).
628
629 Half a second is 500,000 microseconds.
630
631 This value will always be rounded down to the nearest integer.
632
633 $dt->nanosecond
634
635 Returns the fractional part of the second as nanoseconds (1E-9
636 seconds).
637
638 Half a second is 500,000,000 nanoseconds.
639
640 $dt->hms($optional_separator)
641
642 Returns the hour, minute, and second, all zero-padded to two digits. If
643 no separator is specified, a colon (:) is used by default.
644
645 Also available as "$dt->time".
646
647 $dt->datetime($optional_separator)
648
649 This method is equivalent to:
650
651 $dt->ymd('-') . 'T' . $dt->hms(':')
652
653 The $optional_separator parameter allows you to override the separator
654 between the date and time, for e.g. "$dt->datetime(q{ })".
655
656 This method is also available as "$dt->iso8601", but it's not really a
657 very good ISO8601 format, as it lacks a time zone. If called as
658 "$dt->iso8601" you cannot change the separator, as ISO8601 specifies
659 that "T" must be used to separate them.
660
661 $dt->rfc3339
662
663 This formats a datetime in RFC3339 format. This is the same as
664 "$dt->datetime" with an added offset at the end of the string except if
665 the time zone is the floating time zone.
666
667 If the offset is '+00:00' then this is represented as 'Z'. Otherwise
668 the offset is formatted with a leading sign (+/-) and a colon separated
669 numeric offset with hours and minutes. If the offset has a non-zero
670 seconds component, that is also included.
671
672 $dt->stringify
673
674 This method returns a stringified version of the object. It is also how
675 stringification overloading is implemented. If the object has a
676 formatter, then its "format_datetime" method is used to produce a
677 string. Otherwise, this method calls "$dt->iso8601" to produce a
678 string. See "Formatters And Stringification" for details.
679
680 $dt->is_leap_year
681
682 This method returns a boolean value indicating whether or not the
683 datetime object is in a leap year.
684
685 $dt->is_last_day_of_month
686
687 This method returns a boolean value indicating whether or not the
688 datetime object is the last day of the month.
689
690 $dt->is_last_day_of_quarter
691
692 This method returns a boolean value indicating whether or not the
693 datetime object is the last day of the quarter.
694
695 $dt->is_last_day_of_year
696
697 This method returns a boolean value indicating whether or not the
698 datetime object is the last day of the year.
699
700 $dt->month_length
701
702 This method returns the number of days in the current month.
703
704 $dt->quarter_length
705
706 This method returns the number of days in the current quarter.
707
708 $dt->year_length
709
710 This method returns the number of days in the current year.
711
712 $dt->week
713
714 my ( $week_year, $week_number ) = $dt->week;
715
716 Returns information about the calendar week for the date. The values
717 returned by this method are also available separately through the
718 "$dt->week_year" and "$dt->week_number" methods.
719
720 The first week of the year is defined by ISO as the one which contains
721 the fourth day of January, which is equivalent to saying that it's the
722 first week to overlap the new year by at least four days.
723
724 Typically the week year will be the same as the year that the object is
725 in, but dates at the very beginning of a calendar year often end up in
726 the last week of the prior year, and similarly, the final few days of
727 the year may be placed in the first week of the next year.
728
729 $dt->week_year
730
731 Returns the year of the week. See "$dt->week" for details.
732
733 $dt->week_number
734
735 Returns the week of the year, from 1..53. See "$dt->week" for details.
736
737 $dt->week_of_month
738
739 The week of the month, from 0..5. The first week of the month is the
740 first week that contains a Thursday. This is based on the ICU
741 definition of week of month, and correlates to the ISO8601 week of year
742 definition. A day in the week before the week with the first Thursday
743 will be week 0.
744
745 $dt->jd, $dt->mjd
746
747 These return the Julian Day and Modified Julian Day, respectively. The
748 value returned is a floating point number. The fractional portion of
749 the number represents the time portion of the datetime.
750
751 The Julian Day is a count of days since the beginning of the Julian
752 Period, which starts with day 0 at noon on January 1, -4712.
753
754 The Modified Julian Day is a count of days since midnight on November
755 17, 1858.
756
757 These methods always refer to the local time, so the Julian Day is the
758 same for a given datetime regardless of its time zone. Or in other
759 words, 2020-12-04T13:01:57 in "America/Chicago" has the same Julian Day
760 as 2020-12-04T13:01:57 in "Asia/Taipei".
761
762 $dt->time_zone
763
764 This returns the DateTime::TimeZone object for the datetime object.
765
766 $dt->offset
767
768 This returns the offset from UTC, in seconds, of the datetime object's
769 time zone.
770
771 $dt->is_dst
772
773 Returns a boolean indicating whether or not the datetime's time zone is
774 currently in Daylight Saving Time or not.
775
776 $dt->time_zone_long_name
777
778 This is a shortcut for "$dt->time_zone->name". It's provided so that
779 one can use "%{time_zone_long_name}" as a strftime format specifier.
780
781 $dt->time_zone_short_name
782
783 This method returns the time zone abbreviation for the current time
784 zone, such as "PST" or "GMT". These names are not definitive, and
785 should not be used in any application intended for general use by users
786 around the world. That's because it's possible for multiple time zones
787 to have the same abbreviation.
788
789 $dt->strftime( $format, ... )
790
791 This method implements functionality similar to the "strftime" method
792 in C. However, if given multiple format strings, then it will return
793 multiple scalars, one for each format string.
794
795 See the "strftime Patterns" section for a list of all possible strftime
796 patterns.
797
798 If you give a pattern that doesn't exist, then it is simply treated as
799 text.
800
801 Note that any deviation from the POSIX standard is probably a bug.
802 DateTime should match the output of "POSIX::strftime" for any given
803 pattern.
804
805 $dt->format_cldr( $format, ... )
806
807 This method implements formatting based on the CLDR date patterns. If
808 given multiple format strings, then it will return multiple scalars,
809 one for each format string.
810
811 See the "CLDR Patterns" section for a list of all possible CLDR
812 patterns.
813
814 If you give a pattern that doesn't exist, then it is simply treated as
815 text.
816
817 $dt->epoch
818
819 Returns the UTC epoch value for the datetime object. Datetimes before
820 the start of the epoch will be returned as a negative number.
821
822 The return value from this method is always an integer number of
823 seconds.
824
825 Since the epoch does not account for leap seconds, the epoch time for
826 1972-12-31T23:59:60 (UTC) is exactly the same as that for
827 1973-01-01T00:00:00.
828
829 $dt->hires_epoch
830
831 Returns the epoch as a floating point number. The floating point
832 portion of the value represents the nanosecond value of the object.
833 This method is provided for compatibility with the "Time::HiRes"
834 module.
835
836 Note that this method suffers from the imprecision of floating point
837 numbers, and the result may end up rounded to an arbitrary degree
838 depending on your platform.
839
840 my $dt = DateTime->new( year => 2012, nanosecond => 4 );
841 say $dt->hires_epoch;
842
843 On my system, this simply prints 1325376000 because adding 0.000000004
844 to 1325376000 returns 1325376000.
845
846 $dt->is_finite, $dt->is_infinite
847
848 These methods allow you to distinguish normal datetime objects from
849 infinite ones. Infinite datetime objects are documented in
850 DateTime::Infinite.
851
852 $dt->utc_rd_values
853
854 Returns the current UTC Rata Die days, seconds, and nanoseconds as a
855 three element list. This exists primarily to allow other calendar
856 modules to create objects based on the values provided by this object.
857
858 $dt->local_rd_values
859
860 Returns the current local Rata Die days, seconds, and nanoseconds as a
861 three element list. This exists for the benefit of other modules which
862 might want to use this information for date math, such as
863 DateTime::Event::Recurrence.
864
865 $dt->leap_seconds
866
867 Returns the number of leap seconds that have happened up to the
868 datetime represented by the object. For floating datetimes, this always
869 returns 0.
870
871 $dt->utc_rd_as_seconds
872
873 Returns the current UTC Rata Die days and seconds purely as seconds.
874 This number ignores any fractional seconds stored in the object, as
875 well as leap seconds.
876
877 $dt->locale
878
879 Returns the datetime's DateTime::Locale object.
880
881 $dt->formatter
882
883 Returns the current formatter object or class. See "Formatters And
884 Stringification" for details.
885
886 "Set" Methods
887 The remaining methods provided by "DateTime", except where otherwise
888 specified, return the object itself, thus making method chaining
889 possible. For example:
890
891 my $dt = DateTime->now->set_time_zone( 'Australia/Sydney' );
892
893 my $first = DateTime
894 ->last_day_of_month( year => 2003, month => 3 )
895 ->add( days => 1 )
896 ->subtract( seconds => 1 );
897
898 $dt->set( .. )
899
900 This method can be used to change the local components of a date time.
901 This method accepts any parameter allowed by the "new" method except
902 for "locale" or "time_zone". Use "set_locale" and "set_time_zone" for
903 those instead.
904
905 This method performs parameter validation just like the "new" method.
906
907 Do not use this method to do date math. Use the "add" and "subtract"
908 methods instead.
909
910 $dt->set_year, $dt->set_month, etc.
911
912 DateTime has a "set_*" method for every item that can be passed to the
913 constructor:
914
915 • $dt->set_year
916
917 • $dt->set_month
918
919 • $dt->set_day
920
921 • $dt->set_hour
922
923 • $dt->set_minute
924
925 • $dt->set_second
926
927 • $dt->set_nanosecond
928
929 These are shortcuts to calling "set" with a single key. They all take a
930 single parameter.
931
932 $dt->truncate( to => ... )
933
934 This method allows you to reset some of the local time components in
935 the object to their "zero" values. The "to" parameter is used to
936 specify which values to truncate, and it may be one of "year",
937 "quarter", "month", "week", "local_week", "day", "hour", "minute", or
938 "second".
939
940 For example, if "month" is specified, then the local day becomes 1, and
941 the hour, minute, and second all become 0.
942
943 If "week" is given, then the datetime is set to the Monday of the week
944 in which it occurs, and the time components are all set to 0. If you
945 truncate to "local_week", then the first day of the week is locale-
946 dependent. For example, in the "en-US" locale, the first day of the
947 week is Sunday.
948
949 $dt->set_locale($locale)
950
951 Sets the object's locale. You can provide either a locale code like
952 "en-US" or an object returned by "DateTime::Locale->load".
953
954 $dt->set_time_zone($tz)
955
956 This method accepts either a time zone object or a string that can be
957 passed as the "name" parameter to "DateTime::TimeZone->new". If the new
958 time zone's offset is different from the old time zone, then the local
959 time is adjusted accordingly.
960
961 For example:
962
963 my $dt = DateTime->new(
964 year => 2000,
965 month => 5,
966 day => 10,
967 hour => 15,
968 minute => 15,
969 time_zone => 'America/Los_Angeles',
970 );
971
972 print $dt->hour; # prints 15
973
974 $dt->set_time_zone('America/Chicago');
975
976 print $dt->hour; # prints 17
977
978 If the old time zone was a floating time zone, then no adjustments to
979 the local time are made, except to account for leap seconds. If the new
980 time zone is floating, then the UTC time is adjusted in order to leave
981 the local time untouched.
982
983 Fans of Tsai Ming-Liang's films will be happy to know that this does
984 work:
985
986 my $dt = DateTime->now( time_zone => 'Asia/Taipei' );
987 $dt->set_time_zone('Europe/Paris');
988
989 Yes, now we can know "ni3 na4 bian1 ji2 dian3?"
990
991 $dt->set_formatter($formatter)
992
993 Sets the formatter for the object. See "Formatters And Stringification"
994 for details.
995
996 You can set this to "undef" to revert to the default formatter.
997
998 Math Methods
999 Like the set methods, math related methods always return the object
1000 itself, to allow for chaining:
1001
1002 $dt->add( days => 1 )->subtract( seconds => 1 );
1003
1004 $dt->duration_class
1005
1006 This returns "DateTime::Duration", but exists so that a subclass of
1007 "DateTime" can provide a different value.
1008
1009 $dt->add_duration($duration_object)
1010
1011 This method adds a DateTime::Duration to the current datetime. See the
1012 DateTime::Duration docs for more details.
1013
1014 $dt->add( parameters for DateTime::Duration )
1015
1016 This method is syntactic sugar around the "$dt->add_duration" method.
1017 It simply creates a new DateTime::Duration object using the parameters
1018 given, and then calls the "$dt->add_duration" method.
1019
1020 $dt->add($duration_object)
1021
1022 A synonym of "$dt->add_duration($duration_object)".
1023
1024 $dt->subtract_duration($duration_object)
1025
1026 When given a DateTime::Duration object, this method simply calls
1027 "$dur->inverse" on that object and passes that new duration to the
1028 "$self->add_duration" method.
1029
1030 $dt->subtract( DateTime::Duration->new parameters )
1031
1032 Like "$dt->add", this is syntactic sugar for the
1033 "$dt->subtract_duration" method.
1034
1035 $dt->subtract($duration_object)
1036
1037 A synonym of "$dt->subtract_duration($duration_object)".
1038
1039 $dt->subtract_datetime($datetime)
1040
1041 This method returns a new DateTime::Duration object representing the
1042 difference between the two dates. The duration is relative to the
1043 object from which $datetime is subtracted. For example:
1044
1045 2003-03-15 00:00:00.00000000
1046 - 2003-02-15 00:00:00.00000000
1047 -------------------------------
1048 = 1 month
1049
1050 Note that this duration is not an absolute measure of the amount of
1051 time between the two datetimes, because the length of a month varies,
1052 as well as due to the presence of leap seconds.
1053
1054 The returned duration may have deltas for months, days, minutes,
1055 seconds, and nanoseconds.
1056
1057 $dt->delta_md($datetime), $dt->delta_days($datetime)
1058
1059 Each of these methods returns a new DateTime::Duration object
1060 representing some portion of the difference between two datetimes. The
1061 "$dt->delta_md" method returns a duration which contains only the month
1062 and day portions of the duration is represented. The "$dt->delta_days"
1063 method returns a duration which contains only days.
1064
1065 The "$dt->delta_md" and "$dt->delta_days" methods truncate the duration
1066 so that any fractional portion of a day is ignored. Both of these
1067 methods operate on the date portion of a datetime only, and so
1068 effectively ignore the time zone.
1069
1070 Unlike the subtraction methods, these methods always return a positive
1071 (or zero) duration.
1072
1073 $dt->delta_ms($datetime)
1074
1075 Returns a duration which contains only minutes and seconds. Any day and
1076 month differences are converted to minutes and seconds. This method
1077 always returns a positive (or zero) duration.
1078
1079 $dt->subtract_datetime_absolute($datetime)
1080
1081 This method returns a new DateTime::Duration object representing the
1082 difference between the two dates in seconds and nanoseconds. This is
1083 the only way to accurately measure the absolute amount of time between
1084 two datetimes, since units larger than a second do not represent a
1085 fixed number of seconds.
1086
1087 Note that because of leap seconds, this may not return the same result
1088 as doing this math based on the value returned by "$dt->epoch".
1089
1090 $dt->is_between( $lower, $upper )
1091
1092 Checks whether $dt is strictly between two other DateTime objects.
1093
1094 "Strictly" means that $dt must be greater than $lower and less than
1095 $upper. If it is equal to either object then this method returns false.
1096
1097 Class Methods
1098 DateTime->DefaultLocale($locale)
1099
1100 This can be used to specify the default locale to be used when creating
1101 DateTime objects. If unset, then "en-US" is used.
1102
1103 This exists for backwards compatibility, but is probably best avoided.
1104 This will change the default locale for every "DateTime" object created
1105 in your application, even those created by third party libraries which
1106 also use "DateTime".
1107
1108 DateTime->compare( $dt1, $dt2 ), DateTime->compare_ignore_floating(
1109 $dt1, $dt2 )
1110
1111 $cmp = DateTime->compare( $dt1, $dt2 );
1112
1113 $cmp = DateTime->compare_ignore_floating( $dt1, $dt2 );
1114
1115 This method compare two DateTime objects. The semantics are compatible
1116 with Perl's "sort" function; it returns "-1" if "$dt1 < $dt2", 0 if
1117 "$dt1 == $dt2", 1 if "$dt1 > $dt2".
1118
1119 If one of the two DateTime objects has a floating time zone, it will
1120 first be converted to the time zone of the other object. This is what
1121 you want most of the time, but it can lead to inconsistent results when
1122 you compare a number of DateTime objects, some of which are floating,
1123 and some of which are in other time zones.
1124
1125 If you want to have consistent results (because you want to sort an
1126 array of objects, for example), you can use the
1127 "compare_ignore_floating" method:
1128
1129 @dates = sort { DateTime->compare_ignore_floating( $a, $b ) } @dates;
1130
1131 In this case, objects with a floating time zone will be sorted as if
1132 they were UTC times.
1133
1134 Since DateTime objects overload comparison operators, this:
1135
1136 @dates = sort @dates;
1137
1138 is equivalent to this:
1139
1140 @dates = sort { DateTime->compare( $a, $b ) } @dates;
1141
1142 DateTime objects can be compared to any other calendar class that
1143 implements the "utc_rd_values" method.
1144
1145 Testing Code That Uses DateTime
1146 If you are trying to test code that calls uses DateTime, you may want
1147 to be to explicitly set the value returned by Perl's "time" builtin.
1148 This builtin is called by "DateTime->now" and "DateTime->today".
1149
1150 You can override "CORE::GLOBAL::time", but this will only work if you
1151 do this before loading DateTime. If doing this is inconvenient, you can
1152 also override "DateTime::_core_time":
1153
1154 no warnings 'redefine';
1155 local *DateTime::_core_time = sub { return 42 };
1156
1157 DateTime is guaranteed to call this subroutine to get the current
1158 "time" value. You can also override the "_core_time" sub in a subclass
1159 of DateTime and use that.
1160
1161 How DateTime Math Works
1162 It's important to have some understanding of how datetime math is
1163 implemented in order to effectively use this module and
1164 DateTime::Duration.
1165
1166 Making Things Simple
1167
1168 If you want to simplify your life and not have to think too hard about
1169 the nitty-gritty of datetime math, I have several recommendations:
1170
1171 • use the floating time zone
1172
1173 If you do not care about time zones or leap seconds, use the
1174 "floating" timezone:
1175
1176 my $dt = DateTime->now( time_zone => 'floating' );
1177
1178 Math done on two objects in the floating time zone produces very
1179 predictable results.
1180
1181 Note that in most cases you will want to start by creating an
1182 object in a specific zone and then convert it to the floating time
1183 zone. When an object goes from a real zone to the floating zone,
1184 the time for the object remains the same.
1185
1186 This means that passing the floating zone to a constructor may not
1187 do what you want.
1188
1189 my $dt = DateTime->now( time_zone => 'floating' );
1190
1191 is equivalent to
1192
1193 my $dt = DateTime->now( time_zone => 'UTC' )->set_time_zone('floating');
1194
1195 This might not be what you wanted. Instead, you may prefer to do
1196 this:
1197
1198 my $dt = DateTime->now( time_zone => 'local' )->set_time_zone('floating');
1199
1200 • use UTC for all calculations
1201
1202 If you do care about time zones (particularly DST) or leap seconds,
1203 try to use non-UTC time zones for presentation and user input only.
1204 Convert to UTC immediately and convert back to the local time zone
1205 for presentation:
1206
1207 my $dt = DateTime->new( %user_input, time_zone => $user_tz );
1208 $dt->set_time_zone('UTC');
1209
1210 # do various operations - store it, retrieve it, add, subtract, etc.
1211
1212 $dt->set_time_zone($user_tz);
1213 print $dt->datetime;
1214
1215 • math on non-UTC time zones
1216
1217 If you need to do date math on objects with non-UTC time zones,
1218 please read the caveats below carefully. The results "DateTime"
1219 produces are predictable, correct, and mostly intuitive, but
1220 datetime math gets very ugly when time zones are involved, and
1221 there are a few strange corner cases involving subtraction of two
1222 datetimes across a DST change.
1223
1224 If you can always use the floating or UTC time zones, you can skip
1225 ahead to "Leap Seconds and Date Math"
1226
1227 • date vs datetime math
1228
1229 If you only care about the date (calendar) portion of a datetime,
1230 you should use either "$dt->delta_md" or "$dt->delta_days", not
1231 "$dt->subtract_datetime". This will give predictable, unsurprising
1232 results, free from DST-related complications.
1233
1234 • $dt->subtract_datetime and $dt->add_duration
1235
1236 You must convert your datetime objects to the UTC time zone before
1237 doing date math if you want to make sure that the following
1238 formulas are always true:
1239
1240 $dt2 - $dt1 = $dur
1241 $dt1 + $dur = $dt2
1242 $dt2 - $dur = $dt1
1243
1244 Note that using "$dt->delta_days" ensures that this formula always
1245 works, regardless of the time zones of the objects involved, as
1246 does using "$dt->subtract_datetime_absolute". Other methods of
1247 subtraction are not always reversible.
1248
1249 • never do math on two objects where only one is in the floating time
1250 zone
1251
1252 The date math code accounts for leap seconds whenever the
1253 "DateTime" object is not in the floating time zone. If you try to
1254 do math where one object is in the floating zone and the other
1255 isn't, the results will be confusing and wrong.
1256
1257 Adding a Duration to a DateTime
1258
1259 The parts of a duration can be broken down into five parts. These are
1260 months, days, minutes, seconds, and nanoseconds. Adding one month to a
1261 date is different than adding 4 weeks or 28, 29, 30, or 31 days.
1262 Similarly, due to DST and leap seconds, adding a day can be different
1263 than adding 86,400 seconds, and adding a minute is not exactly the same
1264 as 60 seconds.
1265
1266 We cannot convert between these units, except for seconds and
1267 nanoseconds, because there is no fixed conversion between most pairs of
1268 units. That is because of things like leap seconds, DST changes, etc.
1269
1270 "DateTime" always adds (or subtracts) days, then months, minutes, and
1271 then seconds and nanoseconds. If there are any boundary overflows,
1272 these are normalized at each step. For the days and months the local
1273 (not UTC) values are used. For minutes and seconds, the local values
1274 are used. This generally just works.
1275
1276 This means that adding one month and one day to February 28, 2003 will
1277 produce the date April 1, 2003, not March 29, 2003.
1278
1279 my $dt = DateTime->new( year => 2003, month => 2, day => 28 );
1280
1281 $dt->add( months => 1, days => 1 );
1282
1283 # 2003-04-01 - the result
1284
1285 On the other hand, if we add months first, and then separately add
1286 days, we end up with March 29, 2003:
1287
1288 $dt->add( months => 1 )->add( days => 1 );
1289
1290 # 2003-03-29
1291
1292 We see similar strangeness when math crosses a DST boundary:
1293
1294 my $dt = DateTime->new(
1295 year => 2003,
1296 month => 4,
1297 day => 5,
1298 hour => 1,
1299 minute => 58,
1300 time_zone => "America/Chicago",
1301 );
1302
1303 $dt->add( days => 1, minutes => 3 );
1304 # 2003-04-06 02:01:00
1305
1306 $dt->add( minutes => 3 )->add( days => 1 );
1307 # 2003-04-06 03:01:00
1308
1309 Note that if you converted the datetime object to UTC first you would
1310 get predictable results.
1311
1312 If you want to know how many seconds a DateTime::Duration object
1313 represents, you have to add it to a datetime to find out, so you could
1314 do:
1315
1316 my $now = DateTime->now( time_zone => 'UTC' );
1317 my $later = $now->clone->add_duration($duration);
1318
1319 my $seconds_dur = $later->subtract_datetime_absolute($now);
1320
1321 This returns a DateTime::Duration which only contains seconds and
1322 nanoseconds.
1323
1324 If we were add the duration to a different "DateTime" object we might
1325 get a different number of seconds.
1326
1327 DateTime::Duration supports three different end-of-month algorithms for
1328 adding months. This comes into play when an addition results in a day
1329 past the end of the following month (for example, adding one month to
1330 January 30).
1331
1332 # 2010-08-31 + 1 month = 2010-10-01
1333 $dt->add( months => 1, end_of_month => 'wrap' );
1334
1335 # 2010-01-30 + 1 month = 2010-02-28
1336 $dt->add( months => 1, end_of_month => 'limit' );
1337
1338 # 2010-04-30 + 1 month = 2010-05-31
1339 $dt->add( months => 1, end_of_month => 'preserve' );
1340
1341 By default, it uses "wrap" for positive durations and "preserve" for
1342 negative durations. See DateTime::Duration for a detailed explanation
1343 of these algorithms.
1344
1345 If you need to do lots of work with durations, take a look at the
1346 DateTime::Format::Duration module, which lets you present information
1347 from durations in many useful ways.
1348
1349 There are other subtract/delta methods in "DateTime" to generate
1350 different types of durations. These methods are
1351 "$dt->subtract_datetime", "$dt->subtract_datetime_absolute",
1352 "$dt->delta_md", "$dt->delta_days", and "$dt->delta_ms".
1353
1354 DateTime Subtraction
1355
1356 Date subtraction is done based solely on the two object's local
1357 datetimes, with one exception to handle DST changes. Also, if the two
1358 datetime objects are in different time zones, one of them is converted
1359 to the other's time zone first before subtraction. This is best
1360 explained through examples:
1361
1362 The first of these probably makes the most sense:
1363
1364 # not DST
1365 my $dt1 = DateTime->new(
1366 year => 2003,
1367 month => 5,
1368 day => 6,
1369 time_zone => 'America/Chicago',
1370 );
1371
1372 # is DST
1373 my $dt2 = DateTime->new(
1374 year => 2003,
1375 month => 11,
1376 day => 6,
1377 time_zone => 'America/Chicago',
1378 );
1379
1380 # 6 months
1381 my $dur = $dt2->subtract_datetime($dt1);
1382
1383 Nice and simple.
1384
1385 This one is a little trickier, but still fairly logical:
1386
1387 # is DST
1388 my $dt1 = DateTime->new(
1389 year => 2003,
1390 month => 4,
1391 day => 5,
1392 hour => 1,
1393 minute => 58,
1394 time_zone => "America/Chicago",
1395 );
1396
1397 # not DST
1398 my $dt2 = DateTime->new(
1399 year => 2003,
1400 month => 4,
1401 day => 7,
1402 hour => 2,
1403 minute => 1,
1404 time_zone => "America/Chicago",
1405 );
1406
1407 # 2 days and 3 minutes
1408 my $dur = $dt2->subtract_datetime($dt1);
1409
1410 Which contradicts the result this one gives, even though they both make
1411 sense:
1412
1413 # is DST
1414 my $dt1 = DateTime->new(
1415 year => 2003,
1416 month => 4,
1417 day => 5,
1418 hour => 1,
1419 minute => 58,
1420 time_zone => "America/Chicago",
1421 );
1422
1423 # not DST
1424 my $dt2 = DateTime->new(
1425 year => 2003,
1426 month => 4,
1427 day => 6,
1428 hour => 3,
1429 minute => 1,
1430 time_zone => "America/Chicago",
1431 );
1432
1433 # 1 day and 3 minutes
1434 my $dur = $dt2->subtract_datetime($dt1);
1435
1436 This last example illustrates the "DST" exception mentioned earlier.
1437 The exception accounts for the fact 2003-04-06 only lasts 23 hours.
1438
1439 And finally:
1440
1441 my $dt2 = DateTime->new(
1442 year => 2003,
1443 month => 10,
1444 day => 26,
1445 hour => 1,
1446 time_zone => 'America/Chicago',
1447 );
1448
1449 my $dt1 = $dt2->clone->subtract( hours => 1 );
1450
1451 # 60 minutes
1452 my $dur = $dt2->subtract_datetime($dt1);
1453
1454 This seems obvious until you realize that subtracting 60 minutes from
1455 $dt2 in the above example still leaves the clock time at "01:00:00".
1456 This time we are accounting for a 25 hour day.
1457
1458 Reversibility
1459
1460 Date math operations are not always reversible. This is because of the
1461 way that addition operations are ordered. As was discussed earlier,
1462 adding 1 day and 3 minutes in one call to "$dt->add" is not the same as
1463 first adding 3 minutes and 1 day in two separate calls.
1464
1465 If we take a duration returned from "$dt->subtract_datetime" and then
1466 try to add or subtract that duration from one of the datetimes we just
1467 used, we sometimes get interesting results:
1468
1469 my $dt1 = DateTime->new(
1470 year => 2003,
1471 month => 4,
1472 day => 5,
1473 hour => 1,
1474 minute => 58,
1475 time_zone => "America/Chicago",
1476 );
1477
1478 my $dt2 = DateTime->new(
1479 year => 2003,
1480 month => 4,
1481 day => 6,
1482 hour => 3,
1483 minute => 1,
1484 time_zone => "America/Chicago",
1485 );
1486
1487 # 1 day and 3 minutes
1488 my $dur = $dt2->subtract_datetime($dt1);
1489
1490 # gives us $dt2
1491 $dt1->add_duration($dur);
1492
1493 # gives us 2003-04-05 02:58:00 - 1 hour later than $dt1
1494 $dt2->subtract_duration($dur);
1495
1496 The "$dt->subtract_duration" operation gives us a (perhaps) unexpected
1497 answer because it first subtracts one day to get 2003-04-05T03:01:00
1498 and then subtracts 3 minutes to get the final result.
1499
1500 If we explicitly reverse the order we can get the original value of
1501 $dt1. This can be facilitated by the DateTime::Duration class's
1502 "$dur->calendar_duration" and "$dur->clock_duration" methods:
1503
1504 $dt2->subtract_duration( $dur->clock_duration )
1505 ->subtract_duration( $dur->calendar_duration );
1506
1507 Leap Seconds and Date Math
1508
1509 The presence of leap seconds can cause even more anomalies in date
1510 math. For example, the following is a legal datetime:
1511
1512 my $dt = DateTime->new(
1513 year => 1972,
1514 month => 12,
1515 day => 31,
1516 hour => 23,
1517 minute => 59,
1518 second => 60,
1519 time_zone => 'UTC'
1520 );
1521
1522 If we add one month ...
1523
1524 $dt->add( months => 1 );
1525
1526 ... the datetime is now "1973-02-01 00:00:00", because there is no
1527 23:59:60 on 1973-01-31.
1528
1529 Leap seconds also force us to distinguish between minutes and seconds
1530 during date math. Given the following datetime ...
1531
1532 my $dt = DateTime->new(
1533 year => 1972,
1534 month => 12,
1535 day => 31,
1536 hour => 23,
1537 minute => 59,
1538 second => 30,
1539 time_zone => 'UTC'
1540 );
1541
1542 ... we will get different results when adding 1 minute than we get if
1543 we add 60 seconds. This is because in this case, the last minute of the
1544 day, beginning at 23:59:00, actually contains 61 seconds.
1545
1546 Here are the results we get:
1547
1548 # 1972-12-31 23:59:30 - our starting datetime
1549 my $dt = DateTime->new(
1550 year => 1972,
1551 month => 12,
1552 day => 31,
1553 hour => 23,
1554 minute => 59,
1555 second => 30,
1556 time_zone => 'UTC'
1557 );
1558
1559 # 1973-01-01 00:00:30 - one minute later
1560 $dt->clone->add( minutes => 1 );
1561
1562 # 1973-01-01 00:00:29 - 60 seconds later
1563 $dt->clone->add( seconds => 60 );
1564
1565 # 1973-01-01 00:00:30 - 61 seconds later
1566 $dt->clone->add( seconds => 61 );
1567
1568 Local vs. UTC and 24 hours vs. 1 day
1569
1570 When math crosses a daylight saving boundary, a single day may have
1571 more or less than 24 hours.
1572
1573 For example, if you do this ...
1574
1575 my $dt = DateTime->new(
1576 year => 2003,
1577 month => 4,
1578 day => 5,
1579 hour => 2,
1580 time_zone => 'America/Chicago',
1581 );
1582
1583 $dt->add( days => 1 );
1584
1585 ... then you will produce an invalid local time, and therefore an
1586 exception will be thrown.
1587
1588 However, this works ...
1589
1590 my $dt = DateTime->new(
1591 year => 2003,
1592 month => 4,
1593 day => 5,
1594 hour => 2,
1595 time_zone => 'America/Chicago',
1596 );
1597
1598 $dt->add( hours => 24 );
1599
1600 ... and produces a datetime with the local time of "03:00".
1601
1602 If all this makes your head hurt, there is a simple alternative. Just
1603 convert your datetime object to the "UTC" time zone before doing date
1604 math on it, and switch it back to the local time zone afterwards. This
1605 avoids the possibility of having date math throw an exception, and
1606 makes sure that 1 day equals 24 hours. Of course, this may not always
1607 be desirable, so caveat user!
1608
1609 Overloading
1610 This module explicitly overloads the addition (+), subtraction (-),
1611 string and numeric comparison operators. This means that the following
1612 all do sensible things:
1613
1614 my $new_dt = $dt + $duration_obj;
1615
1616 my $new_dt = $dt - $duration_obj;
1617
1618 my $duration_obj = $dt - $new_dt;
1619
1620 for my $dt ( sort @dts ) {...}
1621
1622 Additionally, the fallback parameter is set to true, so other derivable
1623 operators (+=, -=, etc.) will work properly. Do not expect increment
1624 (++) or decrement (--) to do anything useful.
1625
1626 The string comparison operators, "eq" or "ne", will use the string
1627 value to compare with non-DateTime objects.
1628
1629 DateTime objects do not have a numeric value, using "==" or "<=>" to
1630 compare a DateTime object with a non-DateTime object will result in an
1631 exception. To safely sort mixed DateTime and non-DateTime objects, use
1632 "sort { $a cmp $b } @dates".
1633
1634 The module also overloads stringification using the object's formatter,
1635 defaulting to "iso8601" method. See "Formatters And Stringification"
1636 for details.
1637
1638 Formatters And Stringification
1639 You can optionally specify a "formatter", which is usually a
1640 "DateTime::Format::*" object or class, to control the stringification
1641 of the DateTime object.
1642
1643 Any of the constructor methods can accept a formatter argument:
1644
1645 my $formatter = DateTime::Format::Strptime->new(...);
1646 my $dt = DateTime->new( year => 2004, formatter => $formatter );
1647
1648 Or, you can set it afterwards:
1649
1650 $dt->set_formatter($formatter);
1651 $formatter = $dt->formatter;
1652
1653 Once you set the formatter, the overloaded stringification method will
1654 use the formatter. If unspecified, the "iso8601" method is used.
1655
1656 A formatter can be handy when you know that in your application you
1657 want to stringify your DateTime objects into a special format all the
1658 time, for example in Postgres format.
1659
1660 If you provide a formatter class name or object, it must implement a
1661 "format_datetime" method. This method will be called with just the
1662 "DateTime" object as its argument.
1663
1664 CLDR Patterns
1665 The CLDR pattern language is both more powerful and more complex than
1666 strftime. Unlike strftime patterns, you often have to explicitly
1667 escape text that you do not want formatted, as the patterns are simply
1668 letters without any prefix.
1669
1670 For example, "yyyy-MM-dd" is a valid CLDR pattern. If you want to
1671 include any lower or upper case ASCII characters as-is, you can
1672 surround them with single quotes ('). If you want to include a single
1673 quote, you must escape it as two single quotes ('').
1674
1675 my $pattern1 = q{'Today is ' EEEE};
1676 my $pattern2 = q{'It is now' h 'o''clock' a};
1677
1678 Spaces and any non-letter text will always be passed through as-is.
1679
1680 Many CLDR patterns which produce numbers will pad the number with
1681 leading zeroes depending on the length of the format specifier. For
1682 example, "h" represents the current hour from 1-12. If you specify "hh"
1683 then hours 1-9 will have a leading zero prepended.
1684
1685 However, CLDR often uses five of a letter to represent the narrow form
1686 of a pattern. This inconsistency is necessary for backwards
1687 compatibility.
1688
1689 There are many cases where CLDR patterns distinguish between the
1690 "format" and "stand-alone" forms of a pattern. The format pattern is
1691 used when the thing in question is being placed into a larger string.
1692 The stand-alone form is used when displaying that item by itself, for
1693 example in a calendar.
1694
1695 There are also many cases where CLDR provides three sizes for each
1696 item, wide (the full name), abbreviated, and narrow. The narrow form is
1697 often just a single character, for example "T" for "Tuesday", and may
1698 not be unique.
1699
1700 CLDR provides a fairly complex system for localizing time zones that we
1701 ignore entirely. The time zone patterns just use the information
1702 provided by "DateTime::TimeZone", and do not follow the CLDR spec.
1703
1704 The output of a CLDR pattern is always localized, when applicable.
1705
1706 CLDR provides the following patterns:
1707
1708 • G{1,3}
1709
1710 The abbreviated era (BC, AD).
1711
1712 • GGGG
1713
1714 The wide era (Before Christ, Anno Domini).
1715
1716 • GGGGG
1717
1718 The narrow era, if it exists (but it mostly doesn't).
1719
1720 • y and y{3,}
1721
1722 The year, zero-prefixed as needed. Negative years will start with a
1723 "-", and this will be included in the length calculation.
1724
1725 In other, words the "yyyyy" pattern will format year -1234 as
1726 "-1234", not "-01234".
1727
1728 • yy
1729
1730 This is a special case. It always produces a two-digit year, so
1731 "1976" becomes "76". Negative years will start with a "-", making
1732 them one character longer.
1733
1734 • Y{1,}
1735
1736 The year in "week of the year" calendars, from "$dt->week_year".
1737
1738 • u{1,}
1739
1740 Same as "y" except that "uu" is not a special case.
1741
1742 • Q{1,2}
1743
1744 The quarter as a number (1..4).
1745
1746 • QQQ
1747
1748 The abbreviated format form for the quarter.
1749
1750 • QQQQ
1751
1752 The wide format form for the quarter.
1753
1754 • q{1,2}
1755
1756 The quarter as a number (1..4).
1757
1758 • qqq
1759
1760 The abbreviated stand-alone form for the quarter.
1761
1762 • qqqq
1763
1764 The wide stand-alone form for the quarter.
1765
1766 • M{1,2}
1767
1768 The numerical month.
1769
1770 • MMM
1771
1772 The abbreviated format form for the month.
1773
1774 • MMMM
1775
1776 The wide format form for the month.
1777
1778 • MMMMM
1779
1780 The narrow format form for the month.
1781
1782 • L{1,2}
1783
1784 The numerical month.
1785
1786 • LLL
1787
1788 The abbreviated stand-alone form for the month.
1789
1790 • LLLL
1791
1792 The wide stand-alone form for the month.
1793
1794 • LLLLL
1795
1796 The narrow stand-alone form for the month.
1797
1798 • w{1,2}
1799
1800 The week of the year, from "$dt->week_number".
1801
1802 • W
1803
1804 The week of the month, from "$dt->week_of_month".
1805
1806 • d{1,2}
1807
1808 The numeric day of the month.
1809
1810 • D{1,3}
1811
1812 The numeric day of the year.
1813
1814 • F
1815
1816 The day of the week in the month, from "$dt->weekday_of_month".
1817
1818 • g{1,}
1819
1820 The modified Julian day, from "$dt->mjd".
1821
1822 • E{1,3} and eee
1823
1824 The abbreviated format form for the day of the week.
1825
1826 • EEEE and eeee
1827
1828 The wide format form for the day of the week.
1829
1830 • EEEEE and eeeee
1831
1832 The narrow format form for the day of the week.
1833
1834 • e{1,2}
1835
1836 The local numeric day of the week, from 1 to 7. This number depends
1837 on what day is considered the first day of the week, which varies
1838 by locale. For example, in the US, Sunday is the first day of the
1839 week, so this returns 2 for Monday.
1840
1841 • c
1842
1843 The numeric day of the week from 1 to 7, treating Monday as the
1844 first of the week, regardless of locale.
1845
1846 • ccc
1847
1848 The abbreviated stand-alone form for the day of the week.
1849
1850 • cccc
1851
1852 The wide stand-alone form for the day of the week.
1853
1854 • ccccc
1855
1856 The narrow format form for the day of the week.
1857
1858 • a
1859
1860 The localized form of AM or PM for the time.
1861
1862 • h{1,2}
1863
1864 The hour from 1-12.
1865
1866 • H{1,2}
1867
1868 The hour from 0-23.
1869
1870 • K{1,2}
1871
1872 The hour from 0-11.
1873
1874 • k{1,2}
1875
1876 The hour from 1-24.
1877
1878 • j{1,2}
1879
1880 The hour, in 12 or 24 hour form, based on the preferred form for
1881 the locale. In other words, this is equivalent to either "h{1,2}"
1882 or "H{1,2}".
1883
1884 • m{1,2}
1885
1886 The minute.
1887
1888 • s{1,2}
1889
1890 The second.
1891
1892 • S{1,}
1893
1894 The fractional portion of the seconds, rounded based on the length
1895 of the specifier. This returned without a leading decimal point,
1896 but may have leading or trailing zeroes.
1897
1898 • A{1,}
1899
1900 The millisecond of the day, based on the current time. In other
1901 words, if it is 12:00:00.00, this returns 43200000.
1902
1903 • z{1,3}
1904
1905 The time zone short name.
1906
1907 • zzzz
1908
1909 The time zone long name.
1910
1911 • Z{1,3}
1912
1913 The time zone offset.
1914
1915 • ZZZZ
1916
1917 The time zone short name and the offset as one string, so something
1918 like "CDT-0500".
1919
1920 • ZZZZZ
1921
1922 The time zone offset as a sexagesimal number, so something like
1923 "-05:00". (This is useful for W3C format.)
1924
1925 • v{1,3}
1926
1927 The time zone short name.
1928
1929 • vvvv
1930
1931 The time zone long name.
1932
1933 • V{1,3}
1934
1935 The time zone short name.
1936
1937 • VVVV
1938
1939 The time zone long name.
1940
1941 CLDR "Available Formats"
1942
1943 The CLDR data includes pre-defined formats for various patterns such as
1944 "month and day" or "time of day". Using these formats lets you render
1945 information about a datetime in the most natural way for users from a
1946 given locale.
1947
1948 These formats are indexed by a key that is itself a CLDR pattern. When
1949 you look these up, you get back a different CLDR pattern suitable for
1950 the locale.
1951
1952 Let's look at some example We'll use "2008-02-05T18:30:30" as our
1953 example datetime value, and see how this is rendered for the "en-US"
1954 and "fr-FR" locales.
1955
1956 • "MMMd"
1957
1958 The abbreviated month and day as number. For "en-US", we get the
1959 pattern "MMM d", which renders as "Feb 5". For "fr-FR", we get the
1960 pattern "d MMM", which renders as "5 févr.".
1961
1962 • "yQQQ"
1963
1964 The year and abbreviated quarter of year. For "en-US", we get the
1965 pattern "QQQ y", which renders as "Q1 2008". For "fr-FR", we get
1966 the same pattern, "QQQ y", which renders as "T1 2008".
1967
1968 • "hm"
1969
1970 The 12-hour time of day without seconds. For "en-US", we get the
1971 pattern "h:mm a", which renders as "6:30 PM". For "fr-FR", we get
1972 the exact same pattern and rendering.
1973
1974 The available formats for each locale are documented in the POD for
1975 that locale. To get back the format, you use the "$locale->format_for"
1976 method. For example:
1977
1978 say $dt->format_cldr( $dt->locale->format_for('MMMd') );
1979
1980 strftime Patterns
1981 The following patterns are allowed in the format string given to the
1982 "$dt->strftime" method:
1983
1984 • %a
1985
1986 The abbreviated weekday name.
1987
1988 • %A
1989
1990 The full weekday name.
1991
1992 • %b
1993
1994 The abbreviated month name.
1995
1996 • %B
1997
1998 The full month name.
1999
2000 • %c
2001
2002 The default datetime format for the object's locale.
2003
2004 • %C
2005
2006 The century number (year/100) as a 2-digit integer.
2007
2008 • %d
2009
2010 The day of the month as a decimal number (range 01 to 31).
2011
2012 • %D
2013
2014 Equivalent to %m/%d/%y. This is not a good standard format if you
2015 want folks from both the United States and the rest of the world to
2016 understand the date!
2017
2018 • %e
2019
2020 Like %d, the day of the month as a decimal number, but a leading
2021 zero is replaced by a space.
2022
2023 • %F
2024
2025 Equivalent to %Y-%m-%d (the ISO 8601 date format)
2026
2027 • %G
2028
2029 The ISO 8601 year with century as a decimal number. The 4-digit
2030 year corresponding to the ISO week number (see %V). This has the
2031 same format and value as %Y, except that if the ISO week number
2032 belongs to the previous or next year, that year is used instead.
2033 (TZ)
2034
2035 • %g
2036
2037 Like %G, but without century, i.e., with a 2-digit year (00-99).
2038
2039 • %h
2040
2041 Equivalent to %b.
2042
2043 • %H
2044
2045 The hour as a decimal number using a 24-hour clock (range 00 to
2046 23).
2047
2048 • %I
2049
2050 The hour as a decimal number using a 12-hour clock (range 01 to
2051 12).
2052
2053 • %j
2054
2055 The day of the year as a decimal number (range 001 to 366).
2056
2057 • %k
2058
2059 The hour (24-hour clock) as a decimal number (range 0 to 23);
2060 single digits are preceded by a blank. (See also %H.)
2061
2062 • %l
2063
2064 The hour (12-hour clock) as a decimal number (range 1 to 12);
2065 single digits are preceded by a blank. (See also %I.)
2066
2067 • %m
2068
2069 The month as a decimal number (range 01 to 12).
2070
2071 • %M
2072
2073 The minute as a decimal number (range 00 to 59).
2074
2075 • %n
2076
2077 A newline character.
2078
2079 • %N
2080
2081 The fractional seconds digits. Default is 9 digits (nanoseconds).
2082
2083 %3N milliseconds (3 digits)
2084 %6N microseconds (6 digits)
2085 %9N nanoseconds (9 digits)
2086
2087 This value will always be rounded down to the nearest integer.
2088
2089 • %p
2090
2091 Either `AM' or `PM' according to the given time value, or the
2092 corresponding strings for the current locale. Noon is treated as
2093 `pm' and midnight as `am'.
2094
2095 • %P
2096
2097 Like %p but in lowercase: `am' or `pm' or a corresponding string
2098 for the current locale.
2099
2100 • %r
2101
2102 The time in a.m. or p.m. notation. In the POSIX locale this is
2103 equivalent to `%I:%M:%S %p'.
2104
2105 • %R
2106
2107 The time in 24-hour notation (%H:%M). (SU) For a version including
2108 the seconds, see %T below.
2109
2110 • %s
2111
2112 The number of seconds since the epoch.
2113
2114 • %S
2115
2116 The second as a decimal number (range 00 to 61).
2117
2118 • %t
2119
2120 A tab character.
2121
2122 • %T
2123
2124 The time in 24-hour notation (%H:%M:%S).
2125
2126 • %u
2127
2128 The day of the week as a decimal, range 1 to 7, Monday being 1. See
2129 also %w.
2130
2131 • %U
2132
2133 The week number of the current year as a decimal number, range 00
2134 to 53, starting with the first Sunday as the first day of week 01.
2135 See also %V and %W.
2136
2137 • %V
2138
2139 The ISO 8601:1988 week number of the current year as a decimal
2140 number, range 01 to 53, where week 1 is the first week that has at
2141 least 4 days in the current year, and with Monday as the first day
2142 of the week. See also %U and %W.
2143
2144 • %w
2145
2146 The day of the week as a decimal, range 0 to 6, Sunday being 0. See
2147 also %u.
2148
2149 • %W
2150
2151 The week number of the current year as a decimal number, range 00
2152 to 53, starting with the first Monday as the first day of week 01.
2153
2154 • %x
2155
2156 The default date format for the object's locale.
2157
2158 • %X
2159
2160 The default time format for the object's locale.
2161
2162 • %y
2163
2164 The year as a decimal number without a century (range 00 to 99).
2165
2166 • %Y
2167
2168 The year as a decimal number including the century.
2169
2170 • %z
2171
2172 The time-zone as hour offset from UTC. Required to emit
2173 RFC822-conformant dates (using "%a, %d %b %Y %H:%M:%S %z").
2174
2175 • %Z
2176
2177 The short name for the time zone, typically an abbreviation like
2178 "EST" or "AEST".
2179
2180 • %%
2181
2182 A literal `%' character.
2183
2184 • %{method}
2185
2186 Any method name may be specified using the format "%{method}" name
2187 where "method" is a valid "DateTime" object method.
2188
2189 DateTime and Storable
2190 "DateTime" implements Storable hooks in order to reduce the size of a
2191 serialized "DateTime" object.
2192
2194 If you're working on the "DateTIme" code base, there are a few extra
2195 non-Perl tools that you may find useful, notably precious
2196 <https://github.com/houseabsolute/precious>, a meta-linter/tidier. You
2197 can install all the necessary tools in "$HOME/bin" by running
2198 ./dev-bin/install-dev-tools.sh.
2199
2200 Try running "precious tidy -a" to tidy all the tidyable files in the
2201 repo, and "precious lint -a" to run all the lint checks.
2202
2203 You can enable a git pre-commit hook for linting by running
2204 ./git/setup.pl.
2205
2206 Note that linting will be checked in CI, and it's okay to submit a PR
2207 which fails the linting check, but it's extra nice to fix these
2208 yourself.
2209
2211 This module is part of a larger ecosystem of modules in the DateTime
2212 family.
2213
2214 DateTime::Set
2215 The DateTime::Set module represents sets (including recurrences) of
2216 datetimes. Many modules return sets or recurrences.
2217
2218 Format Modules
2219 The various format modules exist to parse and format datetimes. For
2220 example, DateTime::Format::HTTP parses dates according to the RFC 1123
2221 format:
2222
2223 my $datetime
2224 = DateTime::Format::HTTP->parse_datetime(
2225 'Thu Feb 3 17:03:55 GMT 1994');
2226
2227 print DateTime::Format::HTTP->format_datetime($datetime);
2228
2229 Most format modules are suitable for use as a "formatter" with a
2230 DateTime object.
2231
2232 All format modules start with DateTime::Format::
2233 <https://metacpan.org/search?q=datetime%3A%3Aformat>.
2234
2235 Calendar Modules
2236 There are a number of modules on CPAN that implement non-Gregorian
2237 calendars, such as the Chinese, Mayan, and Julian calendars.
2238
2239 All calendar modules start with DateTime::Calendar::
2240 <https://metacpan.org/search?q=datetime%3A%3Acalendar>.
2241
2242 Event Modules
2243 There are a number of modules that calculate the dates for events, such
2244 as Easter, Sunrise, etc.
2245
2246 All event modules start with DateTime::Event::
2247 <https://metacpan.org/search?q=datetime%3A%3Aevent>.
2248
2249 Others
2250 There are many other modules that work with DateTime, including modules
2251 in the DateTimeX namespace <https://metacpan.org/search?q=datetimex>
2252 namespace, as well as others.
2253
2254 See MetaCPAN <https://metacpan.org/search?q=datetime> for more modules.
2255
2257 The tests in 20infinite.t seem to fail on some machines, particularly
2258 on Win32. This appears to be related to Perl's internal handling of
2259 IEEE infinity and NaN, and seems to be highly platform/compiler/phase
2260 of moon dependent.
2261
2262 If you don't plan to use infinite datetimes you can probably ignore
2263 this. This will be fixed (perhaps) in future versions.
2264
2266 A Date with Perl <http://presentations.houseabsolute.com/a-date-with-
2267 perl/> - a talk I've given at a few YAPCs.
2268
2269 datetime@perl.org mailing list
2270 <http://lists.perl.org/list/datetime.html>
2271
2273 Bugs may be submitted at
2274 <https://github.com/houseabsolute/DateTime.pm/issues>.
2275
2276 There is a mailing list available for users of this distribution,
2277 <mailto:datetime@perl.org>.
2278
2280 The source code repository for DateTime can be found at
2281 <https://github.com/houseabsolute/DateTime.pm>.
2282
2284 If you'd like to thank me for the work I've done on this module, please
2285 consider making a "donation" to me via PayPal. I spend a lot of free
2286 time creating free software, and would appreciate any support you'd
2287 care to offer.
2288
2289 Please note that I am not suggesting that you must do this in order for
2290 me to continue working on this particular software. I will continue to
2291 do so, inasmuch as I have in the past, for as long as it interests me.
2292
2293 Similarly, a donation made in this way will probably not make me work
2294 on this software much more, unless I get so many donations that I can
2295 consider working on free software full time (let's all have a chuckle
2296 at that together).
2297
2298 To donate, log into PayPal and send money to autarch@urth.org, or use
2299 the button at <https://houseabsolute.com/foss-donations/>.
2300
2302 Dave Rolsky <autarch@urth.org>
2303
2305 • Ben Bennett <fiji@limey.net>
2306
2307 • Christian Hansen <chansen@cpan.org>
2308
2309 • Daisuke Maki <dmaki@cpan.org>
2310
2311 • Dan Book <grinnz@gmail.com>
2312
2313 • Dan Stewart <danielandrewstewart@gmail.com>
2314
2315 • David Dyck <david.dyck@checksum.com>
2316
2317 • David E. Wheeler <david@justatheory.com>
2318
2319 • David Precious <davidp@preshweb.co.uk>
2320
2321 • Doug Bell <madcityzen@gmail.com>
2322
2323 • Flávio Soibelmann Glock <fglock@gmail.com>
2324
2325 • Gianni Ceccarelli <gianni.ceccarelli@broadbean.com>
2326
2327 • Gregory Oschwald <oschwald@gmail.com>
2328
2329 • Hauke D <haukex@zero-g.net>
2330
2331 • Iain Truskett <deceased>
2332
2333 • James Raspass <jraspass@gmail.com>
2334
2335 • Jason McIntosh <jmac@jmac.org>
2336
2337 • Joshua Hoblitt <jhoblitt@cpan.org>
2338
2339 • Karen Etheridge <ether@cpan.org>
2340
2341 • Mark Overmeer <mark@overmeer.net>
2342
2343 • Michael Conrad <mike@nrdvana.net>
2344
2345 • Michael R. Davis <mrdvt92@users.noreply.github.com>
2346
2347 • Mohammad S Anwar <mohammad.anwar@yahoo.com>
2348
2349 • M Somerville <dracos@users.noreply.github.com>
2350
2351 • Nick Tonkin <1nickt@users.noreply.github.com>
2352
2353 • Olaf Alders <olaf@wundersolutions.com>
2354
2355 • Ovid <curtis_ovid_poe@yahoo.com>
2356
2357 • Paul Howarth <paul@city-fan.org>
2358
2359 • Philippe Bruhat (BooK) <book@cpan.org>
2360
2361 • philip r brenan <philiprbrenan@gmail.com>
2362
2363 • Ricardo Signes <rjbs@cpan.org>
2364
2365 • Richard Bowen <bowen@cpan.org>
2366
2367 • Ron Hill <rkhill@cpan.org>
2368
2369 • Sam Kington <github@illuminated.co.uk>
2370
2371 • viviparous <viviparous@prc>
2372
2374 This software is Copyright (c) 2003 - 2022 by Dave Rolsky.
2375
2376 This is free software, licensed under:
2377
2378 The Artistic License 2.0 (GPL Compatible)
2379
2380 The full text of the license can be found in the LICENSE file included
2381 with this distribution.
2382
2383
2384
2385perl v5.36.0 2022-10-24 DateTime(3)