| 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::Misc - Miscellaneous information about Date::Manip |
| 10 |
|
| 11 |
=head1 SHOULD I USE DATE::MANIP |
| 12 |
|
| 13 |
If you look in CPAN, you'll find that there are a number of Date and |
| 14 |
Time packages. Is Date::Manip the one you should be using? That isn't |
| 15 |
a trivial question to answer. It depends to a large extent on what you |
| 16 |
are trying to do. |
| 17 |
|
| 18 |
Date::Manip is certainly one of the most powerful of the Date modules |
| 19 |
(the other main contender being the DateTime suite of modules). I'm |
| 20 |
trying to build a library which can do _EVERY_ conceivable |
| 21 |
date/time manipulation that you'll run into in everyday life dealing with |
| 22 |
the Gregorian calendar. To the best of my knowledge, it will do |
| 23 |
everything that any other date module will do which work with the |
| 24 |
Gregorian calendar, and there are a number of features that Date::Manip |
| 25 |
has that other modules do not have. |
| 26 |
|
| 27 |
There is a tradeoff in being able to do "everything"... and that |
| 28 |
tradeoff is primarily in terms of performance. Date::Manip is written |
| 29 |
entirely in Perl and is the largest of the date modules. Other modules |
| 30 |
tend to be faster than Date::Manip, and modules written in C are |
| 31 |
significantly faster than their Perl counterparts (at least if they're |
| 32 |
done right). Although I am working on making Date::Manip faster, it |
| 33 |
will never be as fast as other modules. And before anyone asks, |
| 34 |
Date::Manip will never be translated to C (at least by me). I write C |
| 35 |
because I have to. I write Perl because I like to. Date::Manip is |
| 36 |
something I do because it interests me, not something I'm paid for. |
| 37 |
|
| 38 |
If you are going to be using the module in cases where performance is |
| 39 |
an important factor, and you're doing a fairly small set of simple |
| 40 |
date operations over and over again, you should carefully examine the |
| 41 |
other date modules to see if they will meet your needs. |
| 42 |
|
| 43 |
Date::Manip does NOT provide functionality for working with alternate |
| 44 |
calendars such as the Chinese or Hebrew calendars, so if you need that |
| 45 |
functionality, you definitely need to look elsewhere (the DateTime suite |
| 46 |
probably). |
| 47 |
|
| 48 |
On the other hand, if you want one solution for all your date needs, |
| 49 |
don't need peak speed, or are trying to do more exotic date |
| 50 |
operations, Date::Manip is for you. Operations on things like |
| 51 |
business dates, foreign language dates, holidays and other recurring |
| 52 |
events, complete timezone handling, etc. are available more-or-less |
| 53 |
exclusively in Date::Manip. At the very least, if you want to be able |
| 54 |
to do these operations, it will require using several other modules, |
| 55 |
each with it's own interface. Also, when you work with Date::Manip, |
| 56 |
you work with one author and one module. The DateTime suite |
| 57 |
currently consists of almost 100 modules and 75 authors. |
| 58 |
|
| 59 |
In addition, I am making significant performance improvements in |
| 60 |
Date::Manip. Although it will never be as fast as some of the other |
| 61 |
perl modules, I believe that it is already competitive enough for most |
| 62 |
purposes, and I continue to look for places where I can improve |
| 63 |
performance, so performance should improve over time. |
| 64 |
|
| 65 |
=head1 YEAR 2000 AND YEAR 2007 DST CHANGE |
| 66 |
|
| 67 |
Did Date::Manip have any problems with Y2K compliance? Did it have any |
| 68 |
problems with the revised daylight saving time changes made in 2007? |
| 69 |
|
| 70 |
Although Date::Manip will parse many date strings (including dates |
| 71 |
with 2-digit years), internally they are stored as a 4 digit year, and |
| 72 |
all operations are performed using this internal representation, so |
| 73 |
Date::Manip had no problems with the Y2K issue. Of course, |
| 74 |
applications written which stored the year as 2 digits (whether or not |
| 75 |
it used Date::Manip) may have had problems, but they were not because |
| 76 |
of this module. |
| 77 |
|
| 78 |
Similarly for the 2007 changes in daylight saving time made in the United |
| 79 |
States, Date::Manip was not affected. Date::Manip makes use of the |
| 80 |
current time zone, but it gets that information from the operating system |
| 81 |
the application is running on. If the operating system knows about the |
| 82 |
new daylight saving time rules... so does Date::Manip. |
| 83 |
|
| 84 |
=head1 WHAT DATES ARE DATE::MANIP USEFUL FOR? |
| 85 |
|
| 86 |
Date::Manip applies to the Gregorian calendar. It does not support |
| 87 |
alternative calendars (Hebrew, Mayan, etc.) so if you want to use |
| 88 |
an alternative calendar, you'll need to look elsewhere. |
| 89 |
|
| 90 |
The Gregorian calendar is a relatively recent innovation. Prior to it, |
| 91 |
the Julian calendar was in use. The Julian calendar defined leap years as |
| 92 |
every 4th year. This led to significant calendar drift over time (since |
| 93 |
a year is NOT 365.25 days long). It was replaced by the Gregorian |
| 94 |
calendar which improved the definition of leap years, and at that point, |
| 95 |
the calendar was adjusted appropriately. |
| 96 |
|
| 97 |
Date::Manip extrapolates the Gregorian calendar back to the year 0001 |
| 98 |
AD and forward to the year 9999 AD, but that does not necessarily mean |
| 99 |
that the results are useful. As the world adopted the Gregorian |
| 100 |
calendar, the dates using the Julian calendar had to be changed to fit |
| 101 |
to account for the drift that had occurred. As such, the dates |
| 102 |
produced by Date::Manip in an era where the Julian calendar was in use |
| 103 |
do not accurately reflect the dates actually in use. In historical |
| 104 |
context, the Julian calendar was in use until 1582 when the Gregorian |
| 105 |
calendar was adopted by the Catholic church. Protestant countries did |
| 106 |
not accept it until later; Germany and Netherlands in 1698, British |
| 107 |
Empire in 1752, Russia in 1918, etc. Date::Manip is therefore not |
| 108 |
equipped to truly deal with historical dates prior to about 1600, and |
| 109 |
between 1600 and 1900, the calendar varied from country to country. |
| 110 |
|
| 111 |
A second problem is that the Gregorian calendar is itself imperfect |
| 112 |
and at some point may need to be corrected (though it's not clear that |
| 113 |
this will happen... drift may now be accounted for using leap seconds |
| 114 |
which means that the Gregorian calendar may be useful indefinitely). |
| 115 |
No attempt is made to correct for the problems in the Gregorian |
| 116 |
calendar for a couple reasons. First is that my great great great |
| 117 |
grandchildren will be long dead before this begins to be a problem, so |
| 118 |
it's not an immediate concern. Secondly, and even more importantly, I |
| 119 |
don't know what the correction will be (if any) or when it will be |
| 120 |
implemented, so I can safely ignore it. |
| 121 |
|
| 122 |
There is some limitation on how dates can be expressed such that |
| 123 |
Date::Manip can handle them correctly. Date::Manip stores the year |
| 124 |
internally as a 4-digit number. This is obviously not a limit due to |
| 125 |
the Gregorian calendar, but I needed a way to store the dates |
| 126 |
internally, and the 4-digit year was chosen. I realize that the |
| 127 |
4-digit limitation does create a time when it will break (quite |
| 128 |
similar to those who chose a 2-digit representation set themselves up |
| 129 |
for the Y2K problem). Frankly, I'm not too concerned about this since |
| 130 |
that date is 8000 years in the future! Date::Manip won't exist then. |
| 131 |
Perl won't exist then. And it's quite possible that the Gregorian |
| 132 |
calendar won't exist then. That's a much different situation than the |
| 133 |
Y2K choice in which programmers chose a representation that would |
| 134 |
break within the lifetime of the programs they were writing. |
| 135 |
|
| 136 |
Given the 4-digit limitation, Date::Manip definitely can't handle BC |
| 137 |
dates, or dates past Dec 31, 9999. So Date::Manip works (in theory) |
| 138 |
during the period Jan 1, 0001 to Dec 31, 9999. There are a few |
| 139 |
caveats: |
| 140 |
|
| 141 |
=over 4 |
| 142 |
|
| 143 |
=item B<Gregorian calendar issue> |
| 144 |
|
| 145 |
In practical terms, Date::Manip deals with the Gregorian calendar, and |
| 146 |
is most useful in the period that that calendar has been, or will be, |
| 147 |
in effect. As explained above, the Gregorian calendar came into universal |
| 148 |
acceptance in the early 1900's, and it should remain in use for the |
| 149 |
foreseeable future. |
| 150 |
|
| 151 |
So... in practical terms, Date::Manip is probably useful from |
| 152 |
around 1900 through several thousand years from now. |
| 153 |
|
| 154 |
=item B<First/last week> |
| 155 |
|
| 156 |
In one part of the code (calculating week-of-year values), Date::Manip |
| 157 |
references dates one week after and one week before the date actually |
| 158 |
being worked on. As such, dates during the first week in the year 0001 |
| 159 |
fail (because a week before is in the year 1 BC), and those in the last |
| 160 |
week in the year 9999 fail (because a week later is in 10,000). |
| 161 |
|
| 162 |
No effort will be made to correct this because the added functionality |
| 163 |
is simply not that important (to me), especially since the Gregorian |
| 164 |
calendar doesn't really apply in either instance. To be absolutely |
| 165 |
safe, I will state that Date::Manip works as described in this manual |
| 166 |
during the period Feb 1, 0001 to Nov 30, 9999, and I will only support |
| 167 |
dates within that range (i.e. if you submit a bug using a date that is |
| 168 |
not in that range, I will will consider myself free to ignore it). |
| 169 |
|
| 170 |
=item B<Leap seconds> |
| 171 |
|
| 172 |
Date::Manip does NOT make use of the leap seconds in calculating time |
| 173 |
intervals, so the difference between two times may not be strictly |
| 174 |
accurate due to the addition of a leap second. |
| 175 |
|
| 176 |
=item B<Three-digit years> |
| 177 |
|
| 178 |
Date::Manip will parse both 2- and 4-digit years, but it will NOT |
| 179 |
handle 3 digit years. So, if you store the year as an offset from |
| 180 |
1900 (which is 3 digits long as of the year 2000), these will NOT be |
| 181 |
parseable by Date::Manip. Since the perl functions localtime and gmtime |
| 182 |
DO return the year as an offset from 1900, the output from these will |
| 183 |
need to be corrected (probably by adding 1900 to the result) before |
| 184 |
they can be passed to any Date::Manip routine. |
| 185 |
|
| 186 |
=back |
| 187 |
|
| 188 |
=head1 FUTURE IDEAS |
| 189 |
|
| 190 |
A number of changes are being considered for future inclusion in |
| 191 |
Date::Manip. As a rule, the changes listed below are not finalized, |
| 192 |
and are open to discussion. |
| 193 |
|
| 194 |
=over 4 |
| 195 |
|
| 196 |
=item B<Rewrite parsing for better language support> |
| 197 |
|
| 198 |
Currently, all of Date::Manip's parsing is based on English language |
| 199 |
forms of dates, even if the words have been replaced by the equivalent |
| 200 |
in some other language. |
| 201 |
|
| 202 |
I am considering rewriting the parsing routines in order to allow |
| 203 |
date forms that might be used in other languages but do not have a |
| 204 |
common English equivalent, and to account for the fact that some |
| 205 |
English formats may not have an equivalent in another language. |
| 206 |
|
| 207 |
=item B<Adding granularity> |
| 208 |
|
| 209 |
The granularity of a time basically refers to how accurate you wish to |
| 210 |
treat a date. For example, if you want to compare two dates to see if |
| 211 |
they are identical at a granularity of days, then they only have to occur |
| 212 |
on the same day. At a granularity of an hour, they have to occur within |
| 213 |
an hour of each other, etc. |
| 214 |
|
| 215 |
I'm not sure how useful this would be, but it's one of the oldest |
| 216 |
unimplemented ideas, so I'm not discarding it completely. |
| 217 |
|
| 218 |
=back |
| 219 |
|
| 220 |
=head1 ACKNOWLEDGMENTS |
| 221 |
|
| 222 |
There are many people who have contributed to Date::Manip over the |
| 223 |
years that I'd like to thank. The most important contributions have |
| 224 |
come in the form of suggestions and bug reports by users. I have |
| 225 |
tried to include the name of every person who first suggested each |
| 226 |
improvement or first reported each bug. These are included in the |
| 227 |
L<Date::Manip::Changes5> and L<Date::Manip::Changes6> documents. The list |
| 228 |
is simply too long to appear here, but I appreciate their help. |
| 229 |
|
| 230 |
A number of people have made suggestions or reported bugs which are |
| 231 |
not mentioned in these documents. These include suggestions which |
| 232 |
have not been implemented and people who have made a suggestion or bug |
| 233 |
report which has already been suggested/reported by someone else. For |
| 234 |
those who's suggestions have not yet been implemented, they will be |
| 235 |
added to the appropriate Changes document when (if) their suggestions |
| 236 |
are implemented. I keep every single suggestion I've ever received |
| 237 |
and periodically review the unimplemented ones to see if it's |
| 238 |
something I'm interested in, so even suggestions made years in the |
| 239 |
past may still appear in future versions of Date::Manip, and the |
| 240 |
original requester will be attributed at that point (some of the |
| 241 |
changes made to Date::Manip 6.00 were based on suggestions 10 years |
| 242 |
old which never fit in with version 5.xx, but which I knew I wanted to |
| 243 |
implement). For those who have sent in requests/reports that had been |
| 244 |
previously made by someone else, thank you too. I'd much rather have |
| 245 |
a suggestion made twice than not at all. |
| 246 |
|
| 247 |
Thanks to Alan Cezar and Greg Schiedler for paying me to implement the |
| 248 |
Events_List routine. They gave me the idea, and were then willing to pay |
| 249 |
me for my time to get it implemented quickly. |
| 250 |
|
| 251 |
I'd also like to thank a couple of authors. Date::Manip has gotten |
| 252 |
some really good press in a couple of books. Since no one's paying me |
| 253 |
to write Date::Manip, seeing my module get a good review in a book |
| 254 |
written by someone else really makes my day. My thanks to Nate |
| 255 |
Padwardhan and Clay Irving (Programming with Perl Modules -- part of |
| 256 |
the O'Reilly Perl Resource Kit); and Tom Christiansen and Nathan |
| 257 |
Torkington (The Perl Cookbook). Also, thanks to any other authors |
| 258 |
who've written about Date::Manip who's books I haven't seen. |
| 259 |
|
| 260 |
I'd also like to thank the people who are maintaining the zoneinfo |
| 261 |
database (and who replied quickly to several inquiries). |
| 262 |
|
| 263 |
I have borrowed from other modules. I originally borrowed the code for |
| 264 |
determining if a year was a leap year from code written by David Muir |
| 265 |
Sharnoff. I borrowed many of the original date printf formats from |
| 266 |
code written by Terry McGonigal as well as the Solaris date command. |
| 267 |
More recently, I borrowed the code to do time zone registry lookups on |
| 268 |
Windows from the DateTime-TimeZone module, though I rewrote it to work |
| 269 |
better with Date::Manip. |
| 270 |
|
| 271 |
=head1 BUGS AND QUESTIONS |
| 272 |
|
| 273 |
Please refer to the L<Date::Manip::Problems> documentation for |
| 274 |
information on submitting bug reports or questions to the author. |
| 275 |
|
| 276 |
=head1 SEE ALSO |
| 277 |
|
| 278 |
L<Date::Manip> - main module documentation |
| 279 |
|
| 280 |
=head1 LICENSE |
| 281 |
|
| 282 |
This script is free software; you can redistribute it and/or |
| 283 |
modify it under the same terms as Perl itself. |
| 284 |
|
| 285 |
=head1 AUTHOR |
| 286 |
|
| 287 |
Sullivan Beck (https://github.com/SBECK-github/) |
| 288 |
|
| 289 |
=cut |