|
Packit |
95306a |
# Copyright (c) 1995-2017 Sullivan Beck. All rights reserved.
|
|
Packit |
95306a |
# This program is free software; you can redistribute it and/or modify it
|
|
Packit |
95306a |
# under the same terms as Perl itself.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=pod
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 NAME
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip::Problems - problems and bugs
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 KNOWN PROBLEMS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The following are not bugs in Date::Manip, but they may give some people
|
|
Packit |
95306a |
problems.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Unable to determine Time Zone>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you ever get the message that Date::Manip was unable to determine the
|
|
Packit |
95306a |
timezone, you need to provide that information to your script.
|
|
Packit |
95306a |
Please refer to the L<Date::Manip::TZ> documentation for a discussion
|
|
Packit |
95306a |
of this problem.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Calculations appear to be off by an hour>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Due to daylight saving time (especially the spring change where
|
|
Packit |
95306a |
the time typically moves forward from 02:00 to 03:00), any date
|
|
Packit |
95306a |
calculation which would intuitively report a time in that range
|
|
Packit |
95306a |
will also move forward (or backward as the case may be).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
*NOTE* This should be less of a problem since 6.30 with the addition
|
|
Packit |
95306a |
of semi-exact deltas.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Missing date formats>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Due to the large number of date formats that Date::Manip CAN process,
|
|
Packit |
95306a |
people often assume that other formats that they want to use should
|
|
Packit |
95306a |
work as well, and when they don't, it comes as a surprise.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
With the much improved parsing of 6.00, many formats can be added
|
|
Packit |
95306a |
easily, though unless they are of general use, I'll probably suggest
|
|
Packit |
95306a |
that you use parse_format instead.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
There is a class of formats that I do not plan to add however.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I have frequently been asked to add formats such as "the 15th of last
|
|
Packit |
95306a |
month", or "Monday of next week". I do not intend to add these date
|
|
Packit |
95306a |
formats to Date::Manip, but since I have received the request several
|
|
Packit |
95306a |
times, I decided to include my reasoning here.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip can parse pretty much any static date format that I could
|
|
Packit |
95306a |
think of or find reference to. Dates such as "today", "Jan 12", or
|
|
Packit |
95306a |
"2001-01-01" are all understood.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
These are fairly limited however. Many very common date formats are
|
|
Packit |
95306a |
best thought of as a date plus a modification. For example,
|
|
Packit |
95306a |
"yesterday" is actually determined internally as "today" plus a
|
|
Packit |
95306a |
modification of "- 1 day". "2nd Sunday in June" is determined as
|
|
Packit |
95306a |
"June 1" modified to the 2nd Sunday.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As these types of formats were added over time, I quickly realized
|
|
Packit |
95306a |
that the number of possible date plus modification formats was
|
|
Packit |
95306a |
huge. The number of combinations has caused the parsing in Date::Manip
|
|
Packit |
95306a |
to be quite complex, and adding new formats occasionally causes
|
|
Packit |
95306a |
unexpected conflicts with other formats.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The first time I received a request similar to "the 15th of last
|
|
Packit |
95306a |
month", I intended to add it, but as I analyzed it to see what changes
|
|
Packit |
95306a |
needed to be made to support it, I realized that this needed to be
|
|
Packit |
95306a |
expressed as a date plus TWO modifications. In other words, today
|
|
Packit |
95306a |
modified to last month modified to the 15th day of the month.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As bad as date plus modification formats are, a date plus TWO
|
|
Packit |
95306a |
modifications would be exponentially worse. On realizing that, I
|
|
Packit |
95306a |
decided that Date::Manip will not support this type of format.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Although I apologize for the inconvenience, I do not intend to change
|
|
Packit |
95306a |
my position on this.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Date::Manip is slow>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip is one of the slower Date/Time modules due to the fact that
|
|
Packit |
95306a |
it is huge and written entirely in perl. I have done a lot of work
|
|
Packit |
95306a |
optimizing it since 6.xx came out, and additional work is planned,
|
|
Packit |
95306a |
but even at it's best, it will probably be slower than other modules.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Some things that will definitely help:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 5.xx was very slow. A lot of work went into speeding it up
|
|
Packit |
95306a |
as I rewrote it for the 6.xx release, and it should be noted that
|
|
Packit |
95306a |
initial tests show version 6.xx to be around twice as fast as 5.xx.
|
|
Packit |
95306a |
There is one notable exception to this speedup. If you use Date::Manip
|
|
Packit |
95306a |
to parse dates from a wide variety of timezones, 6.xx will be significantly
|
|
Packit |
95306a |
slower than 5.xx. The reason for this is that each time a new timezone is
|
|
Packit |
95306a |
accessed, 6.xx does quite a bit of work to initialize it. 5.xx does not
|
|
Packit |
95306a |
have this overhead, so it can parse dates from any number of timezones
|
|
Packit |
95306a |
without a speed penalty. However, 5.xx does NOT handle timezones correctly,
|
|
Packit |
95306a |
so many of the dates will be incorrect. If timezones are important to you,
|
|
Packit |
95306a |
there is no way to use 5.xx and get accurate results.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you only parse dates from a single timezone (which is more often what
|
|
Packit |
95306a |
you are doing), 6.xx is significantly faster than 5.xx.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
ISO-8601 dates are parsed first and fastest. If you have the flexibility
|
|
Packit |
95306a |
to define the date format, use ISO-8601 formats whenever possible.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Avoid parsing dates that are referenced against the current time (in 2
|
|
Packit |
95306a |
days, today at noon, etc.). These take a lot longer to parse.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Business date calculations are extremely slow. You should consider
|
|
Packit |
95306a |
alternatives if possible (i.e. doing the calculation in exact mode and
|
|
Packit |
95306a |
then multiplying by 5/7). Who needs a business date more accurate
|
|
Packit |
95306a |
than "6 to 8 weeks" anyway, right :-)
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Memory leak>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
There is a known memory leak in perl related to named regexp captures
|
|
Packit |
95306a |
that directly affects Date::Manip . The leak is in all versions of
|
|
Packit |
95306a |
perl up to (and including) the following versions:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
5.10.1
|
|
Packit |
95306a |
5.12.5
|
|
Packit |
95306a |
5.14.3
|
|
Packit |
95306a |
5.15.5
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The bug has been fixed in:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
5.15.6
|
|
Packit |
95306a |
5.16.0
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If a maintenance release is done for any of the other releases (5.10,
|
|
Packit |
95306a |
5.12, 5.14), that includes the patch, I'll update this section to
|
|
Packit |
95306a |
include that information.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 5.xx is not susceptible, so using it may be a feasible
|
|
Packit |
95306a |
workaround, but if you need accurate timezone handling, this isn't
|
|
Packit |
95306a |
possible.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Simple tests estimate the leak to be about 3 MB per 10,000 dates
|
|
Packit |
95306a |
parsed, so unless you're parsing hundreds of thousands, or millions of
|
|
Packit |
95306a |
dates, the leak probably won't be a problem on systems with moderate
|
|
Packit |
95306a |
amounts of memory. And if you're parsing that many dates, the
|
|
Packit |
95306a |
relatively slow Date::Manip may not be the correct module for you to
|
|
Packit |
95306a |
use anyway.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Dmake error on strawberry perl>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Users of Strawberry perl on windows may encounter an error similar
|
|
Packit |
95306a |
to the following:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
dmake: makefile: line 3016: Error: -- Input line too long, increase MAXLINELENGTH
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This is a known problem with some versions of strawberry perl, and
|
|
Packit |
95306a |
I can't fix it in Date::Manip. If you encounter this problem, you
|
|
Packit |
95306a |
can install the package manually using the commands:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
c:> cpan
|
|
Packit |
95306a |
cpan> look Date::Manip::Date
|
|
Packit |
95306a |
> perl Makefile.PL
|
|
Packit |
95306a |
> dmake MAXLINELENGTH=300000 make
|
|
Packit |
95306a |
> dmake MAXLINELENGTH=300000 make test
|
|
Packit |
95306a |
> dmake MAXLINELENGTH=300000 make install
|
|
Packit |
95306a |
|
|
Packit |
95306a |
You can find more details here:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
http://www.nntp.perl.org/group/perl.win32.vanilla/2011/02/msg287.html
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Using functions/methods which are not supported>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
There have been a handful of incidents of people using a function from
|
|
Packit |
95306a |
Date::Manip which were not documented in the manual.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip consists of a large number of user functions which are
|
|
Packit |
95306a |
documented in the manual. These are designed to be used by other
|
|
Packit |
95306a |
programmers, and I will not make any backwards incompatible changes in
|
|
Packit |
95306a |
them unless there is a very compelling reason to do so, and in that
|
|
Packit |
95306a |
case, the change will be clearly documented in the
|
|
Packit |
95306a |
L<Date::Manip::Changes6> documentation for this module.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip also includes a large number of functions which are NOT
|
|
Packit |
95306a |
documented. These are for internal use only. Please do not use them!
|
|
Packit |
95306a |
I can (and do) change their functionality, and even their name, without notice,
|
|
Packit |
95306a |
and without apology! Some of these internal functions even have test
|
|
Packit |
95306a |
scripts, but that is not a guarantee that they will not change, nor is
|
|
Packit |
95306a |
any support implied. I simply like to run regression tests on as much
|
|
Packit |
95306a |
of Date::Manip as possible.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As of the most recent versions of Date::Manip, all internal functions
|
|
Packit |
95306a |
have names that begin with an underscore (_). If you choose to use
|
|
Packit |
95306a |
them directly, it is quite possible that new versions of Date::Manip
|
|
Packit |
95306a |
will cause your programs to break due to a change in how those
|
|
Packit |
95306a |
functions work.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Any changes to internal functions will not be documented, and will not
|
|
Packit |
95306a |
be regarded by me as a backwards incompatibility. Nor will I (as was
|
|
Packit |
95306a |
requested in one instance) revert to a previous version of the
|
|
Packit |
95306a |
internal function.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you feel that an internal function is of more general use, feel
|
|
Packit |
95306a |
free to contact me with an argument of why it should be "promoted". I
|
|
Packit |
95306a |
welcome suggestions and will definitely consider any such request.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<RCS Control>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you try to put Date::Manip under RCS control, you are going to have
|
|
Packit |
95306a |
problems. Apparently, RCS replaces strings of the form "$Date...$" with
|
|
Packit |
95306a |
the current date. This form occurs all over in Date::Manip. To prevent the
|
|
Packit |
95306a |
RCS keyword expansion, checkout files using:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
co -ko
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Since very few people will ever have a desire to do this (and I don't
|
|
Packit |
95306a |
use RCS), I have not worried about it, and I do not intend to try to
|
|
Packit |
95306a |
workaround this problem.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 KNOWN COMPLAINTS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 6.xx has gotten some complaints (far more than 5.xx if the
|
|
Packit |
95306a |
truth be told), so I'd like to address a couple of them here. Perhaps
|
|
Packit |
95306a |
an understanding of why some of the changes were made will allay some
|
|
Packit |
95306a |
of the complaints. If not, people are always welcome to stick with
|
|
Packit |
95306a |
the 5.xx release. I will continue to support the 5.xx releases for a
|
|
Packit |
95306a |
couple years (though I do NOT plan to add functionality to it).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
These complaints come both from both the CPAN ratings site:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
http://cpanratings.perl.org/dist/Date-Manip
|
|
Packit |
95306a |
|
|
Packit |
95306a |
and from personal email.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Requires perl 5.10>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The single most controversial change made in 6.00 is that it now
|
|
Packit |
95306a |
required perl 5.10.0 or higher. Most of the negative feedback I've
|
|
Packit |
95306a |
received is due to this.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In the past, I've avoided using new features of perl in order to allow
|
|
Packit |
95306a |
Date::Manip to run on older versions of perl. Prior to perl 5.10,
|
|
Packit |
95306a |
none of the new features would have had a major impact on how
|
|
Packit |
95306a |
Date::Manip was written so this practice was justified. That all
|
|
Packit |
95306a |
changed with the release of perl 5.10.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
One of the aspects of Date::Manip that has received the most positive
|
|
Packit |
95306a |
response is the ability to parse almost every conceivable date format.
|
|
Packit |
95306a |
Unfortunately, as I've added formats, the parsing routine became more
|
|
Packit |
95306a |
and more complicated, and maintaining it was one of the least
|
|
Packit |
95306a |
enjoyable aspect in maintaining Date::Manip . In fact, for several
|
|
Packit |
95306a |
years I'd been extremely reluctant to add new formats due to the fact
|
|
Packit |
95306a |
that too often, adding a new format broke other formats.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As I was rewriting Date::Manip, I was looking for ways to improve the
|
|
Packit |
95306a |
parsing and to make maintaining it easier. Perl 5.10 provides the
|
|
Packit |
95306a |
feature "named capture buffers". Named capture buffers not only
|
|
Packit |
95306a |
improves the ease of maintaining the complex regular expressions used
|
|
Packit |
95306a |
by Date::Manip, it makes it dramatically easier to add additional
|
|
Packit |
95306a |
formats in a way that is much less likely to interfere with other
|
|
Packit |
95306a |
formats. The parsing in 6.00 is so much more robust, extensible, and
|
|
Packit |
95306a |
flexible, that it will make parser maintenance possible for many years
|
|
Packit |
95306a |
to come at a fraction of the effort and risk.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
It was too much to turn down. Hopefully, since 5.10 has been out for
|
|
Packit |
95306a |
some time now, this will not prohibit too many people from using the
|
|
Packit |
95306a |
new version of Date::Manip. I realize that there are many people out
|
|
Packit |
95306a |
there using older versions of perl who do not have the option of
|
|
Packit |
95306a |
upgrading perl. The decision to use 5.10 wasn't made lightly... but I
|
|
Packit |
95306a |
don't regret making it. I apologize to users who, as a result, cannot
|
|
Packit |
95306a |
use 6.00 . Hopefully in the future you'll be able to benefit from the
|
|
Packit |
95306a |
improvements in 6.00.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
One complaint I've received is that this in some way makes Date::Manip
|
|
Packit |
95306a |
backwards incompatible, but this is not an accurate complaint. Version
|
|
Packit |
95306a |
6.xx DOES include some backwards incompatibilities (and these are
|
|
Packit |
95306a |
covered in the L<Date::Manip::Migration5to6> document), however in almost
|
|
Packit |
95306a |
all cases, these incompatibilities are with infrequently used
|
|
Packit |
95306a |
features, or workarounds are in place to allow deprecated features to
|
|
Packit |
95306a |
continue functioning for some period of time.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Though I have no data to confirm this, I suspect that 90% or more of
|
|
Packit |
95306a |
all scripts which were written with Date::Manip 5.xx will continue to
|
|
Packit |
95306a |
work unmodified with 6.xx (of course, you should still refer to the
|
|
Packit |
95306a |
migration document to see what features are deprecated or changed to
|
|
Packit |
95306a |
make sure that you don't need to modify your script so that it will
|
|
Packit |
95306a |
continue to work in the future). Even with scripts that need to be
|
|
Packit |
95306a |
changed, the changes should be trivial.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
So, Date::Manip 6.xx is almost entirely backward compatible with 5.xx
|
|
Packit |
95306a |
(to the extent that you would expect any major version release to be
|
|
Packit |
95306a |
compatible with a previous major version).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The change is only in the requirements necessary to get Date::Manip
|
|
Packit |
95306a |
6.xx to run.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Obviously, it's not reasonable to say that Date::Manip should never be
|
|
Packit |
95306a |
allowed to switch minimum perl versions. At some point, you have to
|
|
Packit |
95306a |
let go of an old version if you want to make use of the features of
|
|
Packit |
95306a |
the newer version. The question is, did I jump to 5.10 too fast?
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The negative ratings I see in the CPAN ratings complain that I no
|
|
Packit |
95306a |
longer support perl 5.6 and perl 5.8.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
With respect to 5.6, perl 5.6 was released in March of 2000 (that's
|
|
Packit |
95306a |
before Windows XP which was released in 2001). Date::Manip 6.00 was
|
|
Packit |
95306a |
released at the end of 2009. To be honest, I don't really feel much
|
|
Packit |
95306a |
sympathy for this complaint. Software that is 9 years old is ANCIENT.
|
|
Packit |
95306a |
People may choose to use it... but please don't complain when new
|
|
Packit |
95306a |
software comes out that doesn't support it.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The argument for perl 5.8 is much more compelling. Although 5.8 was
|
|
Packit |
95306a |
released well before Date::Manip 6.00 (July of 2002), there were no
|
|
Packit |
95306a |
major perl releases until 5.10 came out in December of 2007, so 5.8
|
|
Packit |
95306a |
was state-of-the art as little as 2 years prior to the release of
|
|
Packit |
95306a |
Date::Manip 6.xx.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I agree completely with the argument that abandoning 5.8 only 2 years
|
|
Packit |
95306a |
after it was the current version is too soon. For that reason, I
|
|
Packit |
95306a |
continued to support the Date::Manip 5.xx releases for several years.
|
|
Packit |
95306a |
As of December 2012 (5 years after the release of perl 5.10), the 5.xx
|
|
Packit |
95306a |
release is no longer supported (in that I will not patch it or provide
|
|
Packit |
95306a |
support for it's use). However, it is still bundled into the Date::Manip
|
|
Packit |
95306a |
distribution so it can still be used. I do not have any plans for
|
|
Packit |
95306a |
removing it, though I may do so at some point.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Too many modules>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
One minor complaint is that there are too many files. One person
|
|
Packit |
95306a |
specifically objects to the fact that there are over 470 modules
|
|
Packit |
95306a |
covering non-minute offsets. This complaint is (IMO) silly.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip supports ALL historical time zones, including those with
|
|
Packit |
95306a |
non-minute offsets, and so there will be information for those time
|
|
Packit |
95306a |
zones, even though they are not currently in use.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I could of course store all of the information in one big module, but
|
|
Packit |
95306a |
that means that you have to load all of that data every time you use
|
|
Packit |
95306a |
Date::Manip, and I find that to be a very poor solution. Instead,
|
|
Packit |
95306a |
storing the information in a per-time zone and per-offset manner
|
|
Packit |
95306a |
dramatically decreases the amount of data that has to be loaded.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
While it is true that Date::Manip includes over 900 modules for all of
|
|
Packit |
95306a |
the time zone information, most implementations of time zone handling
|
|
Packit |
95306a |
also choose to break up the data into a large number of files.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
My linux distribution (openSuSE 11.2 at the time of writing this) uses
|
|
Packit |
95306a |
the standard zoneinfo database, and at this point, there are over 1700
|
|
Packit |
95306a |
files included in /usr/share/zoneinfo (though it does appear that
|
|
Packit |
95306a |
there is some duplication of information). Current versions of RedHat
|
|
Packit |
95306a |
also use over 1700 files, so Date::Manip isn't treating the time zone
|
|
Packit |
95306a |
data in a new or unreasonable way.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Objects are large>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
One complaint that was put on the CPAN ratings site was that the OO
|
|
Packit |
95306a |
interface is "a dud" due to the size of it's objects. The complaint is
|
|
Packit |
95306a |
that a L<Date::Manip::Date> object is 115K while it should (according to
|
|
Packit |
95306a |
the complaint) only require that you need to save the seconds from the
|
|
Packit |
95306a |
epoch, zone, and a couple other pieces of information, all of which
|
|
Packit |
95306a |
could probably be stored in 100 bytes or less.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This complaint is not accurate, and comes from a misunderstanding
|
|
Packit |
95306a |
of the objects used by Date::Manip.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip is very configurable, and contains a great deal of
|
|
Packit |
95306a |
information which could theoretically be calculated on the fly, but
|
|
Packit |
95306a |
which would greatly reduce it's performance. Instead, in the interest
|
|
Packit |
95306a |
of improving performance, the data is cached, and since the data is
|
|
Packit |
95306a |
virtually all potentially object specific, it has to be somehow linked
|
|
Packit |
95306a |
to the object.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
For example, Date::Manip allows you to parse dates in several
|
|
Packit |
95306a |
languages. Each language has a large number of regular expressions
|
|
Packit |
95306a |
which are used to do the actual parsing. Instead of recreating these
|
|
Packit |
95306a |
regular expressions each time they are needed, they are created once
|
|
Packit |
95306a |
and stored in an object (specifically, a L<Date::Manip::Base> object).
|
|
Packit |
95306a |
The size of the L<Date::Manip::Base> object is almost 15K (due primarily
|
|
Packit |
95306a |
to the regular expressions used in parsing dates in the selected
|
|
Packit |
95306a |
language).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Similarly, a description of the time zones are stored in a second
|
|
Packit |
95306a |
object (a L<Date::Manip::TZ> object). The size of the L<Date::Manip::TZ>
|
|
Packit |
95306a |
object starts at 100K. That may seem excessive, but you have to
|
|
Packit |
95306a |
remember that there are almost 500 time zones, and they have to be
|
|
Packit |
95306a |
indexed by name, alias, abbreviation, and offset. In addition, critical
|
|
Packit |
95306a |
dates (dates where the offset from GMT change such as during a daylight
|
|
Packit |
95306a |
saving time change) along with information such as offsets, abbreviation,
|
|
Packit |
95306a |
etc., are all cached in order to improve performance. By the time you
|
|
Packit |
95306a |
do this, it does take a fair bit of space. It should also be noted
|
|
Packit |
95306a |
that the full description of each timezone is only stored in the
|
|
Packit |
95306a |
object when the timezone is actually used, so if you use a lot of
|
|
Packit |
95306a |
timezones, this object will grow slowly as new timezones are used.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The size of the actual L<Date::Manip::Date> object is a little over 300
|
|
Packit |
95306a |
bytes. However, each includes a pointer to a L<Date::Manip::Base> and
|
|
Packit |
95306a |
a L<Date::Manip::TZ> object (and due to how the object was being looked
|
|
Packit |
95306a |
at in the complaint, they were reporting the size of all three objects,
|
|
Packit |
95306a |
NOT just the L<Date::Manip::Date> object).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Both the L<Date::Manip::Base> and L<Date::Manip::TZ> objects are reused by
|
|
Packit |
95306a |
any number of L<Date::Manip::Date> objects. They can almost be thought of
|
|
Packit |
95306a |
as global data, except that they are accessible in the standard OO
|
|
Packit |
95306a |
manner, and you are allowed to modify them on a per-object basis which
|
|
Packit |
95306a |
WILL mean that you have to store more data. If you work with multiple
|
|
Packit |
95306a |
configurations (see L<Date::Manip::Config>), you'll need multiple Base
|
|
Packit |
95306a |
and TZ objects. However, most of the time you will not need to do
|
|
Packit |
95306a |
this.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The actual L<Date::Manip::Date> object is a bit larger than suggested in
|
|
Packit |
95306a |
the complaint, but it should be noted that Date::Manip actually stores
|
|
Packit |
95306a |
the dates in a number of different formats (a string of the form
|
|
Packit |
95306a |
YYYYMMDDHH:MN:SS and a list [YYYY,MM,DD,HH,MN,SS] in the time zone it
|
|
Packit |
95306a |
was parsed in, the local time zone (if different) and GMT. By caching
|
|
Packit |
95306a |
this information as it is used, it has a huge impact on the
|
|
Packit |
95306a |
performance.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
So, Date::Manip in typical usage consists of one 100K L<Date::Manip::TZ>
|
|
Packit |
95306a |
object, one 15K L<Date::Manip::Base> objects, and any number of small 300
|
|
Packit |
95306a |
byte L<Date::Manip::Date> objects. L<Date::Manip::Delta> objects are even
|
|
Packit |
95306a |
smaller. L<Date::Manip::Recur> objects are also small, but they contain
|
|
Packit |
95306a |
any number of Date objects in them.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I am certainly open to suggestions as to how I can improve the OO
|
|
Packit |
95306a |
interface... but I don't believe it is a dud. While I'm not an expert
|
|
Packit |
95306a |
at OO programming, I believe that I followed pretty standard and
|
|
Packit |
95306a |
accepted procedures for accessing the data.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Please refer to the L<Date::Manip::Objects> document for more
|
|
Packit |
95306a |
information.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Date::Manip has an inconsistent interface>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I've gotten a few complaints that the interface to Date::Manip is
|
|
Packit |
95306a |
inconsistent... and I agree (at least when referring to the functional
|
|
Packit |
95306a |
interfaces).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip was originally written in an unplanned way... as a need/want
|
|
Packit |
95306a |
came up, it was extended. That's not the way to write a major package
|
|
Packit |
95306a |
of course, but it wasn't expected to be a major package at the start.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As it became more and more widely used, I too wished for a more
|
|
Packit |
95306a |
consistent interface, but I did not want to break backward compatibility
|
|
Packit |
95306a |
for everyone using it.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
When 6.xx was written, I spent a good deal of time trying to make a
|
|
Packit |
95306a |
very standard OO interface, so I do not believe that this complaint
|
|
Packit |
95306a |
can be applied to the OO interface (though I'm interested in
|
|
Packit |
95306a |
suggestions for improving it of course).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As far as the functional interface goes, I'll continue to support it
|
|
Packit |
95306a |
in a backward compatible (and therefore inconsistent) form. I'd
|
|
Packit |
95306a |
encourage the use of the OO interface whenever possible.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 BUGS AND QUESTIONS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you find a bug in Date::Manip, there are three ways to send it to me.
|
|
Packit |
95306a |
Any of them are fine, so use the method that is easiest for you.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item Direct email
|
|
Packit |
95306a |
|
|
Packit |
95306a |
You are welcome to send it directly to me by email. The email address
|
|
Packit |
95306a |
to use is: sbeck@cpan.org.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item CPAN Bug Tracking
|
|
Packit |
95306a |
|
|
Packit |
95306a |
You can submit it using the CPAN tracking too. This can be done at the
|
|
Packit |
95306a |
following URL:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
L<http://rt.cpan.org/Public/Dist/Display.html?Name=Date-Manip>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item GitHub
|
|
Packit |
95306a |
|
|
Packit |
95306a |
You can submit it as an issue on GitHub. This can be done at the following
|
|
Packit |
95306a |
URL:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
L<https://github.com/SBECK-github/Date-Manip>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Please do not use other means to report bugs (such as forums for a specific
|
|
Packit |
95306a |
OS or Linux distribution) as it is impossible for me to keep up with all of
|
|
Packit |
95306a |
them.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
When filing a bug report, please include the following information:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Date::Manip version>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Please include the version of Date::Manip you are using. You can get
|
|
Packit |
95306a |
this by using the script:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
use Date::Manip;
|
|
Packit |
95306a |
print DateManipVersion(1),"\n";
|
|
Packit |
95306a |
|
|
Packit |
95306a |
or
|
|
Packit |
95306a |
|
|
Packit |
95306a |
use Date::Manip::Date;
|
|
Packit |
95306a |
$obj = new Date::Manip::Date;
|
|
Packit |
95306a |
print $obj->version(1),"\n";
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Perl information>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Please include the output from "perl -V"
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you have a problem using Date::Manip that perhaps isn't a bug
|
|
Packit |
95306a |
(can't figure out the syntax, etc.), you're in the right place. Start
|
|
Packit |
95306a |
by reading the main Date::Manip documentation, and the other documents
|
|
Packit |
95306a |
that apply to whatever you are trying to do. If this still doesn't
|
|
Packit |
95306a |
answer your question, mail me directly.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I would ask that you be reasonably familiar with the documentation
|
|
Packit |
95306a |
BEFORE you choose to do this. Date::Manip is a hobby, and I simply do
|
|
Packit |
95306a |
not have time to respond to hundreds of questions which are already
|
|
Packit |
95306a |
answered in this manual.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If you find any problems with the documentation (errors, typos, or items
|
|
Packit |
95306a |
that are not clear), please send them to me. I welcome any suggestions
|
|
Packit |
95306a |
that will allow me to improve the documentation.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 KNOWN BUGS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
None known.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 SEE ALSO
|
|
Packit |
95306a |
|
|
Packit |
95306a |
L<Date::Manip> - main module documentation
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 LICENSE
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This script is free software; you can redistribute it and/or
|
|
Packit |
95306a |
modify it under the same terms as Perl itself.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 AUTHOR
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Sullivan Beck (sbeck@cpan.org)
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=cut
|