Debian Codegraph @

lib/Date/Manip/Changes5to6.pod

raw
1 # Copyright (c) 2008-2026 Sullivan Beck. All rights reserved.
2 # This program is free software; you can redistribute it and/or modify it
3 # under the same terms as Perl itself.
4
5 =pod
6
7 =head1 NAME
8
9 Date::Manip::Changes5to6 - describes differences between 5.xx and 6.00
10
11 =head1 SYNOPSIS
12
13 Date::Manip 6.00 represents a complete rethink and rewrite of
14 Date::Manip. A great deal of effort was made to make sure that 6.00
15 is almost backwards compatible with 5.xx whenever feasible, but some
16 functionality has changed in backwards incompatible ways. Other parts
17 have been deprecated and will be removed at some point in the future.
18
19 This document describes the differences between the 5.xx series and
20 version 6.00. This page primarily describes technical details, most of
21 which do not impact how Date::Manip is used in scripts. If you want to
22 make sure that a script which ran with 5.xx will run with 6.xx, refer
23 to the Date::Manip::Migration5to6 document.
24
25 =head1 OVERVIEW
26
27 The Date::Manip 5.xx series of suffered from several weaknesses. These
28 included:
29
30 =over 4
31
32 =item B<Poor time zone support>
33
34 Time zone support in 5.xx was broken. Determining a time zone, and
35 understanding daylight saving time changes was incomplete (at best)
36 and totally inadequate to do true timezone operations.
37
38 =item B<Parsing too complicated and unstructured>
39
40 The parsing routines had grown very complicated, and overly permissive
41 over time and were in need of a complete overhaul.
42
43 =item B<Lacking OO model>
44
45 Date::Manip 5.xx was written as a functional module, not an OO module,
46 but date handling would lend itself very well to being OO with different
47 classes to handle dates, deltas, and recurrences.
48
49 The OO model allows a lot of information to be stored with each date
50 (such as time zone information) which is discarded in the functional
51 interface.
52
53 =item B<Too monolithic>
54
55 The entire Date::Manip module was contained in one huge file. Breaking
56 up the module would make it much easier to deal with.
57
58 =back
59
60 Date::Manip 6.00 is a complete rewrite of Date::Manip to address these
61 and other issues.
62
63 The following sections address how Date::Manip 6.00 differs from previous
64 releases, and describes changes that might need to be made to your script
65 in order to upgrade from 5.xx to 6.00.
66
67 The most important changes are marked with asterisks.
68
69 =head1 GENERAL CHANGES
70
71 =over 4
72
73 =item B<(*) Requires perl 5.10.0>
74
75 Please see the Date::Manip::Problems document for a discussion of
76 this problem. It's in the KNOWN COMPLAINTS section.
77
78 =item B<(*) Breaking into smaller modules>
79
80 Date::Manip module has been broken up from one huge module into a
81 large number of smaller more manageable modules. The main Date::Manip
82 module is still present, and contains all of the functions from
83 Date::Manip 5.xx (except that they now call functions from all the
84 other modules to do the actual work). In general, the Date::Manip
85 module from 6.00 is backwards compatible.
86
87 A number of new modules have been created as well. These can be used
88 directly, bypassing the main Date::Manip module. These include the
89 following:
90
91 Date::Manip::Base contains many basic date operations which may be
92 used to do simple date manipulation tasks without all the overhead of
93 the full Date::Manip module.
94
95 Date::Manip::TZ contains time zone operations.
96
97 Handling dates, deltas, and recurrences are now done in
98 Date::Manip::Date, Date::Manip::Delta, and Date::Manip::Recur.
99
100 All of these modules are object oriented, and are designed to be used
101 directly, so if you prefer an OO interface over a functional
102 interface, use these modules.
103
104 =item B<(*) Intermediate data cached>
105
106 In order to improve the performance of Date::Manip, many intermediate
107 values are cached. This does impact the memory footprint of the module,
108 but it has a huge impact on the performance of the module.
109
110 Some types of data depend on the config variables used, and these
111 are cached separately, and this cache is automatically cleared every
112 time a config variable is set. As a result, it is best if you set
113 all config variables at the start, and then leave them alone completely
114 to get optimal use of cached data.
115
116 A side effect of all this is that the Memoize module should not be used
117 in conjunction with Date::Manip.
118
119 In the version 5.xx documentation, it was mentioned that the Memoize
120 module might be used to improve performance in some cases. This is no
121 longer the case. It should not be used with Date::Manip, even if you
122 use the functional interface instead of the OO interface.
123
124 =item B<Taint safe>
125
126 Date::Manip now contains no tainted data, and should run without problems
127 with taint checking on provided you do not set additional methods for
128 determining the system time zone using the curr_zone_methods function.
129
130 Ideally, this should never be necessary. If it is necessary, I'd like to
131 hear about it so that I can add whatever standard methods are needed
132 to the built in list.
133
134 =back
135
136 =head1 TIME ZONE SUPPORT
137
138 =over 4
139
140 =item B<(*) Complete handling of time zones>
141
142 The biggest problem with Date::Manip 5.xx was it's inability to
143 correctly handle time zones and Daylight Saving Time. That is now
144 fixed. Version 6.00 includes support for every time zone included in
145 the zoneinfo (aka Olson) database which includes the definitions of
146 (hopefully) all of the time zones used in the world.
147
148 =item B<Individual time zones will no longer be added>
149
150 Prior to 5.55, time zones were added upon request. Since 6.00 now
151 supports a full set of standard time zones, I will no longer add in
152 individual time zones (Date::Manip::TZ includes functionality for
153 adding them yourself if they are needed). With Date::Manip now having
154 full time zone support, I'm not interested in supporting my own
155 time zone database.
156
157 However, I am interested in adding sets of time zones from various
158 "standards".
159
160 Date::Manip 6.00 includes time zones from the following standards:
161
162 Olson zoneinfo database
163 all Microsoft Windows time zones
164 zones listed in RFC-822
165
166 If there are additional standards that include additional time zones
167 not included here, please point me to them so they can be added.
168 This could include published lists of time zone names supported on
169 some operating system which have different names than the zoneinfo
170 list.
171
172 =item B<Nonstandard time zone abbreviations removed>
173
174 Some of the individual standards that were added in the 5.xx series
175 are not included in any of the standards listed above.
176
177 As of 6.00, only time zones from standards will be included in the
178 distribution (others can be added by users using the functions
179 described in Date::Manip::TZ to add aliases for existing time zones).
180
181 The following time zones were in Date::Manip 5.xx but not in 6.00.
182
183 IDLW -1200 International Date Line West
184 NT -1100 Nome
185 SAT -0400 Chile
186 CLDT -0300 Chile Daylight
187 AT -0200 Azores
188 MEWT +0100 Middle European Winter
189 MEZ +0100 Middle European
190 FWT +0100 French Winter
191 GB +0100 GMT with daylight saving
192 SWT +0100 Swedish Winter
193 MESZ +0200 Middle European Summer
194 FST +0200 French Summer
195 METDST +0200 An alias for MEST used by HP-UX
196 EETDST +0300 An alias for eest used by HP-UX
197 EETEDT +0300 Eastern Europe, USSR Zone 1
198 BT +0300 Baghdad, USSR Zone 2
199 IT +0330 Iran
200 ZP4 +0400 USSR Zone 3
201 ZP5 +0500 USSR Zone 4
202 IST +0530 Indian Standard
203 ZP6 +0600 USSR Zone 5
204 AWST +0800 Australian Western Standard
205 ROK +0900 Republic of Korea
206 AEST +1000 Australian Eastern Standard
207 ACDT +1030 Australian Central Daylight
208 CADT +1030 Central Australian Daylight
209 AEDT +1100 Australian Eastern Daylight
210 EADT +1100 Eastern Australian Daylight
211 NZT +1200 New Zealand
212 IDLE +1200 International Date Line East
213
214 =item B<A lot of support modules and files>
215
216 Date::Manip now includes a large number of files and modules that
217 are used to support time zones.
218
219 A series of modules are included which are auto-generated from the
220 zoneinfo database. The Date::Manip::Zones, Date::Manip::TZ::*, and
221 Date::Manip::Offset::* modules are all automatically generated and are
222 not intended to be used directly. Instead, the Date::Manip::TZ module
223 is used to access the data stored there.
224
225 A separate time zone module (Date::Manip::TZ::*) is included for every
226 single time zone. There is also a module (Date::Manip::Offset::*) for
227 every different offset. All told, there are almost 1000 modules.
228 These are included to make time zone handling more efficient. Rather
229 than calculating everything on the fly, information about each
230 time zone and offset are included here which greatly speeds up the
231 handling of time zones. These modules are only loaded as needed
232 (i.e. only the modules related to the specific time zones you refer to
233 are ever loaded), so there is no performance penalty to having them.
234
235 Also included in the distribution are a script (tzdata) and additional
236 module (Date::Manip::TZdata). These are used to automatically
237 generate the time zone modules, and are of no use to anyone other
238 than the maintainer of Date::Manip. They are included solely for the
239 sake of completeness. If someone wanted to fork Date::Manip, all
240 the tools necessary to do so are included in the distribution.
241
242 =item B<(*) Meaning of $::TZ and $ENV{TZ}>
243
244 In Date::Manip 5.x, you could specify what time zone you wanted to work
245 in using either the $::TZ or $ENV{TZ} variables.
246
247 Date::Manip 6.00 makes use of two different time zones: the actual
248 local time zone the computer is running in (and which is used by the
249 system clock), and a time zone that you want to work in. Typically,
250 these are the same, but they do not have to be.
251
252 As of Date::Manip 6.00, the $::TZ and $ENV{TZ} variables are used only
253 to specify the actual local time zone.
254
255 In order to specify an alternate time zone to work in, use the
256 SetDate or ForceDate config variables.
257
258 =back
259
260 =head1 CONFIG FILES AND VARIABLES
261
262 =over 4
263
264 =item B<(*) Date_Init handling of config variables>
265
266 The handling of config variables has changed slightly.
267
268 Previously, variables passed in to Date_Init overrode values from
269 config files. This has changed slightly. Options to Date_Init are
270 now parsed in the order they are listed, so the following:
271
272 Date_Init("DateFormat=Other","ConfigFile=DateManip.cnf")
273
274 would first set the DateFormat variable, and then it would read
275 the config file "DateManip.cnf". If that config file included
276 a DateFormat definition, it would override the one passed in to
277 Date_Init.
278
279 The proper way to override config files is to pass the config files
280 in first, followed by any script-specific overrides. In other
281 words:
282
283 Date_Init("ConfigFile=DateManip.cnf","DateFormat=Other")
284
285 =item B<Date_Init doesn't return the config variables>
286
287 In Date::Manip::5.xx, Date_Init could return the list of all
288 config variables. This functionality is no longer supported.
289 Date_Init is used strictly to set config variables.
290
291 =item B<(*) Config file options>
292
293 Date::Manip 5.xx had the concept of a global and personal config
294 file. In addition, the personal config file could be looked for
295 in a path of directories. All this was specified using the
296 config variables:
297
298 GlobalCnf
299 IgnoreGlobalCnf
300 PersonalCnf
301 PersonalCnfPath
302 PathSep
303
304 All of these have been removed. Instead, the single config variable:
305
306 ConfigFile
307
308 will be used to specify config files (with no distinction between a
309 global and personal config file). Also, no path searching is
310 done. Each must be specified by a complete path. Finally, any number
311 of config files can be used. So the following is valid:
312
313 Date_Init("ConfigFile=./Manip.cnf","ConfigFile=/tmp/Manip.cnf")
314
315 =item B<Other config variables removed>
316
317 The following config variables have been removed.
318
319 TodayIsMidnight Use DefaultTime instead.
320
321 ConvTZ Use SetDate or ForceDate instead.
322
323 Internal Use Printable instead.
324
325 DeltaSigns Use the Date::Manip::Delta::printf
326 method to print deltas
327
328 UpdateCurrTZ With real time zone handling in
329 place, this is no longer necessary
330
331 IntCharSet This has been replaced with better support for
332 international character sets. The Encoding config
333 variable may be used instead.
334
335 =item B<Other config variables deprecated>
336
337 The following config variables are deprecated and will be removed
338 in some future version:
339
340 TZ Use SetDate or ForceDate instead.
341
342 =item B<Holidays>
343
344 Previously, holidays could be defined as a "Date + Delta" or "Date -
345 Delta" string. These predate recurrences, and introduce some complexity
346 into the handling of holidays. Since recurrences are a much better
347 way to define holidays, the "Date + Delta" and "Date - Delta" strings
348 are no longer supported.
349
350 =item B<TZ replaced (and enhanced)>
351
352 The SetDate and ForceDate variables (which include the functionality
353 of the deprecated TZ variable) are much improved as described in the
354 Date::Manip::Config documentation.
355
356 Since it is now handles time change correctly (allowing time changes
357 to occur in the alternate time zone), parsed results may be different
358 than in 5.x (but since 5.x didn't have proper time zone handling, this
359 is a good thing).
360
361 =back
362
363 =head1 DATE PARSING AND OPERATIONS
364
365 =over 4
366
367 =item B<(*) today, tomorrow, yesterday>
368
369 The words "today", "tomorrow", and "yesterday" in 5.xx referred to the
370 time now, 24 hours in the future, and 24 hours in the past respectively.
371
372 As of 6.00, these are treated strictly as date strings, so they are
373 the current day, the day before, or the day after at the time 00:00:00.
374
375 The string "now" still refers to the current date and time.
376
377 =item B<ISO 8601 formats>
378
379 A couple of the date formats from Date::Manip 5.xx conflicted with ISO
380 8601 formats in the spec. These are documented in the
381 Date::Manip::Date documentation.
382
383 Dates are now parsed according to the spec (though a couple extensions
384 have been made, which are also documented in the Date::Manip::Date
385 documentation).
386
387 There is one change with respect to Date::Manip 5.xx that results from
388 a possible misinterpretation of the standard. In Date::Manip, there is
389 a small amount of ambiguity in how the Www-D date formats are
390 understood.
391
392 The date:
393
394 1996-w02-3
395
396 might be interpreted in two different ways. It could be interpreted as
397 Wednesday (day 3) of the 2nd week of 1996, or as the 3rd day of the
398 2nd week of 1996 (which would be Tuesday if the week begins on
399 Sunday). Since the specification only works with weeks which begin on
400 day 1, the two are always equivalent in the specification, and the
401 language of the specification doesn't clearly indicate one
402 interpretation over the other.
403
404 Since Date::Manip supports the concept of weeks starting on days other
405 than day 1 (Monday), the two interpretations are not equivalent.
406
407 In Date::Manip 5.xx, the date was interpreted as Wednesday of the 2nd
408 week, but I now believe that the other interpretation (3rd day of the
409 week) is the interpretation intended by the specification. In addition,
410 if this interpretation is used, it is easy to get the other interpretation.
411
412 If 1996-w02-3 means the 3rd day of the 2nd week, then to get Wednesday
413 (day 3) of the week, use the following two Date::Manip::Date methods:
414
415 $err = $date->parse("1996-w02-1");
416 $date2 = $date->next(3,1);
417
418 The first call gets the 1st day of the 2nd week, and the second call
419 gets the next Wednesday.
420
421 If 1996-w02-3 is interpreted as Wednesday of the 2nd week, then to
422 get the 3rd day of the week involves significantly more work.
423
424 In Date::Manip 6.00, the date will now be parsed as the 3rd day of the
425 2nd week.
426
427 =item B<(*) Parsing is now more rigid>
428
429 The philosophy in Date::Manip 5.xx with respect to parsing dates was
430 "if there's any conceivable way to find a valid date in the string, do
431 so". As a result, strings which did not look like they could contain a
432 valid date often would.
433
434 This manifested itself it two ways. First, a lot of punctuation was
435 ignored. For example, the string "01 // 03 -. 75" was the date
436 1975-01-03.
437
438 Second, a lot of word breaks were optional and it was often acceptable
439 to run strings together. For example, the delta "in5seconds" would
440 have worked.
441
442 With Date::Manip 6.00, parsing now tries to find a valid date in the
443 string, but uses a more rigidly defined set of allowed formats which
444 should more closely match how the dates would actually be expressed in
445 real life. The punctuation allowed is more rigidly defined, and word
446 breaks are required. So "01/03/75" will work, but "01//03/75" and
447 "01/03-75" won't. Also, "in5seconds" will no longer work, though "in 5
448 seconds" will work.
449
450 These changes serve to simplify some of the regular expressions used
451 in parsing dates, as well as simplifying the parsing routines. They
452 also help to recognize actually dates as opposed to typos... it was too
453 easy to pass in garbage and get a date out.
454
455 =item B<Support dropped for a few formats>
456
457 I've dropped support for a few very uncommon (probably never used)
458 formats. These include (with Jan 3, 2009 as an example):
459
460 DD/YYmmm 03/09Jan
461 DD/YYYYmmm 03/2009Jan
462 mmmYYYY/DD Jan2009/03
463 YYYY/DDmmm 2009/03Jan
464
465 mmmYYYY Jan2009
466 YYYYmmm 2009Jan
467
468 The last two are no longer supported since they are incomplete.
469
470 With the exception of the incomplete forms, these could be added back in
471 with very little effort. If there is ever a request to do so, I probably
472 will.
473
474 =item B<No longer parses the Apache format>
475
476 Date::Manip 5.xx supported the format:
477
478 DD/mmm/YYYY:HH:MN:SS
479
480 used in the apache logs. Due to the stricter parsing, this format
481 is no longer supported directly. However, the parse_format method
482 may be used to parse the date directly from an apache log line
483 with no need to extract the date string beforehand.
484
485 =item B<Date_PrevWorkDay behavior>
486
487 The behavior of Date_PrevWorkDay has changed slightly.
488
489 The starting date is checked. If $timecheck was non-zero, the
490 check failed if the date was not a business date, or if the time was
491 not during business hours. If $timecheck was zero, the check failed
492 if the date was not a business date, but the time was ignored.
493
494 In 5.xx, if the check failed, and $timecheck was non-zero, day 0
495 was defined as the start of the next business day, but if $timecheck
496 was zero, day 0 was defined as the previous business day at the
497 same time.
498
499 In 6.xx, if the check fails, and $timecheck is non-zero, the behavior
500 is the same as before. If $timecheck is zero, day 0 is defined as the
501 next business day at the same time.
502
503 So day 0 is now always the same, where before, day 0 meant two
504 different things depending on whether $timecheck was zero or not.
505
506 =item B<(*) Default time>
507
508 In Date::Manip 5.xx, the default times for dates was handled in an
509 inconsistent manner. In the Date::Manip::Date documentation, if you
510 parse a date from the "Common date formats" section, in Date::Manip
511 5.xx, if no time was included, it defaulted to "00:00:00". If you
512 parsed a date from the "Less common formats" section, the default time
513 was the current time.
514
515 So running a program on Jun 5, 2009 at noon that parsed the following
516 dates gave the following return values:
517
518 Jun 12 => Jun 12, 2009 at 00:00:00
519 next week => Jun 12, 2009 at 12:00:00
520
521 This behavior is changed and now relies on the config variable DefaultTime.
522 If DefaultTime is "curr", the default time for any date which includes no
523 information about the time is the current time. Otherwise, the default time
524 is midnight.
525
526 =item B<%z format>
527
528 In Date::Manip 5.xx, the %z format would give an offset in the form: -0500.
529 Now it gives it in the form: -05:00:00
530
531 =back
532
533 =head1 DELTAS
534
535 =over 4
536
537 =item B<Dropped mixed style delta parsing>
538
539 In Date::Manip 5.xx, a parsed delta could be written in the delta style
540
541 1:2:3
542
543 or in a language-specific expanded form:
544
545 1 hour 2 minutes 3 seconds
546
547 or in a mixed form:
548
549 1 hour 2:3
550
551 The mixed form has been dropped since I doubt that it sees much use in
552 real life, and by dropping the mixed form, the parsing is much
553 simpler.
554
555 =item B<Approximate date/date calculations>
556
557 In Date::Manip 5.xx, the approximate delta between the two dates:
558
559 Jan 10 1996 noon
560 Jan 7 1998 noon
561
562 was +1:11:4:0:0:0:0 (or 1 year, 11 months, 4 weeks). As of
563 Date::Manip 6.00, the delta is +2:0:-0:3:0:0:0 (or 2 years minus 3
564 days). Although this leads to mixed-sign deltas, it is actually
565 how more people would think about the delta. It has the additional
566 advantage of being MUCH easier and faster to calculate.
567
568 =item B<Approximate relationships in deltas>
569
570 When printing parts of deltas in Date::Manip::5.xx, the approximate
571 relationship of 1 year = 365.25 days was used. This is the correct
572 value for the Julian calendar, but for the Gregorian calendar, a
573 better value is 365.2425, and this is used in version 6.00.
574
575 =item B<Old style formats>
576
577 The formats used in the printf command are slightly different than in the
578 old Delta_Format command.
579
580 The old formats are described in the Date::Manip::DM5 manual, and the
581 new ones are in the Date::Manip::Delta manual.
582
583 The new formats are much more flexible and I encourage you to switch over,
584 however at this point, the old style formats are officially supported for
585 the Delta_Format command.
586
587 At some point, the old style formats may be deprecated (and removed at
588 some point beyond that), but for now, they are not.
589
590 The old formats are NOT available using the printf method.
591
592 =back
593
594 =head1 RECURRENCES
595
596 =over 4
597
598 =item B<The day field meaning changed in a few recurrences>
599
600 The value of the day field can refer to several different things
601 including the day of week number (Monday=1 to Sunday=7), day of month (1-31),
602 day of year (1-366), etc.
603
604 In Date::Manip 5.xx, it could also refer to the nth day of the week
605 (i.e. 1 being the 1st day of the week, -1 being the last day of the
606 week). This meaning is no longer used in 6.xx.
607
608 For example, the recurrence:
609
610 1*2:3:4:0:0:0
611
612 referred to the 3rd occurrence of the 4th day of the week in February.
613
614 The meaning has been changed to refer to the 3rd occurrence of day 4
615 (Thursday) in February. This is a much more useful type of recurrence.
616
617 As a result of this change, the related recurrence:
618
619 1*2:3:-1:0:0:0
620
621 is invalid. Negative numbers may be used to refer to the nth day
622 of the week, but NOT when referring to the day of week numbers.
623
624 =item B<Recurrence range now inclusive>
625
626 Previously, the list of dates implied by the recurrence were on or
627 after the start date, but before the end date.
628
629 This has been changed so that the dates may be on or before the end
630 date.
631
632 =item B<Dropped support for a couple English recurrences>
633
634 Date::Manip 5.xx claimed support for a recurrence:
635
636 every 2nd day in June [1997]
637
638 In actuality, this recurrence is not practical to calculate. It
639 requires a base date which might imply June 1,3,5,... in 1997 but June
640 2,4,6 in 1998.
641
642 In addition, the recurrence does not fit the mold for other
643 recurrences that are an approximate distance apart. This type of
644 recurrence has a number of closely spaced events with 11-month gaps
645 between groups.
646
647 I no longer consider this a valid recurrence and support is now
648 dropped for this string.
649
650 I also dropped the following for a similar reason:
651
652 every 6th Tuesday [in 1999]
653
654 =item B<Other minor recurrence changes>
655
656 Previously, ParseRecur would supply default dates if the start or
657 end were missing. This is no longer done.
658
659 =back
660
661 =head1 DATE::MANIP FUNCTIONS
662
663 The Date::Manip module contains the same functions that Date::Manip 5.xx had
664 (though the OO modules do all the work now). In general, the routines behave
665 the same as before with the following exceptions:
666
667 =over 4
668
669 =item B<Date_ConvTZ>
670
671 Previously, Date_ConvTZ took 1 to 4 arguments and used the local time zone and
672 the ConvTZ config variable to fill in missing arguments.
673
674 Now, the Date_ConvTZ function only supports a 3 argument call:
675
676 $date = Date_ConvTZ($date,$from,$to);
677
678 If $from is not given, it defaults to the local time zone. If $to is not given,
679 it defaults to the local time zone.
680
681 The optional 4th argument ($errlevel) is no longer supported. If there is
682 an error, an empty string is returned.
683
684 =item B<DateCalc>
685
686 In Date::Manip 5.xx, it was recommended that you pass arguments to
687 ParseDate or ParseDateDelta. This is not recommended with 6.00 since it
688 is much more intelligent about handling the arguments, and you'll just
689 end up parsing the date/delta twice.
690
691 =back
692
693 =head1 BUGS AND QUESTIONS
694
695 Please refer to the L<Date::Manip::Problems> documentation for
696 information on submitting bug reports or questions to the author.
697
698 =head1 SEE ALSO
699
700 L<Date::Manip> - main module documentation
701
702 =head1 LICENSE
703
704 This script is free software; you can redistribute it and/or
705 modify it under the same terms as Perl itself.
706
707 =head1 AUTHOR
708
709 Sullivan Beck ([email protected])
710
711 =cut