Debian Codegraph @

lib/Date/Manip/Problems.pod

raw
1 # Copyright (c) 1995-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::Problems - problems and bugs
10
11 =head1 KNOWN PROBLEMS
12
13 The following are not bugs in Date::Manip, but they may give some people
14 problems.
15
16 =over 4
17
18 =item B<Unable to determine Time Zone>
19
20 If you ever get the message that Date::Manip was unable to determine the
21 timezone, you need to provide that information to your script.
22 Please refer to the L<Date::Manip::TZ> documentation for a discussion
23 of this problem.
24
25 =item B<Calculations appear to be off by an hour>
26
27 Due to daylight saving time (especially the spring change where
28 the time typically moves forward from 02:00 to 03:00), any date
29 calculation which would intuitively report a time in that range
30 will also move forward (or backward as the case may be).
31
32 *NOTE* This should be less of a problem since 6.30 with the addition
33 of semi-exact deltas.
34
35 =item B<Missing date formats>
36
37 Due to the large number of date formats that Date::Manip CAN process,
38 people often assume that other formats that they want to use should
39 work as well, and when they don't, it comes as a surprise.
40
41 With the much improved parsing of 6.00, many formats can be added
42 easily, though unless they are of general use, I'll probably suggest
43 that you use parse_format instead.
44
45 There is a class of formats that I do not plan to add however.
46
47 I have frequently been asked to add formats such as "the 15th of last
48 month", or "Monday of next week". I do not intend to add these date
49 formats to Date::Manip, but since I have received the request several
50 times, I decided to include my reasoning here.
51
52 Date::Manip can parse pretty much any static date format that I could
53 think of or find reference to. Dates such as "today", "Jan 12", or
54 "2001-01-01" are all understood.
55
56 These are fairly limited however. Many very common date formats are
57 best thought of as a date plus a modification. For example,
58 "yesterday" is actually determined internally as "today" plus a
59 modification of "- 1 day". "2nd Sunday in June" is determined as
60 "June 1" modified to the 2nd Sunday.
61
62 As these types of formats were added over time, I quickly realized
63 that the number of possible date plus modification formats was
64 huge. The number of combinations has caused the parsing in Date::Manip
65 to be quite complex, and adding new formats occasionally causes
66 unexpected conflicts with other formats.
67
68 The first time I received a request similar to "the 15th of last
69 month", I intended to add it, but as I analyzed it to see what changes
70 needed to be made to support it, I realized that this needed to be
71 expressed as a date plus TWO modifications. In other words, today
72 modified to last month modified to the 15th day of the month.
73
74 As bad as date plus modification formats are, a date plus TWO
75 modifications would be exponentially worse. On realizing that, I
76 decided that Date::Manip will not support this type of format.
77
78 Although I apologize for the inconvenience, I do not intend to change
79 my position on this.
80
81 =item B<Date::Manip is slow>
82
83 Date::Manip is one of the slower Date/Time modules due to the fact that
84 it is huge and written entirely in perl. I have done a lot of work
85 optimizing it since 6.xx came out, and additional work is planned,
86 but even at it's best, it will probably be slower than other modules.
87
88 Some things that will definitely help:
89
90 Date::Manip 5.xx was very slow. A lot of work went into speeding it up
91 as I rewrote it for the 6.xx release, and it should be noted that
92 initial tests show version 6.xx to be around twice as fast as 5.xx.
93 There is one notable exception to this speedup. If you use Date::Manip
94 to parse dates from a wide variety of timezones, 6.xx will be significantly
95 slower than 5.xx. The reason for this is that each time a new timezone is
96 accessed, 6.xx does quite a bit of work to initialize it. 5.xx does not
97 have this overhead, so it can parse dates from any number of timezones
98 without a speed penalty. However, 5.xx does NOT handle timezones correctly,
99 so many of the dates will be incorrect. If timezones are important to you,
100 there is no way to use 5.xx and get accurate results.
101
102 If you only parse dates from a single timezone (which is more often what
103 you are doing), 6.xx is significantly faster than 5.xx.
104
105 ISO-8601 dates are parsed first and fastest. If you have the flexibility
106 to define the date format, use ISO-8601 formats whenever possible.
107
108 Avoid parsing dates that are referenced against the current time (in 2
109 days, today at noon, etc.). These take a lot longer to parse.
110
111 Business date calculations are extremely slow. You should consider
112 alternatives if possible (i.e. doing the calculation in exact mode and
113 then multiplying by 5/7). Who needs a business date more accurate
114 than "6 to 8 weeks" anyway, right :-)
115
116 =item B<Memory leak>
117
118 There is a known memory leak in perl related to named regexp captures
119 that directly affects Date::Manip . The leak is in all versions of
120 perl up to (and including) the following versions:
121
122 5.10.1
123 5.12.5
124 5.14.3
125 5.15.5
126
127 The bug has been fixed in:
128
129 5.15.6
130 5.16.0
131
132 If a maintenance release is done for any of the other releases (5.10,
133 5.12, 5.14), that includes the patch, I'll update this section to
134 include that information.
135
136 Date::Manip 5.xx is not susceptible, so using it may be a feasible
137 workaround, but if you need accurate timezone handling, this isn't
138 possible.
139
140 Simple tests estimate the leak to be about 3 MB per 10,000 dates
141 parsed, so unless you're parsing hundreds of thousands, or millions of
142 dates, the leak probably won't be a problem on systems with moderate
143 amounts of memory. And if you're parsing that many dates, the
144 relatively slow Date::Manip may not be the correct module for you to
145 use anyway.
146
147 =item B<Dmake error on strawberry perl>
148
149 Users of Strawberry perl on windows may encounter an error similar
150 to the following:
151
152 dmake: makefile: line 3016: Error: -- Input line too long, increase MAXLINELENGTH
153
154 This is a known problem with some versions of strawberry perl, and
155 I can't fix it in Date::Manip. If you encounter this problem, you
156 can install the package manually using the commands:
157
158 c:> cpan
159 cpan> look Date::Manip::Date
160 > perl Makefile.PL
161 > dmake MAXLINELENGTH=300000 make
162 > dmake MAXLINELENGTH=300000 make test
163 > dmake MAXLINELENGTH=300000 make install
164
165 You can find more details here:
166
167 http://www.nntp.perl.org/group/perl.win32.vanilla/2011/02/msg287.html
168
169 =item B<Using functions/methods which are not supported>
170
171 There have been a handful of incidents of people using a function from
172 Date::Manip which were not documented in the manual.
173
174 Date::Manip consists of a large number of user functions which are
175 documented in the manual. These are designed to be used by other
176 programmers, and I will not make any backwards incompatible changes in
177 them unless there is a very compelling reason to do so, and in that
178 case, the change will be clearly documented in the
179 L<Date::Manip::Changes6> documentation for this module.
180
181 Date::Manip also includes a large number of functions which are NOT
182 documented. These are for internal use only. Please do not use them!
183 I can (and do) change their functionality, and even their name, without notice,
184 and without apology! Some of these internal functions even have test
185 scripts, but that is not a guarantee that they will not change, nor is
186 any support implied. I simply like to run regression tests on as much
187 of Date::Manip as possible.
188
189 As of the most recent versions of Date::Manip, all internal functions
190 have names that begin with an underscore (_). If you choose to use
191 them directly, it is quite possible that new versions of Date::Manip
192 will cause your programs to break due to a change in how those
193 functions work.
194
195 Any changes to internal functions will not be documented, and will not
196 be regarded by me as a backwards incompatibility. Nor will I (as was
197 requested in one instance) revert to a previous version of the
198 internal function.
199
200 If you feel that an internal function is of more general use, feel
201 free to contact me with an argument of why it should be "promoted". I
202 welcome suggestions and will definitely consider any such request.
203
204 =item B<RCS Control>
205
206 If you try to put Date::Manip under RCS control, you are going to have
207 problems. Apparently, RCS replaces strings of the form "$Date...$" with
208 the current date. This form occurs all over in Date::Manip. To prevent the
209 RCS keyword expansion, checkout files using:
210
211 co -ko
212
213 Since very few people will ever have a desire to do this (and I don't
214 use RCS), I have not worried about it, and I do not intend to try to
215 workaround this problem.
216
217 =back
218
219 =head1 KNOWN COMPLAINTS
220
221 Date::Manip 6.xx has gotten some complaints (far more than 5.xx if the
222 truth be told), so I'd like to address a couple of them here. Perhaps
223 an understanding of why some of the changes were made will allay some
224 of the complaints. If not, people are always welcome to stick with
225 the 5.xx release. I will continue to support the 5.xx releases for a
226 couple years (though I do NOT plan to add functionality to it).
227
228 =over 4
229
230 =item B<Requires perl 5.10>
231
232 The single most controversial change made in 6.00 is that it now
233 required perl 5.10.0 or higher. Most of the negative feedback I've
234 received is due to this.
235
236 In the past, I've avoided using new features of perl in order to allow
237 Date::Manip to run on older versions of perl. Prior to perl 5.10,
238 none of the new features would have had a major impact on how
239 Date::Manip was written so this practice was justified. That all
240 changed with the release of perl 5.10.
241
242 One of the aspects of Date::Manip that has received the most positive
243 response is the ability to parse almost every conceivable date format.
244 Unfortunately, as I've added formats, the parsing routine became more
245 and more complicated, and maintaining it was one of the least
246 enjoyable aspect in maintaining Date::Manip . In fact, for several
247 years I'd been extremely reluctant to add new formats due to the fact
248 that too often, adding a new format broke other formats.
249
250 As I was rewriting Date::Manip, I was looking for ways to improve the
251 parsing and to make maintaining it easier. Perl 5.10 provides the
252 feature "named capture buffers". Named capture buffers not only
253 improves the ease of maintaining the complex regular expressions used
254 by Date::Manip, it makes it dramatically easier to add additional
255 formats in a way that is much less likely to interfere with other
256 formats. The parsing in 6.00 is so much more robust, extensible, and
257 flexible, that it will make parser maintenance possible for many years
258 to come at a fraction of the effort and risk.
259
260 It was too much to turn down. Hopefully, since 5.10 has been out for
261 some time now, this will not prohibit too many people from using the
262 new version of Date::Manip. I realize that there are many people out
263 there using older versions of perl who do not have the option of
264 upgrading perl. The decision to use 5.10 wasn't made lightly... but I
265 don't regret making it. I apologize to users who, as a result, cannot
266 use 6.00 . Hopefully in the future you'll be able to benefit from the
267 improvements in 6.00.
268
269 One complaint I've received is that this in some way makes Date::Manip
270 backwards incompatible, but this is not an accurate complaint. Version
271 6.xx DOES include some backwards incompatibilities (and these are
272 covered in the L<Date::Manip::Migration5to6> document), however in almost
273 all cases, these incompatibilities are with infrequently used
274 features, or workarounds are in place to allow deprecated features to
275 continue functioning for some period of time.
276
277 Though I have no data to confirm this, I suspect that 90% or more of
278 all scripts which were written with Date::Manip 5.xx will continue to
279 work unmodified with 6.xx (of course, you should still refer to the
280 migration document to see what features are deprecated or changed to
281 make sure that you don't need to modify your script so that it will
282 continue to work in the future). Even with scripts that need to be
283 changed, the changes should be trivial.
284
285 So, Date::Manip 6.xx is almost entirely backward compatible with 5.xx
286 (to the extent that you would expect any major version release to be
287 compatible with a previous major version).
288
289 The change is only in the requirements necessary to get Date::Manip
290 6.xx to run.
291
292 Obviously, it's not reasonable to say that Date::Manip should never be
293 allowed to switch minimum perl versions. At some point, you have to
294 let go of an old version if you want to make use of the features of
295 the newer version. The question is, did I jump to 5.10 too fast?
296
297 The negative ratings I see in the CPAN ratings complain that I no
298 longer support perl 5.6 and perl 5.8.
299
300 With respect to 5.6, perl 5.6 was released in March of 2000 (that's
301 before Windows XP which was released in 2001). Date::Manip 6.00 was
302 released at the end of 2009. To be honest, I don't really feel much
303 sympathy for this complaint. Software that is 9 years old is ANCIENT.
304 People may choose to use it... but please don't complain when new
305 software comes out that doesn't support it.
306
307 The argument for perl 5.8 is much more compelling. Although 5.8 was
308 released well before Date::Manip 6.00 (July of 2002), there were no
309 major perl releases until 5.10 came out in December of 2007, so 5.8
310 was state-of-the art as little as 2 years prior to the release of
311 Date::Manip 6.xx.
312
313 I agree completely with the argument that abandoning 5.8 only 2 years
314 after it was the current version is too soon. For that reason, I
315 continued to support the Date::Manip 5.xx releases for several years.
316 As of December 2012 (5 years after the release of perl 5.10), the 5.xx
317 release is no longer supported (in that I will not patch it or provide
318 support for it's use). However, it is still bundled into the Date::Manip
319 distribution so it can still be used. I do not have any plans for
320 removing it, though I may do so at some point.
321
322 =item B<Too many modules>
323
324 One minor complaint is that there are too many files. One person
325 specifically objects to the fact that there are over 470 modules
326 covering non-minute offsets. This complaint is (IMO) silly.
327
328 Date::Manip supports ALL historical time zones, including those with
329 non-minute offsets, and so there will be information for those time
330 zones, even though they are not currently in use.
331
332 I could of course store all of the information in one big module, but
333 that means that you have to load all of that data every time you use
334 Date::Manip, and I find that to be a very poor solution. Instead,
335 storing the information in a per-time zone and per-offset manner
336 dramatically decreases the amount of data that has to be loaded.
337
338 While it is true that Date::Manip includes over 900 modules for all of
339 the time zone information, most implementations of time zone handling
340 also choose to break up the data into a large number of files.
341
342 My linux distribution (openSuSE 11.2 at the time of writing this) uses
343 the standard zoneinfo database, and at this point, there are over 1700
344 files included in /usr/share/zoneinfo (though it does appear that
345 there is some duplication of information). Current versions of RedHat
346 also use over 1700 files, so Date::Manip isn't treating the time zone
347 data in a new or unreasonable way.
348
349 =item B<Objects are large>
350
351 One complaint that was put on the CPAN ratings site was that the OO
352 interface is "a dud" due to the size of it's objects. The complaint is
353 that a L<Date::Manip::Date> object is 115K while it should (according to
354 the complaint) only require that you need to save the seconds from the
355 epoch, zone, and a couple other pieces of information, all of which
356 could probably be stored in 100 bytes or less.
357
358 This complaint is not accurate, and comes from a misunderstanding
359 of the objects used by Date::Manip.
360
361 Date::Manip is very configurable, and contains a great deal of
362 information which could theoretically be calculated on the fly, but
363 which would greatly reduce it's performance. Instead, in the interest
364 of improving performance, the data is cached, and since the data is
365 virtually all potentially object specific, it has to be somehow linked
366 to the object.
367
368 For example, Date::Manip allows you to parse dates in several
369 languages. Each language has a large number of regular expressions
370 which are used to do the actual parsing. Instead of recreating these
371 regular expressions each time they are needed, they are created once
372 and stored in an object (specifically, a L<Date::Manip::Base> object).
373 The size of the L<Date::Manip::Base> object is almost 15K (due primarily
374 to the regular expressions used in parsing dates in the selected
375 language).
376
377 Similarly, a description of the time zones are stored in a second
378 object (a L<Date::Manip::TZ> object). The size of the L<Date::Manip::TZ>
379 object starts at 100K. That may seem excessive, but you have to
380 remember that there are almost 500 time zones, and they have to be
381 indexed by name, alias, abbreviation, and offset. In addition, critical
382 dates (dates where the offset from GMT change such as during a daylight
383 saving time change) along with information such as offsets, abbreviation,
384 etc., are all cached in order to improve performance. By the time you
385 do this, it does take a fair bit of space. It should also be noted
386 that the full description of each timezone is only stored in the
387 object when the timezone is actually used, so if you use a lot of
388 timezones, this object will grow slowly as new timezones are used.
389
390 The size of the actual L<Date::Manip::Date> object is a little over 300
391 bytes. However, each includes a pointer to a L<Date::Manip::Base> and
392 a L<Date::Manip::TZ> object (and due to how the object was being looked
393 at in the complaint, they were reporting the size of all three objects,
394 NOT just the L<Date::Manip::Date> object).
395
396 Both the L<Date::Manip::Base> and L<Date::Manip::TZ> objects are reused by
397 any number of L<Date::Manip::Date> objects. They can almost be thought of
398 as global data, except that they are accessible in the standard OO
399 manner, and you are allowed to modify them on a per-object basis which
400 WILL mean that you have to store more data. If you work with multiple
401 configurations (see L<Date::Manip::Config>), you'll need multiple Base
402 and TZ objects. However, most of the time you will not need to do
403 this.
404
405 The actual L<Date::Manip::Date> object is a bit larger than suggested in
406 the complaint, but it should be noted that Date::Manip actually stores
407 the dates in a number of different formats (a string of the form
408 YYYYMMDDHH:MN:SS and a list [YYYY,MM,DD,HH,MN,SS] in the time zone it
409 was parsed in, the local time zone (if different) and GMT. By caching
410 this information as it is used, it has a huge impact on the
411 performance.
412
413 So, Date::Manip in typical usage consists of one 100K L<Date::Manip::TZ>
414 object, one 15K L<Date::Manip::Base> objects, and any number of small 300
415 byte L<Date::Manip::Date> objects. L<Date::Manip::Delta> objects are even
416 smaller. L<Date::Manip::Recur> objects are also small, but they contain
417 any number of Date objects in them.
418
419 I am certainly open to suggestions as to how I can improve the OO
420 interface... but I don't believe it is a dud. While I'm not an expert
421 at OO programming, I believe that I followed pretty standard and
422 accepted procedures for accessing the data.
423
424 Please refer to the L<Date::Manip::Objects> document for more
425 information.
426
427 =item B<Date::Manip has an inconsistent interface>
428
429 I've gotten a few complaints that the interface to Date::Manip is
430 inconsistent... and I agree (at least when referring to the functional
431 interfaces).
432
433 Date::Manip was originally written in an unplanned way... as a need/want
434 came up, it was extended. That's not the way to write a major package
435 of course, but it wasn't expected to be a major package at the start.
436
437 As it became more and more widely used, I too wished for a more
438 consistent interface, but I did not want to break backward compatibility
439 for everyone using it.
440
441 When 6.xx was written, I spent a good deal of time trying to make a
442 very standard OO interface, so I do not believe that this complaint
443 can be applied to the OO interface (though I'm interested in
444 suggestions for improving it of course).
445
446 As far as the functional interface goes, I'll continue to support it
447 in a backward compatible (and therefore inconsistent) form. I'd
448 encourage the use of the OO interface whenever possible.
449
450 =back
451
452 =head1 BUGS AND QUESTIONS
453
454 If you find a bug in Date::Manip, please let me know. As CPAN has removed
455 email support, the only supported way to submit a bug is via ticket:
456
457 =over 4
458
459 =item GitHub
460
461 You can submit it as an issue on GitHub. This can be done at the following
462 URL:
463
464 L<https://github.com/SBECK-github/Date-Manip>
465
466 This is the preferred method. Please submit problems requests as GitHub issues
467 if at all possible.
468
469 =back
470
471 Please do not use other means to report bugs (such as forums for a specific
472 OS or Linux distribution) as it is impossible for me to keep up with all of
473 them.
474
475 When filing a bug report, please include the following information:
476
477 =over 4
478
479 =item B<Date::Manip version>
480
481 Please include the version of Date::Manip you are using. You can get
482 this by using the script:
483
484 use Date::Manip;
485 print DateManipVersion(1),"\n";
486
487 or
488
489 use Date::Manip::Date;
490 $obj = new Date::Manip::Date;
491 print $obj->version(1),"\n";
492
493 =item B<Perl information>
494
495 Please include the output from "perl -V"
496
497 =back
498
499 If you have a problem using Date::Manip that perhaps isn't a bug
500 (can't figure out the syntax, etc.), you're in the right place. Start
501 by reading the main Date::Manip documentation, and the other documents
502 that apply to whatever you are trying to do. If this still doesn't
503 answer your question, mail me directly.
504
505 I would ask that you be reasonably familiar with the documentation
506 BEFORE you choose to do this. Date::Manip is a hobby, and I simply do
507 not have time to respond to hundreds of questions which are already
508 answered in this manual.
509
510 If you find any problems with the documentation (errors, typos, or items
511 that are not clear), please send them to me. I welcome any suggestions
512 that will allow me to improve the documentation.
513
514 =head1 KNOWN BUGS
515
516 None known.
517
518 =head1 SEE ALSO
519
520 L<Date::Manip> - main module documentation
521
522 =head1 LICENSE
523
524 This script is free software; you can redistribute it and/or
525 modify it under the same terms as Perl itself.
526
527 =head1 AUTHOR
528
529 Sullivan Beck (https://github.com/SBECK-github/)
530
531 =cut