|
Packit |
95306a |
# Copyright (c) 2008-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::Changes5to6 - describes differences between 5.xx and 6.00
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 SYNOPSIS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 6.00 represents a complete rethink and rewrite of
|
|
Packit |
95306a |
Date::Manip. A great deal of effort was made to make sure that 6.00
|
|
Packit |
95306a |
is almost backwards compatible with 5.xx whenever feasible, but some
|
|
Packit |
95306a |
functionality has changed in backwards incompatible ways. Other parts
|
|
Packit |
95306a |
have been deprecated and will be removed at some point in the future.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This document describes the differences between the 5.xx series and
|
|
Packit |
95306a |
version 6.00. This page primarily describes technical details, most of
|
|
Packit |
95306a |
which do not impact how Date::Manip is used in scripts. If you want to
|
|
Packit |
95306a |
make sure that a script which ran with 5.xx will run with 6.xx, refer
|
|
Packit |
95306a |
to the Date::Manip::Migration5to6 document.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 OVERVIEW
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The Date::Manip 5.xx series of suffered from several weaknesses. These
|
|
Packit |
95306a |
included:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Poor time zone support>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Time zone support in 5.xx was broken. Determining a time zone, and
|
|
Packit |
95306a |
understanding daylight saving time changes was incomplete (at best)
|
|
Packit |
95306a |
and totally inadequate to do true timezone operations.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Parsing too complicated and unstructured>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The parsing routines had grown very complicated, and overly permissive
|
|
Packit |
95306a |
over time and were in need of a complete overhaul.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Lacking OO model>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 5.xx was written as a functional module, not an OO module,
|
|
Packit |
95306a |
but date handling would lend itself very well to being OO with different
|
|
Packit |
95306a |
classes to handle dates, deltas, and recurrences.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The OO model allows a lot of information to be stored with each date
|
|
Packit |
95306a |
(such as time zone information) which is discarded in the functional
|
|
Packit |
95306a |
interface.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Too monolithic>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The entire Date::Manip module was contained in one huge file. Breaking
|
|
Packit |
95306a |
up the module would make it much easier to deal with.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 6.00 is a complete rewrite of Date::Manip to address these
|
|
Packit |
95306a |
and other issues.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The following sections address how Date::Manip 6.00 differs from previous
|
|
Packit |
95306a |
releases, and describes changes that might need to be made to your script
|
|
Packit |
95306a |
in order to upgrade from 5.xx to 6.00.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The most important changes are marked with asterisks.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 GENERAL CHANGES
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Requires perl 5.10.0>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Please see the Date::Manip::Problems document for a discussion of
|
|
Packit |
95306a |
this problem. It's in the KNOWN COMPLAINTS section.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Breaking into smaller modules>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip module has been broken up from one huge module into a
|
|
Packit |
95306a |
large number of smaller more manageable modules. The main Date::Manip
|
|
Packit |
95306a |
module is still present, and contains all of the functions from
|
|
Packit |
95306a |
Date::Manip 5.xx (except that they now call functions from all the
|
|
Packit |
95306a |
other modules to do the actual work). In general, the Date::Manip
|
|
Packit |
95306a |
module from 6.00 is backwards compatible.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
A number of new modules have been created as well. These can be used
|
|
Packit |
95306a |
directly, bypassing the main Date::Manip module. These include the
|
|
Packit |
95306a |
following:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip::Base contains many basic date operations which may be
|
|
Packit |
95306a |
used to do simple date manipulation tasks without all the overhead of
|
|
Packit |
95306a |
the full Date::Manip module.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip::TZ contains time zone operations.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Handling dates, deltas, and recurrences are now done in
|
|
Packit |
95306a |
Date::Manip::Date, Date::Manip::Delta, and Date::Manip::Recur.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
All of these modules are object oriented, and are designed to be used
|
|
Packit |
95306a |
directly, so if you prefer an OO interface over a functional
|
|
Packit |
95306a |
interface, use these modules.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Intermediate data cached>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In order to improve the performance of Date::Manip, many intermediate
|
|
Packit |
95306a |
values are cached. This does impact the memory footprint of the module,
|
|
Packit |
95306a |
but it has a huge impact on the performance of the module.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Some types of data depend on the config variables used, and these
|
|
Packit |
95306a |
are cached separately, and this cache is automatically cleared every
|
|
Packit |
95306a |
time a config variable is set. As a result, it is best if you set
|
|
Packit |
95306a |
all config variables at the start, and then leave them alone completely
|
|
Packit |
95306a |
to get optimal use of cached data.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
A side effect of all this is that the Memoize module should not be used
|
|
Packit |
95306a |
in conjunction with Date::Manip.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In the version 5.xx documentation, it was mentioned that the Memoize
|
|
Packit |
95306a |
module might be used to improve performance in some cases. This is no
|
|
Packit |
95306a |
longer the case. It should not be used with Date::Manip, even if you
|
|
Packit |
95306a |
use the functional interface instead of the OO interface.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Taint safe>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip now contains no tainted data, and should run without problems
|
|
Packit |
95306a |
with taint checking on provided you do not set additional methods for
|
|
Packit |
95306a |
determining the system time zone using the curr_zone_methods function.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Ideally, this should never be necessary. If it is necessary, I'd like to
|
|
Packit |
95306a |
hear about it so that I can add whatever standard methods are needed
|
|
Packit |
95306a |
to the built in list.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 TIME ZONE SUPPORT
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Complete handling of time zones>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The biggest problem with Date::Manip 5.xx was it's inability to
|
|
Packit |
95306a |
correctly handle time zones and Daylight Saving Time. That is now
|
|
Packit |
95306a |
fixed. Version 6.00 includes support for every time zone included in
|
|
Packit |
95306a |
the zoneinfo (aka Olson) database which includes the definitions of
|
|
Packit |
95306a |
(hopefully) all of the time zones used in the world.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Individual time zones will no longer be added>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Prior to 5.55, time zones were added upon request. Since 6.00 now
|
|
Packit |
95306a |
supports a full set of standard time zones, I will no longer add in
|
|
Packit |
95306a |
individual time zones (Date::Manip::TZ includes functionality for
|
|
Packit |
95306a |
adding them yourself if they are needed). With Date::Manip now having
|
|
Packit |
95306a |
full time zone support, I'm not interested in supporting my own
|
|
Packit |
95306a |
time zone database.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
However, I am interested in adding sets of time zones from various
|
|
Packit |
95306a |
"standards".
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 6.00 includes time zones from the following standards:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Olson zoneinfo database
|
|
Packit |
95306a |
all Microsoft Windows time zones
|
|
Packit |
95306a |
zones listed in RFC-822
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If there are additional standards that include additional time zones
|
|
Packit |
95306a |
not included here, please point me to them so they can be added.
|
|
Packit |
95306a |
This could include published lists of time zone names supported on
|
|
Packit |
95306a |
some operating system which have different names than the zoneinfo
|
|
Packit |
95306a |
list.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Nonstandard time zone abbreviations removed>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Some of the individual standards that were added in the 5.xx series
|
|
Packit |
95306a |
are not included in any of the standards listed above.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As of 6.00, only time zones from standards will be included in the
|
|
Packit |
95306a |
distribution (others can be added by users using the functions
|
|
Packit |
95306a |
described in Date::Manip::TZ to add aliases for existing time zones).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The following time zones were in Date::Manip 5.xx but not in 6.00.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
IDLW -1200 International Date Line West
|
|
Packit |
95306a |
NT -1100 Nome
|
|
Packit |
95306a |
SAT -0400 Chile
|
|
Packit |
95306a |
CLDT -0300 Chile Daylight
|
|
Packit |
95306a |
AT -0200 Azores
|
|
Packit |
95306a |
MEWT +0100 Middle European Winter
|
|
Packit |
95306a |
MEZ +0100 Middle European
|
|
Packit |
95306a |
FWT +0100 French Winter
|
|
Packit |
95306a |
GB +0100 GMT with daylight saving
|
|
Packit |
95306a |
SWT +0100 Swedish Winter
|
|
Packit |
95306a |
MESZ +0200 Middle European Summer
|
|
Packit |
95306a |
FST +0200 French Summer
|
|
Packit |
95306a |
METDST +0200 An alias for MEST used by HP-UX
|
|
Packit |
95306a |
EETDST +0300 An alias for eest used by HP-UX
|
|
Packit |
95306a |
EETEDT +0300 Eastern Europe, USSR Zone 1
|
|
Packit |
95306a |
BT +0300 Baghdad, USSR Zone 2
|
|
Packit |
95306a |
IT +0330 Iran
|
|
Packit |
95306a |
ZP4 +0400 USSR Zone 3
|
|
Packit |
95306a |
ZP5 +0500 USSR Zone 4
|
|
Packit |
95306a |
IST +0530 Indian Standard
|
|
Packit |
95306a |
ZP6 +0600 USSR Zone 5
|
|
Packit |
95306a |
AWST +0800 Australian Western Standard
|
|
Packit |
95306a |
ROK +0900 Republic of Korea
|
|
Packit |
95306a |
AEST +1000 Australian Eastern Standard
|
|
Packit |
95306a |
ACDT +1030 Australian Central Daylight
|
|
Packit |
95306a |
CADT +1030 Central Australian Daylight
|
|
Packit |
95306a |
AEDT +1100 Australian Eastern Daylight
|
|
Packit |
95306a |
EADT +1100 Eastern Australian Daylight
|
|
Packit |
95306a |
NZT +1200 New Zealand
|
|
Packit |
95306a |
IDLE +1200 International Date Line East
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip now includes a large number of files and modules that
|
|
Packit |
95306a |
are used to support time zones.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
A series of modules are included which are auto-generated from the
|
|
Packit |
95306a |
zoneinfo database. The Date::Manip::Zones, Date::Manip::TZ::*, and
|
|
Packit |
95306a |
Date::Manip::Offset::* modules are all automatically generated and are
|
|
Packit |
95306a |
not intended to be used directly. Instead, the Date::Manip::TZ module
|
|
Packit |
95306a |
is used to access the data stored there.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
A separate time zone module (Date::Manip::TZ::*) is included for every
|
|
Packit |
95306a |
single time zone. There is also a module (Date::Manip::Offset::*) for
|
|
Packit |
95306a |
every different offset. All told, there are almost 1000 modules.
|
|
Packit |
95306a |
These are included to make time zone handling more efficient. Rather
|
|
Packit |
95306a |
than calculating everything on the fly, information about each
|
|
Packit |
95306a |
time zone and offset are included here which greatly speeds up the
|
|
Packit |
95306a |
handling of time zones. These modules are only loaded as needed
|
|
Packit |
95306a |
(i.e. only the modules related to the specific time zones you refer to
|
|
Packit |
95306a |
are ever loaded), so there is no performance penalty to having them.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Also included in the distribution are a script (tzdata) and additional
|
|
Packit |
95306a |
module (Date::Manip::TZdata). These are used to automatically
|
|
Packit |
95306a |
generate the time zone modules, and are of no use to anyone other
|
|
Packit |
95306a |
than the maintainer of Date::Manip. They are included solely for the
|
|
Packit |
95306a |
sake of completeness. If someone wanted to fork Date::Manip, all
|
|
Packit |
95306a |
the tools necessary to do so are included in the distribution.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Meaning of $::TZ and $ENV{TZ}>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.x, you could specify what time zone you wanted to work
|
|
Packit |
95306a |
in using either the $::TZ or $ENV{TZ} variables.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 6.00 makes use of two different time zones: the actual
|
|
Packit |
95306a |
local time zone the computer is running in (and which is used by the
|
|
Packit |
95306a |
system clock), and a time zone that you want to work in. Typically,
|
|
Packit |
95306a |
these are the same, but they do not have to be.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As of Date::Manip 6.00, the $::TZ and $ENV{TZ} variables are used only
|
|
Packit |
95306a |
to specify the actual local time zone.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In order to specify an alternate time zone to work in, use the
|
|
Packit |
95306a |
SetDate or ForceDate config variables.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 CONFIG FILES AND VARIABLES
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Date_Init handling of config variables>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The handling of config variables has changed slightly.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Previously, variables passed in to Date_Init overrode values from
|
|
Packit |
95306a |
config files. This has changed slightly. Options to Date_Init are
|
|
Packit |
95306a |
now parsed in the order they are listed, so the following:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date_Init("DateFormat=Other","ConfigFile=DateManip.cnf")
|
|
Packit |
95306a |
|
|
Packit |
95306a |
would first set the DateFormat variable, and then it would read
|
|
Packit |
95306a |
the config file "DateManip.cnf". If that config file included
|
|
Packit |
95306a |
a DateFormat definition, it would override the one passed in to
|
|
Packit |
95306a |
Date_Init.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The proper way to override config files is to pass the config files
|
|
Packit |
95306a |
in first, followed by any script-specific overrides. In other
|
|
Packit |
95306a |
words:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date_Init("ConfigFile=DateManip.cnf","DateFormat=Other")
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Date_Init doesn't return the config variables>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip::5.xx, Date_Init could return the list of all
|
|
Packit |
95306a |
config variables. This functionality is no longer supported.
|
|
Packit |
95306a |
Date_Init is used strictly to set config variables.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Config file options>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 5.xx had the concept of a global and personal config
|
|
Packit |
95306a |
file. In addition, the personal config file could be looked for
|
|
Packit |
95306a |
in a path of directories. All this was specified using the
|
|
Packit |
95306a |
config variables:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
GlobalCnf
|
|
Packit |
95306a |
IgnoreGlobalCnf
|
|
Packit |
95306a |
PersonalCnf
|
|
Packit |
95306a |
PersonalCnfPath
|
|
Packit |
95306a |
PathSep
|
|
Packit |
95306a |
|
|
Packit |
95306a |
All of these have been removed. Instead, the single config variable:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
ConfigFile
|
|
Packit |
95306a |
|
|
Packit |
95306a |
will be used to specify config files (with no distinction between a
|
|
Packit |
95306a |
global and personal config file). Also, no path searching is
|
|
Packit |
95306a |
done. Each must be specified by a complete path. Finally, any number
|
|
Packit |
95306a |
of config files can be used. So the following is valid:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date_Init("ConfigFile=./Manip.cnf","ConfigFile=/tmp/Manip.cnf")
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Other config variables removed>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The following config variables have been removed.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
TodayIsMidnight Use DefaultTime instead.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
ConvTZ Use SetDate or ForceDate instead.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Internal Use Printable instead.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
DeltaSigns Use the Date::Manip::Delta::printf
|
|
Packit |
95306a |
method to print deltas
|
|
Packit |
95306a |
|
|
Packit |
95306a |
UpdateCurrTZ With real time zone handling in
|
|
Packit |
95306a |
place, this is no longer necessary
|
|
Packit |
95306a |
|
|
Packit |
95306a |
IntCharSet This has been replaced with better support for
|
|
Packit |
95306a |
international character sets. The Encoding config
|
|
Packit |
95306a |
variable may be used instead.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Other config variables deprecated>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The following config variables are deprecated and will be removed
|
|
Packit |
95306a |
in some future version:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
TZ Use SetDate or ForceDate instead.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Holidays>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Previously, holidays could be defined as a "Date + Delta" or "Date -
|
|
Packit |
95306a |
Delta" string. These predate recurrences, and introduce some complexity
|
|
Packit |
95306a |
into the handling of holidays. Since recurrences are a much better
|
|
Packit |
95306a |
way to define holidays, the "Date + Delta" and "Date - Delta" strings
|
|
Packit |
95306a |
are no longer supported.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<TZ replaced (and enhanced)>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The SetDate and ForceDate variables (which include the functionality
|
|
Packit |
95306a |
of the deprecated TZ variable) are much improved as described in the
|
|
Packit |
95306a |
Date::Manip::Config documentation.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Since it is now handles time change correctly (allowing time changes
|
|
Packit |
95306a |
to occur in the alternate time zone), parsed results may be different
|
|
Packit |
95306a |
than in 5.x (but since 5.x didn't have proper time zone handling, this
|
|
Packit |
95306a |
is a good thing).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 DATE PARSING AND OPERATIONS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) today, tomorrow, yesterday>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The words "today", "tomorrow", and "yesterday" in 5.xx referred to the
|
|
Packit |
95306a |
time now, 24 hours in the future, and 24 hours in the past respectively.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As of 6.00, these are treated strictly as date strings, so they are
|
|
Packit |
95306a |
the current day, the day before, or the day after at the time 00:00:00.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The string "now" still refers to the current date and time.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<ISO 8601 formats>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
A couple of the date formats from Date::Manip 5.xx conflicted with ISO
|
|
Packit |
95306a |
8601 formats in the spec. These are documented in the
|
|
Packit |
95306a |
Date::Manip::Date documentation.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Dates are now parsed according to the spec (though a couple extensions
|
|
Packit |
95306a |
have been made, which are also documented in the Date::Manip::Date
|
|
Packit |
95306a |
documentation).
|
|
Packit |
95306a |
|
|
Packit |
95306a |
There is one change with respect to Date::Manip 5.xx that results from
|
|
Packit |
95306a |
a possible misinterpretation of the standard. In Date::Manip, there is
|
|
Packit |
95306a |
a small amount of ambiguity in how the Www-D date formats are
|
|
Packit |
95306a |
understood.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The date:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
1996-w02-3
|
|
Packit |
95306a |
|
|
Packit |
95306a |
might be interpreted in two different ways. It could be interpreted as
|
|
Packit |
95306a |
Wednesday (day 3) of the 2nd week of 1996, or as the 3rd day of the
|
|
Packit |
95306a |
2nd week of 1996 (which would be Tuesday if the week begins on
|
|
Packit |
95306a |
Sunday). Since the specification only works with weeks which begin on
|
|
Packit |
95306a |
day 1, the two are always equivalent in the specification, and the
|
|
Packit |
95306a |
language of the specification doesn't clearly indicate one
|
|
Packit |
95306a |
interpretation over the other.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Since Date::Manip supports the concept of weeks starting on days other
|
|
Packit |
95306a |
than day 1 (Monday), the two interpretations are not equivalent.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, the date was interpreted as Wednesday of the 2nd
|
|
Packit |
95306a |
week, but I now believe that the other interpretation (3rd day of the
|
|
Packit |
95306a |
week) is the interpretation intended by the specification. In addition,
|
|
Packit |
95306a |
if this interpretation is used, it is easy to get the other interpretation.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If 1996-w02-3 means the 3rd day of the 2nd week, then to get Wednesday
|
|
Packit |
95306a |
(day 3) of the week, use the following two Date::Manip::Date methods:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
$err = $date->parse("1996-w02-1");
|
|
Packit |
95306a |
$date2 = $date->next(3,1);
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The first call gets the 1st day of the 2nd week, and the second call
|
|
Packit |
95306a |
gets the next Wednesday.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If 1996-w02-3 is interpreted as Wednesday of the 2nd week, then to
|
|
Packit |
95306a |
get the 3rd day of the week involves significantly more work.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 6.00, the date will now be parsed as the 3rd day of the
|
|
Packit |
95306a |
2nd week.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Parsing is now more rigid>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The philosophy in Date::Manip 5.xx with respect to parsing dates was
|
|
Packit |
95306a |
"if there's any conceivable way to find a valid date in the string, do
|
|
Packit |
95306a |
so". As a result, strings which did not look like they could contain a
|
|
Packit |
95306a |
valid date often would.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This manifested itself it two ways. First, a lot of punctuation was
|
|
Packit |
95306a |
ignored. For example, the string "01 // 03 -. 75" was the date
|
|
Packit |
95306a |
1975-01-03.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Second, a lot of word breaks were optional and it was often acceptable
|
|
Packit |
95306a |
to run strings together. For example, the delta "in5seconds" would
|
|
Packit |
95306a |
have worked.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
With Date::Manip 6.00, parsing now tries to find a valid date in the
|
|
Packit |
95306a |
string, but uses a more rigidly defined set of allowed formats which
|
|
Packit |
95306a |
should more closely match how the dates would actually be expressed in
|
|
Packit |
95306a |
real life. The punctuation allowed is more rigidly defined, and word
|
|
Packit |
95306a |
breaks are required. So "01/03/75" will work, but "01//03/75" and
|
|
Packit |
95306a |
"01/03-75" won't. Also, "in5seconds" will no longer work, though "in 5
|
|
Packit |
95306a |
seconds" will work.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
These changes serve to simplify some of the regular expressions used
|
|
Packit |
95306a |
in parsing dates, as well as simplifying the parsing routines. They
|
|
Packit |
95306a |
also help to recognize actually dates as opposed to typos... it was too
|
|
Packit |
95306a |
easy to pass in garbage and get a date out.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Support dropped for a few formats>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I've dropped support for a few very uncommon (probably never used)
|
|
Packit |
95306a |
formats. These include (with Jan 3, 2009 as an example):
|
|
Packit |
95306a |
|
|
Packit |
95306a |
DD/YYmmm 03/09Jan
|
|
Packit |
95306a |
DD/YYYYmmm 03/2009Jan
|
|
Packit |
95306a |
mmmYYYY/DD Jan2009/03
|
|
Packit |
95306a |
YYYY/DDmmm 2009/03Jan
|
|
Packit |
95306a |
|
|
Packit |
95306a |
mmmYYYY Jan2009
|
|
Packit |
95306a |
YYYYmmm 2009Jan
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The last two are no longer supported since they are incomplete.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
With the exception of the incomplete forms, these could be added back in
|
|
Packit |
95306a |
with very little effort. If there is ever a request to do so, I probably
|
|
Packit |
95306a |
will.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<No longer parses the Apache format>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 5.xx supported the format:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
DD/mmm/YYYY:HH:MN:SS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
used in the apache logs. Due to the stricter parsing, this format
|
|
Packit |
95306a |
is no longer supported directly. However, the parse_format method
|
|
Packit |
95306a |
may be used to parse the date directly from an apache log line
|
|
Packit |
95306a |
with no need to extract the date string beforehand.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Date_PrevWorkDay behavior>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The behavior of Date_PrevWorkDay has changed slightly.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The starting date is checked. If $timecheck was non-zero, the
|
|
Packit |
95306a |
check failed if the date was not a business date, or if the time was
|
|
Packit |
95306a |
not during business hours. If $timecheck was zero, the check failed
|
|
Packit |
95306a |
if the date was not a business date, but the time was ignored.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In 5.xx, if the check failed, and $timecheck was non-zero, day 0
|
|
Packit |
95306a |
was defined as the start of the next business day, but if $timecheck
|
|
Packit |
95306a |
was zero, day 0 was defined as the previous business day at the
|
|
Packit |
95306a |
same time.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In 6.xx, if the check fails, and $timecheck is non-zero, the behavior
|
|
Packit |
95306a |
is the same as before. If $timecheck is zero, day 0 is defined as the
|
|
Packit |
95306a |
next business day at the same time.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
So day 0 is now always the same, where before, day 0 meant two
|
|
Packit |
95306a |
different things depending on whether $timecheck was zero or not.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<(*) Default time>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, the default times for dates was handled in an
|
|
Packit |
95306a |
inconsistent manner. In the Date::Manip::Date documentation, if you
|
|
Packit |
95306a |
parse a date from the "Common date formats" section, in Date::Manip
|
|
Packit |
95306a |
5.xx, if no time was included, it defaulted to "00:00:00". If you
|
|
Packit |
95306a |
parsed a date from the "Less common formats" section, the default time
|
|
Packit |
95306a |
was the current time.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
So running a program on Jun 5, 2009 at noon that parsed the following
|
|
Packit |
95306a |
dates gave the following return values:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Jun 12 => Jun 12, 2009 at 00:00:00
|
|
Packit |
95306a |
next week => Jun 12, 2009 at 12:00:00
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This behavior is changed and now relies on the config variable DefaultTime.
|
|
Packit |
95306a |
If DefaultTime is "curr", the default time for any date which includes no
|
|
Packit |
95306a |
information about the time is the current time. Otherwise, the default time
|
|
Packit |
95306a |
is midnight.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<%z format>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, the %z format would give an offset in the form: -0500.
|
|
Packit |
95306a |
Now it gives it in the form: -05:00:00
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 DELTAS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Dropped mixed style delta parsing>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, a parsed delta could be written in the delta style
|
|
Packit |
95306a |
|
|
Packit |
95306a |
1:2:3
|
|
Packit |
95306a |
|
|
Packit |
95306a |
or in a language-specific expanded form:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
1 hour 2 minutes 3 seconds
|
|
Packit |
95306a |
|
|
Packit |
95306a |
or in a mixed form:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
1 hour 2:3
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The mixed form has been dropped since I doubt that it sees much use in
|
|
Packit |
95306a |
real life, and by dropping the mixed form, the parsing is much
|
|
Packit |
95306a |
simpler.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Approximate date/date calculations>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, the approximate delta between the two dates:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Jan 10 1996 noon
|
|
Packit |
95306a |
Jan 7 1998 noon
|
|
Packit |
95306a |
|
|
Packit |
95306a |
was +1:11:4:0:0:0:0 (or 1 year, 11 months, 4 weeks). As of
|
|
Packit |
95306a |
Date::Manip 6.00, the delta is +2:0:-0:3:0:0:0 (or 2 years minus 3
|
|
Packit |
95306a |
days). Although this leads to mixed-sign deltas, it is actually
|
|
Packit |
95306a |
how more people would think about the delta. It has the additional
|
|
Packit |
95306a |
advantage of being MUCH easier and faster to calculate.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Approximate relationships in deltas>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
When printing parts of deltas in Date::Manip::5.xx, the approximate
|
|
Packit |
95306a |
relationship of 1 year = 365.25 days was used. This is the correct
|
|
Packit |
95306a |
value for the Julian calendar, but for the Gregorian calendar, a
|
|
Packit |
95306a |
better value is 365.2425, and this is used in version 6.00.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Old style formats>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The formats used in the printf command are slightly different than in the
|
|
Packit |
95306a |
old Delta_Format command.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The old formats are described in the Date::Manip::DM5 manual, and the
|
|
Packit |
95306a |
new ones are in the Date::Manip::Delta manual.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The new formats are much more flexible and I encourage you to switch over,
|
|
Packit |
95306a |
however at this point, the old style formats are officially supported for
|
|
Packit |
95306a |
the Delta_Format command.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
At some point, the old style formats may be deprecated (and removed at
|
|
Packit |
95306a |
some point beyond that), but for now, they are not.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The old formats are NOT available using the printf method.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 RECURRENCES
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<The day field meaning changed in a few recurrences>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The value of the day field can refer to several different things
|
|
Packit |
95306a |
including the day of week number (Monday=1 to Sunday=7), day of month (1-31),
|
|
Packit |
95306a |
day of year (1-366), etc.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, it could also refer to the nth day of the week
|
|
Packit |
95306a |
(i.e. 1 being the 1st day of the week, -1 being the last day of the
|
|
Packit |
95306a |
week). This meaning is no longer used in 6.xx.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
For example, the recurrence:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
1*2:3:4:0:0:0
|
|
Packit |
95306a |
|
|
Packit |
95306a |
referred to the 3rd occurrence of the 4th day of the week in February.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The meaning has been changed to refer to the 3rd occurrence of day 4
|
|
Packit |
95306a |
(Thursday) in February. This is a much more useful type of recurrence.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
As a result of this change, the related recurrence:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
1*2:3:-1:0:0:0
|
|
Packit |
95306a |
|
|
Packit |
95306a |
is invalid. Negative numbers may be used to refer to the nth day
|
|
Packit |
95306a |
of the week, but NOT when referring to the day of week numbers.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Recurrence range now inclusive>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Previously, the list of dates implied by the recurrence were on or
|
|
Packit |
95306a |
after the start date, but before the end date.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
This has been changed so that the dates may be on or before the end
|
|
Packit |
95306a |
date.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Dropped support for a couple English recurrences>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Date::Manip 5.xx claimed support for a recurrence:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
every 2nd day in June [1997]
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In actuality, this recurrence is not practical to calculate. It
|
|
Packit |
95306a |
requires a base date which might imply June 1,3,5,... in 1997 but June
|
|
Packit |
95306a |
2,4,6 in 1998.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In addition, the recurrence does not fit the mold for other
|
|
Packit |
95306a |
recurrences that are an approximate distance apart. This type of
|
|
Packit |
95306a |
recurrence has a number of closely spaced events with 11-month gaps
|
|
Packit |
95306a |
between groups.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I no longer consider this a valid recurrence and support is now
|
|
Packit |
95306a |
dropped for this string.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
I also dropped the following for a similar reason:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
every 6th Tuesday [in 1999]
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Other minor recurrence changes>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Previously, ParseRecur would supply default dates if the start or
|
|
Packit |
95306a |
end were missing. This is no longer done.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 DATE::MANIP FUNCTIONS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The Date::Manip module contains the same functions that Date::Manip 5.xx had
|
|
Packit |
95306a |
(though the OO modules do all the work now). In general, the routines behave
|
|
Packit |
95306a |
the same as before with the following exceptions:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=over 4
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<Date_ConvTZ>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Previously, Date_ConvTZ took 1 to 4 arguments and used the local time zone and
|
|
Packit |
95306a |
the ConvTZ config variable to fill in missing arguments.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Now, the Date_ConvTZ function only supports a 3 argument call:
|
|
Packit |
95306a |
|
|
Packit |
95306a |
$date = Date_ConvTZ($date,$from,$to);
|
|
Packit |
95306a |
|
|
Packit |
95306a |
If $from is not given, it defaults to the local time zone. If $to is not given,
|
|
Packit |
95306a |
it defaults to the local time zone.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
The optional 4th argument ($errlevel) is no longer supported. If there is
|
|
Packit |
95306a |
an error, an empty string is returned.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=item B<DateCalc>
|
|
Packit |
95306a |
|
|
Packit |
95306a |
In Date::Manip 5.xx, it was recommended that you pass arguments to
|
|
Packit |
95306a |
ParseDate or ParseDateDelta. This is not recommended with 6.00 since it
|
|
Packit |
95306a |
is much more intelligent about handling the arguments, and you'll just
|
|
Packit |
95306a |
end up parsing the date/delta twice.
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=back
|
|
Packit |
95306a |
|
|
Packit |
95306a |
=head1 BUGS AND QUESTIONS
|
|
Packit |
95306a |
|
|
Packit |
95306a |
Please refer to the L<Date::Manip::Problems> documentation for
|
|
Packit |
95306a |
information on submitting bug reports or questions to the author.
|
|
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
|