deprecated/buildtools/buildsystemtools/lib/Date/Manip.pod
author lorewang
Wed, 17 Nov 2010 11:24:29 +0800
changeset 685 39f7ecf8fbc7
parent 655 3f65fd25dfd4
permissions -rw-r--r--
pull from trunk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
# Copyright (c) 1995-2003 Sullivan Beck. All rights reserved.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
# This program is free software; you can redistribute it and/or modify it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
# under the same terms as Perl itself.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
=head1 NAME
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
Date::Manip - date manipulation routines
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
=head1 SYNOPSIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
 use Date::Manip;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
 $date = ParseDate(\@args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
 $date = ParseDate($string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
 $date = ParseDate(\$string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
 @date = UnixDate($date,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
 $date = UnixDate($date,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
 $delta = ParseDateDelta(\@args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
 $delta = ParseDateDelta($string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
 $delta = ParseDateDelta(\$string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
 @str = Delta_Format($delta,$dec,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
 $str = Delta_Format($delta,$dec,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
 $recur = ParseRecur($string,$base,$date0,$date1,$flags);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
 @dates = ParseRecur($string,$base,$date0,$date1,$flags);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
 $flag = Date_Cmp($date1,$date2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
 $d = DateCalc($d1,$d2 [,$errref] [,$del]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
 $date = Date_SetTime($date,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
 $date = Date_SetTime($date,$time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
 $date = Date_SetDateField($date,$field,$val [,$nocheck]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
 $date = Date_GetPrev($date,$dow,$today,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
 $date = Date_GetPrev($date,$dow,$today,$time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    41
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    42
 $date = Date_GetNext($date,$dow,$today,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    43
 $date = Date_GetNext($date,$dow,$today,$time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    44
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    45
 $version = DateManipVersion;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    46
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    47
 $flag = Date_IsWorkDay($date [,$flag]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    48
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    49
 $date = Date_NextWorkDay($date,$off [,$time]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    50
 $date = Date_PrevWorkDay($date,$off [,$time]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    51
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    52
 $name = Date_IsHoliday($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    53
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    54
 $listref = Events_List($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    55
 $listref = Events_List($date0,$date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    56
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    57
 &Date_Init();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    58
 &Date_Init("VAR=VAL","VAR=VAL",...);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    59
 @list = Date_Init();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    60
 @list = Date_Init("VAR=VAL","VAR=VAL",...);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    61
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    62
The above routines all check to make sure that Date_Init is called.  If it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    63
hasn't been, they will call it automatically.  As a result, there is usually
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    64
no need to call Date_Init explicitely unless you want to change some of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    65
config variables (described below).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    66
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    67
The following routines are used by the above routines (though they can also
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    68
be called directly).  $y may be entered as either a 2 or 4 digit year (it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    69
will be converted to a 4 digit year based on the variable YYtoYYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    70
described below).  Month and day should be numeric in all cases.  Most (if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    71
not all) of the information below can be gotten from UnixDate which is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    72
really the way I intended it to be gotten, but there are reasons to use
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    73
these (these are significantly faster).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    74
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    75
***NOTE*** Unlike the routines listed above, the following routines do NOT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    76
explicitely call Date_Init.  You must make sure that Date_Init has been
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    77
called, either by you explicitely, or by one of the above routines before you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    78
use these routines.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    79
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    80
 $day = Date_DayOfWeek($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    81
 $secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    82
 $secs = Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    83
 $days = Date_DaysSince1BC($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    84
 $day = Date_DayOfYear($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    85
 $days = Date_DaysInYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    86
 $wkno = Date_WeekOfYear($m,$d,$y,$first);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    87
 $flag = Date_LeapYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    88
 $day = Date_DaySuffix($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    89
 $tz = Date_TimeZone();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    90
 ($y,$m,$d,$h,$mn,$s) = Date_NthDayOfYear($y,$n);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    91
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    92
=head1 DESCRIPTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    93
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    94
This is a set of routines designed to make any common date/time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    95
manipulation easy to do.  Operations such as comparing two times,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    96
calculating a time a given amount of time from another, or parsing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    97
international times are all easily done.  From the very beginning, the main
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    98
focus of Date::Manip has been to be able to do ANY desired date/time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    99
operation easily, not necessarily quickly.  Also, it is definitely oriented
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   100
towards the type of operations we (as people) tend to think of rather than
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   101
those operations used routinely by computers.  There are other modules that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   102
can do a subset of the operations available in Date::Manip much quicker
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   103
than those presented here, so be sure to read the section SHOULD I USE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   104
DATE::MANIP below before deciding which of the Date and Time modules from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   105
CPAN is for you.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   106
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   107
Date::Manip deals with time as it is presented the Gregorian calendar (the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   108
one currently in use).  The Julian calendar defined leap years as every 4th
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   109
year.  The Gregorian calendar improved this by making every 100th year NOT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   110
a leap year, unless it was also the 400th year.  The Gregorian calendar has
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   111
been extrapolated back to the year 0000 AD and forward to the year 9999 AD.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   112
Note that in historical context, the Julian calendar was in use until 1582
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   113
when the Gregorian calendar was adopted by the Catholic church.  Protestant
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   114
countries did not accept it until later; Germany and Netherlands in 1698,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   115
British Empire in 1752, Russia in 1918.  Note that the Gregorian calendar
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   116
is itself imperfect and at some point will need to be corrected.  No attempt
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   117
is made to correct for that, and my great great great grandchildren will be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   118
long dead before this even occurs, so it's not an immediate concern.  Yes,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   119
this is the same type of attitute that caused the great Y2K problem... but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   120
I have an excuse: I don't know what the correction will be, so I can't
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   121
possible implement it.  Nobody doubted that the year after 1999 would be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   122
known as 2000 :-).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   123
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   124
Date::Manip is therefore not equipped to truly deal with historical dates,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   125
but should be able to perform (virtually) any operation dealing with a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   126
modern time and date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   127
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   128
Date::Manip has (or will have) functionality to work with several fundamental
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   129
types of data.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   130
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   131
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   132
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   133
=item DATE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   134
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   135
Although the word date is used extensively here, it is actually somewhat
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   136
misleading.  Date::Manip works with the full date AND time (year, month,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   137
day, hour, minute, second and weeks when appropriate).  It doesn't work
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   138
with fractional seconds.  Timezones are also supported to some extent.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   139
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   140
NOTE:  Much better support for timezones (including Daylight Savings Time)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   141
is planned for the future.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   142
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   143
=item DELTA
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   144
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   145
This refers to a duration or elapsed time.  One thing to note is that, as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   146
used in this module, a delta refers only to the amount of time elapsed.  It
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   147
includes no information about a starting or ending time.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   149
=item RECURRENCE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   150
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   151
A recurrence is simply a notation for defining when a recurring event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   152
occurs.  For example, if an event occurs every other Friday or every
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   153
4 hours, this can be defined as a recurrence.  With a recurrence and a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   154
starting and ending date, you can get a list of dates in that period when
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   155
a recurring event occurs.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   156
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   157
=item GRAIN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   158
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   159
The granularity of a time basically refers to how accurate you wish to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   160
treat a date.  For example, if you want to compare two dates to see if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   161
they are identical at a granularity of days, then they only have to occur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   162
on the same day.  At a granularity of an hour, they have to occur within
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   163
an hour of each other, etc.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   164
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   165
NOTE:  Support for this will be added in the future.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   166
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   167
=item HOLIDAYS and EVENTS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   168
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   169
These are basically a named time.  Holidays are used in business mode
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   170
calculations.  Events allow things like calendar and scheduling
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   171
applications to be designed much more easily.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   172
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   173
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   174
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   175
Among other things, Date::Manip allow you to:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   176
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   177
1.  Enter a date and be able to choose any format convenient
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   178
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   179
2.  Compare two dates, entered in widely different formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   180
    to determine which is earlier
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   181
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   182
3.  Extract any information you want from ANY date using a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   183
    format string similar to the Unix date command
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   184
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   185
4.  Determine the amount of time between two dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   187
5.  Add a time offset to a date to get a second date (i.e.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   188
    determine the date 132 days ago or 2 years and 3 months
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   189
    after Jan 2, 1992)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   190
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   191
6.  Work with dates with dates using international formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   192
    (foreign month names, 12/10/95 referring to October
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   193
    rather than December, etc.).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   194
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   195
7.  To find a list of dates where a recurring event happens.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   196
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   197
Each of these tasks is trivial (one or two lines at most) with this package.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   198
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   199
=head1 EXAMPLES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   201
In the documentation below, US formats are used, but in most (if not all)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   202
cases, a non-English equivalent will work equally well.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   203
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   204
1.  Parsing a date from any convenient format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   205
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   206
  $date = ParseDate("today");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   207
  $date = ParseDate("1st thursday in June 1992");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   208
  $date = ParseDate("05/10/93");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   209
  $date = ParseDate("12:30 Dec 12th 1880");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   210
  $date = ParseDate("8:00pm december tenth");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   211
  if (! $date) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   212
    # Error in the date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   213
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   214
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   215
2.  Compare two dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   216
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   217
  $date1 = ParseDate($string1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   218
  $date2 = ParseDate($string2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   219
  $flag = Date_Cmp($date1,$date2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   220
  if ($flag<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   221
    # date1 is earlier
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   222
  } elsif ($flag==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   223
    # the two dates are identical
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   224
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   225
    # date2 is earlier
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   226
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   227
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   228
3.  Extract information from a date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   229
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   230
  print &UnixDate("today","It is now %T on %b %e, %Y.");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   231
    =>  "It is now 13:24:08 on Feb  3, 1996."
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   232
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   233
4.  The amount of time between two dates.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   234
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   235
  $date1 = ParseDate($string1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   236
  $date2 = ParseDate($string2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   237
  $delta = DateCalc($date1,$date2,\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   238
    => 0:0:WK:DD:HH:MM:SS   the weeks, days, hours, minutes,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   239
                            and seconds between the two
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   240
  $delta = DateCalc($date1,$date2,\$err,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   241
    => YY:MM:WK:DD:HH:MM:SS  the years, months, etc. between
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   242
                             the two
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   243
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   244
  Read the documentation below for an explanation of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   245
  difference.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   246
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   247
5.  To determine a date a given offset from another.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   248
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   249
  $date = DateCalc("today","+ 3hours 12minutes 6 seconds",\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   250
  $date = DateCalc("12 hours ago","12:30 6Jan90",\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   251
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   252
  It even works with business days:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   253
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   254
  $date = DateCalc("today","+ 3 business days",\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   255
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   256
6.  To work with dates in another language.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   257
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   258
  &Date_Init("Language=French","DateFormat=non-US");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   259
  $date = ParseDate("1er decembre 1990");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   260
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   261
7.  To find a list of dates where a recurring event happens
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   262
    (including quite complex ones).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   263
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   264
  # To find the 2nd tuesday of every month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   265
  @date = ParseRecur("0:1*2:2:0:0:0",$base,$start,$stop);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   266
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   267
  # To find the Monday after easter in 1997-1999.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   268
  @date = ParseRecur("*1997-1999:0:0:0:0:0:0*EASTER,ND1");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   269
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   270
NOTE: Some date forms do not work as well in languages other than English,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   271
but this is not because Date::Manip is incapable of doing so (almost nothing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   272
in this module is language dependent).  It is simply that I do not have the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   273
correct translation available for some words.  If there is a date form that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   274
works in English but does not work in a language you need, let me know and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   275
if you can provide me the translation, I will fix Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   276
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   277
=head1 SHOULD I USE DATE::MANIP
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   278
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   279
If you look in CPAN, you'll find that there are a number of Date and Time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   280
packages.  Is Date::Manip the one you should be using?  In my opinion, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   281
answer is no most of the time.  This sounds odd coming from the author of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   282
the software, but read on.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   283
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   284
Date::Manip is written entirely in perl.  It's the most powerful of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   285
date modules.  It's also the biggest and slowest.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   286
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   287
Since Date::Manip is written entirely in perl, and depends on no other
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   288
module not in a standard perl distribution, Date::Manip has no dependancies
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   289
to meet.  Other modules have dependancies on a C compiler or other perl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   290
modules.  Since it is fairly easy to satisfy these dependancies for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   291
anyone who is reasonably familiar with perl modules, this is not a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   292
huge advantage that Date::Manip has.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   293
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   294
On the other hand, simpler perl modules tend to be faster than Date::Manip,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   295
and modules written in C are significantly faster than their perl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   296
counterparts (at least if they're done right).  The TimeDate and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   297
Time-modules modules are written in perl, but are much simpler (and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   298
hence, faster) than Date::Manip.  The Date::Calc module is written in C
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   299
and is a good module for doing many date calculations much faster than
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   300
Date::Manip.  Between these three, most of your common date operations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   301
can be done.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   302
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   303
Date::Manip is certainly the most powerful of the Date modules.  To the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   304
best of my knowledge, it will do everything that any other date module will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   305
do (not just the ones I listed above), and there are a number of features
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   306
that Date::Manip has that none of the other modules have.  Date::Manip is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   307
the "Swiss Army Knife" of Date modules.  I'm trying to build a library
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   308
which can do _EVERY_ conceivable date/time manipulation that you'll run
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   309
into in everyday life.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   311
Although I am working on making Date::Manip faster, it will never be as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   312
fast as other modules.  And before anyone asks, Date::Manip will never
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   313
be translated to C (at least by me).  I write C because I have to.  I
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   314
write perl because I like to.  Date::Manip is something I do because it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   315
interests me, not something I'm paid for.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   316
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   317
Date::Manip is also big.  The last time I looked, it's one of the largest
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   318
CPAN modules there is.  If you ignore modules like Tk, LWP, etc. which are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   319
actually packages of modules, it may be the largest.  It's true that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   320
Date::Manip will do almost every date operation you could imagine... but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   321
you rarely need all that power.  I'm working on reducing the footprint of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   322
Date::Manip, but even at it's slimmest, it'll outweigh the other modules by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   323
a good bit.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   324
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   325
If you are going to be using the module in cases where performance is an
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   326
important factor (started up in a CGI program being run by your web server
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   327
5,000 times a second), you should check out one of the other Date or Time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   328
modules in CPAN.  If you're only doing fairly simple date operations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   329
(parsing common date formats, finding the difference between two dates,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   330
etc.), the other modules will almost certainly suffice.  If you're doing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   331
one operation very repetitively (parsing 10,000 dates from a database), you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   332
are probably better off writing your own functions (perhaps bypassing all
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   333
date modules entirely) designed specifically for your needs.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   334
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   335
On the other hand, if you want one solution for all your date needs, don't
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   336
need peak speed, or are trying to do more exotic date operations,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   337
Date::Manip is for you.  Operations on things like business dates, foreign
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   338
language dates, holidays and other recurring events, etc. are available
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   339
more-or-less exclusively in Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   340
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   341
=head1 ROUTINES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   342
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   343
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   344
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   345
=item ParseDate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   346
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   347
 $date = ParseDate(\@args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   348
 $date = ParseDate($string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   349
 $date = ParseDate(\$string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   350
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   351
This takes an array or a string containing a date and parses it.  When the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   352
date is included as an array (for example, the arguments to a program) the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   353
array should contain a valid date in the first one or more elements
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   354
(elements after a valid date are ignored).  Elements containing a valid
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   355
date are shifted from the array.  The largest possible number of elements
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   356
which can be correctly interpreted as a valid date are always used.  If a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   357
string is entered rather than an array, that string is tested for a valid
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   358
date.  The string is unmodified, even if passed in by reference.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   359
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   360
The real work is done in the ParseDateString routine.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   361
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   362
The ParseDate routine is primarily used to handle command line arguments.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   363
If you have a command where you want to enter a date as a command line
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   364
argument, you can use Date::Manip to make something like the following
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   365
work:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   366
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   367
  mycommand -date Dec 10 1997 -arg -arg2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   368
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   369
No more reading man pages to find out what date format is required in a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   370
man page.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   371
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   372
Historical note: this is originally why the Date::Manip routines were
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   373
written (though long before they were released as the Date::Manip module).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   374
I was using a bunch of programs (primarily batch queue managers) where
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   375
dates and times were entered as command line options and I was getting
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   376
highly annoyed at the many different (but not compatible) ways that they
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   377
had to be entered.  Date::Manip originally consisted of basically 1 routine
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   378
which I could pass "@ARGV" to and have it remove a date from the beginning.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   379
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   380
=item ParseDateString
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   381
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   382
 $date = ParseDateString($string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   383
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   384
This routine is called by ParseDate, but it may also be called directly
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   385
to save some time (a negligable amount).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   386
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   387
NOTE:  One of the most frequently asked questions that I have gotten
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   388
is how to parse seconds since the epoch.  ParseDateString cannot simply
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   389
parse a number as the seconds since the epoch (it conflicts with some
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   390
ISO-8601 date formats).  There are two ways to get this information.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   391
First, you can do the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   392
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   393
    $secs = ...         # seconds since Jan 1, 1970  00:00:00 GMT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   394
    $date = &DateCalc("Jan 1, 1970  00:00:00 GMT",$secs);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   395
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   396
Second, you can call it directly as:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   397
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   398
    $date = &ParseDateString("epoch $secs");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   399
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   400
To go backwards, just use the "%s" format of UnixDate:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   401
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   402
    $secs = &UnixDate($date,"%s");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   403
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   404
A full date actually includes 2 parts: date and time.  A time must include
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   405
hours and minutes and can optionally include seconds, fractional seconds,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   406
an am/pm type string, and a timezone.  For example:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   407
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   408
     [at] HH:MN              [Zone]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   409
     [at] HH:MN         [am] [Zone]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   410
     [at] HH:MN:SS      [am] [Zone]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   411
     [at] HH:MN:SS.SSSS [am] [Zone]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   412
     [at] HH            am   [Zone]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   413
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   414
Hours can be written using 1 or 2 digits, but the single digit form may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   415
only be used when no ambiguity is introduced (i.e. when it is not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   416
immediately preceded by a digit).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   417
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   418
A time is usually entered in 24 hour mode, but 12 hour mode can be used
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   419
as well if AM/PM are entered (AM can be entered as AM or A.M. or other
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   420
variations depending on the language).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   421
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   422
Fractional seconds are also supported in parsing but the fractional part is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   423
discarded (with NO rounding ocurring).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   424
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   425
Timezones always appear immediately after the time.  A number of different
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   426
forms are supported (see the section TIMEZONEs below).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   427
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   428
Incidentally, the time is removed from the date before the date is parsed,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   429
so the time may appear before or after the date, or between any two parts
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   430
of the date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   431
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   432
Valid date formats include the ISO 8601 formats:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   433
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   434
   YYYYMMDDHHMNSSF...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   435
   YYYYMMDDHHMNSS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   436
   YYYYMMDDHHMN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   437
   YYYYMMDDHH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   438
   YY-MMDDHHMNSSF...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   439
   YY-MMDDHHMNSS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   440
   YY-MMDDHHMN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   441
   YY-MMDDHH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   442
   YYYYMMDD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   443
   YYYYMM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   444
   YYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   445
   YY-MMDD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   446
   YY-MM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   447
   YY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   448
   YYYYwWWD      ex.  1965-W02-2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   449
   YYwWWD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   450
   YYYYDOY       ex.  1965-045
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   451
   YYDOY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   452
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   453
In the above list, YYYY and YY signify 4 or 2 digit years, MM, DD, HH, MN, SS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   454
refer to two digit month, day, hour, minute, and second respectively.  F...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   455
refers to fractional seconds (any number of digits) which will be ignored.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   456
The last 4 formats can be explained by example:  1965-w02-2 refers to Tuesday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   457
(day 2) of the 2nd week of 1965.  1965-045 refers to the 45th day of 1965.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   458
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   459
In all cases, parts of the date may be separated by dashes "-".  If this is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   460
done, 1 or 2 digit forms of MM, DD, etc. may be used.  All dashes are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   461
optional except for those given in the table above (which MUST be included
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   462
for that format to be correctly parsed).  So 19980820, 1998-0820,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   463
1998-08-20, 1998-8-20, and 199808-20 are all equivalent, but that date may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   464
NOT be written as 980820 (it must be written as 98-0820).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   465
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   466
NOTE:  Even though not allowed in the standard, the timezone for an ISO-8601
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   467
date is flexible and may be any of the timezones understood by Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   468
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   469
Additional date formats are available which may or may not be common including:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   470
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   471
  MM/DD  **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   472
  MM/DD/YY  **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   473
  MM/DD/YYYY  **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   474
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   475
  mmmDD       DDmmm                   mmmYYYY/DD     mmmYYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   476
  mmmDD/YY    DDmmmYY     DD/YYmmm    YYYYmmmDD      YYYYmmm
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   477
  mmmDDYYYY   DDmmmYYYY   DDYYYYmmm   YYYY/DDmmm
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   478
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   479
Where mmm refers to the name of a month.  All parts of the date can be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   480
separated by valid separators (space, "/", or ".").  The separator "-" may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   481
be used as long as it doesn't conflict with an ISO 8601 format, but this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   482
is discouraged since it is easy to overlook conflicts.  For example, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   483
format MM/DD/YY is just fine, but MM-DD-YY does not work since it conflicts
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   484
with YY-MM-DD.  To be safe, if "-" is used as a separator in a non-ISO
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   485
format, they should be turned into "/" before calling the Date::Manip
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   486
routines.  As with ISO 8601 formats, all separators are optional except for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   487
those given as a "/" in the list above.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   488
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   489
** Note that with these formats, Americans tend to write month first, but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   490
many other countries tend to write day first.  The latter behavior can be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   491
obtained by setting the config variable DateFormat to something other than
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   492
"US" (see CUSTOMIZING DATE::MANIP below).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   493
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   494
Date separators are treated very flexibly (they are converted to spaces),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   495
so the following dates are all equivalent:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   496
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   497
   12/10/1965
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   498
   12-10 / 1965
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   499
   12 // 10 -. 1965
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   500
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   501
In some cases, this may actually be TOO flexible, but no attempt is made to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   502
trap this.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   503
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   504
Years can be entered as 2 or 4 digits, days and months as 1 or 2 digits.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   505
Both days and months must include 2 digits whenever they are immediately
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   506
adjacent to another numeric part of the date or time.  Date separators
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   507
are required if single digit forms of DD or MM are used.  If separators
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   508
are not used, the date will either be unparsable or will get parsed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   509
incorrectly.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   510
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   511
Miscellaneous other allowed formats are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   512
  which dofw in mmm in YY      "first sunday in june 1996 at 14:00" **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   513
  dofw week num YY             "sunday week 22 1995" **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   514
  which dofw YY                "22nd sunday at noon" **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   515
  dofw which week YY           "sunday 22nd week in 1996" **
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   516
  next/last dofw               "next friday at noon"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   517
  next/last week/month         "next month"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   518
  in num days/weeks/months     "in 3 weeks at 12:00"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   519
  num days/weeks/months later  "3 weeks later"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   520
  num days/weeks/months ago    "3 weeks ago"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   521
  dofw in num week             "Friday in 2 weeks"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   522
  in num weeks dofw            "in 2 weeks on friday"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   523
  dofw num week ago            "Friday 2 weeks ago"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   524
  num week ago dofw            "2 weeks ago friday"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   525
  last day in mmm in YY        "last day of October"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   526
  dofw                         "Friday" (Friday of current week)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   527
  Nth                          "12th", "1st" (day of current month)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   528
  epoch SECS                   seconds since the epoch (negative values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   529
                               are supported)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   530
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   531
** Note that the formats "sunday week 22" and "22nd sunday" give very
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   532
different bahaviors.  "sunday week 22" returns the sunday of the 22nd week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   533
of the year based on how week 1 is defined.  ISO 8601 defines week one to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   534
contain Jan 4, so "sunday week 1" might be the first or second sunday of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   535
the current year, or the last sunday of the previous year.  "22nd sunday"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   536
gives the actual 22nd time sunday occurs in a given year, regardless of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   537
definition of a week.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   538
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   539
Note that certain words such as "in", "at", "of", etc. which commonly appear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   540
in a date or time are ignored.  Also, the year is always optional.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   541
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   542
In addition, the following strings are recognized:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   543
  today     (exactly now OR today at a given time if a time is specified)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   544
  now       (synonym for today)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   545
  yesterday (exactly 24 hours ago unless a time is specified)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   546
  tomorrow  (exactly 24 hours from now unless a time is specifed)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   547
  noon      (12:00:00)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   548
  midnight  (00:00:00)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   549
Other languages have similar (and in some cases additional) strings.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   550
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   551
Some things to note:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   552
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   553
All strings are case insensitive.  "December" and "DEceMBer" both work.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   554
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   555
When a part of the date is not given, defaults are used: year defaults
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   556
to current year; hours, minutes, seconds to 00.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   557
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   558
The year may be entered as 2 or 4 digits.  If entered as 2 digits, it will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   559
be converted to a 4 digit year.  There are several ways to do this based on
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   560
the value of the YYtoYYYY variable (described below).  The default behavior
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   561
it to force the 2 digit year to be in the 100 year period CurrYear-89 to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   562
CurrYear+10.  So in 1996, the range is [1907 to 2006], and the 2 digit year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   563
05 would refer to 2005 but 07 would refer to 1907.  See CUSTOMIZING
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   564
DATE::MANIP below for information on YYtoYYYY for other methods.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   565
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   566
Dates are always checked to make sure they are valid.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   567
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   568
In all of the formats, the day of week ("Friday") can be entered anywhere
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   569
in the date and it will be checked for accuracy.  In other words,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   570
  "Tue Jul 16 1996 13:17:00"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   571
will work but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   572
  "Jul 16 1996 Wednesday 13:17:00"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   573
will not (because Jul 16, 1996 is Tuesday, not Wednesday).  Note that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   574
depending on where the weekday comes, it may give unexpected results when
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   575
used in array context (with ParseDate).  For example, the date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   576
("Jun","25","Sun","1990") would return June 25 of the current year since
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   577
Jun 25, 1990 is not Sunday.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   578
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   579
The times "12:00 am", "12:00 pm", and "midnight" are not well defined.  For
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   580
good or bad, I use the following convention in Date::Manip:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   581
  midnight = 12:00am = 00:00:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   582
  noon     = 12:00pm = 12:00:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   583
and the day goes from 00:00:00 to 23:59:59.  In other words, midnight is the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   584
beginning of a day rather than the end of one.  The time 24:00:00 is also
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   585
allowed (though it is automatically transformed to 00:00:00 of the following
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   586
day).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   587
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   588
The format of the date returned is YYYYMMDDHH:MM:SS.  The advantage of this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   589
time format is that two times can be compared using simple string comparisons
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   590
to find out which is later.  Also, it is readily understood by a human.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   591
Alternate forms can be used if that is more convenient.  See Date_Init below
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   592
and the config variable Internal.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   593
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   594
NOTE: The format for the date is going to change at some point in the future
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   595
to YYYYMMDDHH:MN:SS+HHMN*FLAGS.  In order to maintain compatibility, you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   596
should use UnixDate to extract information from a date, and Date_Cmp to compare
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   597
two dates.  The simple string comparison will only work for dates in the same
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   598
timezone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   599
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   600
=item UnixDate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   601
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   602
 @date = UnixDate($date,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   603
 $date = UnixDate($date,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   604
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   605
This takes a date and a list of strings containing formats roughly
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   606
identical to the format strings used by the UNIX date(1) command.  Each
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   607
format is parsed and an array of strings corresponding to each format is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   608
returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   609
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   610
$date may be any string that can be parsed by ParseDateString.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   611
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   612
The format options are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   613
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   614
 Year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   615
     %y     year                     - 00 to 99
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   616
     %Y     year                     - 0001 to 9999
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   617
     %G     year                     - 0001 to 9999 (see below)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   618
     %L     year                     - 0001 to 9999 (see below)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   619
 Month, Week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   620
     %m     month of year            - 01 to 12
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   621
     %f     month of year            - " 1" to "12"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   622
     %b,%h  month abbreviation       - Jan to Dec
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   623
     %B     month name               - January to December
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   624
     %U     week of year, Sunday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   625
            as first day of week     - 01 to 53
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   626
     %W     week of year, Monday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   627
            as first day of week     - 01 to 53
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   628
 Day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   629
     %j     day of the year          - 001 to 366
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   630
     %d     day of month             - 01 to 31
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   631
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   632
     %e     day of month             - " 1" to "31"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   633
     %v     weekday abbreviation     - " S"," M"," T"," W","Th"," F","Sa"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   634
     %a     weekday abbreviation     - Sun to Sat
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   635
     %A     weekday name             - Sunday to Saturday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   636
     %w     day of week              - 1 (Monday) to 7 (Sunday)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   637
     %E     day of month with suffix - 1st, 2nd, 3rd...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   638
 Hour
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   639
     %H     hour                     - 00 to 23
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   640
     %k     hour                     - " 0" to "23"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   641
     %i     hour                     - " 1" to "12"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   642
     %I     hour                     - 01 to 12
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   643
     %p     AM or PM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   644
 Minute, Second, Timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   645
     %M     minute                   - 00 to 59
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   646
     %S     second                   - 00 to 59
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   647
     %s     seconds from 1/1/1970 GMT- negative if before 1/1/1970
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   648
     %o     seconds from Jan 1, 1970
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   649
            in the current time zone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   650
     %Z     timezone                 - "EDT"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   651
     %z     timezone as GMT offset   - "+0100"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   652
 Date, Time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   653
     %c     %a %b %e %H:%M:%S %Y     - Fri Apr 28 17:23:15 1995
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   654
     %C,%u  %a %b %e %H:%M:%S %z %Y  - Fri Apr 28 17:25:57 EDT 1995
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   655
     %g     %a, %d %b %Y %H:%M:%S %z - Fri, 28 Apr 1995 17:23:15 EDT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   656
     %D,%x  %m/%d/%y                 - 04/28/95
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   657
     %l     date in ls(1) format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   658
              %b %e $H:$M            - Apr 28 17:23  (if within 6 months)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   659
              %b %e  %Y              - Apr 28  1993  (otherwise)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   660
     %r     %I:%M:%S %p              - 05:39:55 PM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   661
     %R     %H:%M                    - 17:40
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   662
     %T,%X  %H:%M:%S                 - 17:40:58
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   663
     %V     %m%d%H%M%y               - 0428174095
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   664
     %Q     %Y%m%d                   - 19961025
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   665
     %q     %Y%m%d%H%M%S             - 19961025174058
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   666
     %P     %Y%m%d%H%M%S             - 1996102517:40:58
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   667
     %F     %A, %B %e, %Y            - Sunday, January  1, 1996
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   668
     %J     %G-W%W-%w                - 1997-W02-2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   669
     %K     %Y-%j                    - 1997-045
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   670
 Other formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   671
     %n     insert a newline character
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   672
     %t     insert a tab character
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   673
     %%     insert a `%' character
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   674
     %+     insert a `+' character
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   675
 The following formats are currently unused but may be used in the future:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   676
     NO 1234567890 !@#$^&*()_|-=\`[];',./~{}:<>?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   677
 They currently insert the character following the %, but may (and probably
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   678
 will) change in the future as new formats are added.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   679
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   680
If a lone percent is the final character in a format, it is ignored.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   681
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   682
Note that the ls format (%l) applies to date within the past OR future 6
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   683
months!
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   684
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   685
The %U, %W, %L, and %G formats are used to support the ISO-8601 format:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   686
YYYY-wWW-D.  In this format, a date is written as a year, the week of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   687
the year, and the day of the week.  Technically, the week may be considered
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   688
to start on any day of the week, but Sunday and Monday are the two most
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   689
common choices, so both are supported.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   690
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   691
The %U and %W formats return a week-of-year number from 01 to 53, and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   692
%L and %G return a 4-digit year corresponding to the week.  Most of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   693
time, the %L and %G formats returns the same value as the %Y format,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   694
but there is a problem with days occuring in the first or last week of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   695
the year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   696
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   697
The ISO-8601 representation of Jan 1, 1993 written in the YYYY-wWWW-D
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   698
format is actually 1992-W53-5.  In other words, Jan 1 is treates as being
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   699
in the last week of the preceding year.  Depending on the year, days in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   700
the first week of a year may belong to the previous year, and days in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   701
final week of a year may belong to the next year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   702
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   703
The %L and %U formats contains the year and week-of-year values treating
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   704
weeks as starting on Sunday.  The %G and %W formats are the year and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   705
week-of-year values treating weeks as starting on Monday.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   706
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   707
%J returns the full ISO-8601 format (%G-W%W-%w).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   708
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   709
The formats used in this routine were originally based on date.pl (version
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   710
3.2) by Terry McGonigal, as well as a couple taken from different versions
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   711
of the Solaris date(1) command.  Also, several have been added which are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   712
unique to Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   713
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   714
=item ParseDateDelta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   715
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   716
 $delta = ParseDateDelta(\@args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   717
 $delta = ParseDateDelta($string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   718
 $delta = ParseDateDelta(\$string);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   719
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   720
This takes an array and shifts a valid delta date (an amount of time)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   721
from the array.  Recognized deltas are of the form:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   722
  +Yy +Mm +Ww +Dd +Hh +MNmn +Ss
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   723
      examples:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   724
         +4 hours +3mn -2second
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   725
         + 4 hr 3 minutes -2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   726
         4 hour + 3 min -2 s
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   727
  +Y:+M:+W:+D:+H:+MN:+S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   728
      examples:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   729
         0:0:0:0:4:3:-2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   730
         +4:3:-2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   731
  mixed format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   732
      examples:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   733
         4 hour 3:-2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   734
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   735
A field in the format +Yy is a sign, a number, and a string specifying
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   736
the type of field.  The sign is "+", "-", or absent (defaults to the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   737
next larger element).  The valid strings specifying the field type
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   738
are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   739
   y:  y, yr, year, years
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   740
   m:  m, mon, month, months
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   741
   w:  w, wk, ws, wks, week, weeks
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   742
   d:  d, day, days
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   743
   h:  h, hr, hour, hours
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   744
   mn: mn, min, minute, minutes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   745
   s:  s, sec, second, seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   746
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   747
Also, the "s" string may be omitted.  The sign, number, and string may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   748
all be separated from each other by any number of whitespaces.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   749
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   750
In the date, all fields must be given in the order: Y M W D H MN S.  Any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   751
number of them may be omitted provided the rest remain in the correct
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   752
order.  In the 2nd (colon) format, from 2 to 7 of the fields may be given.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   753
For example +D:+H:+MN:+S may be given to specify only four of the fields.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   754
In any case, both the MN and S field may be present.  No spaces may be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   755
present in the colon format.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   756
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   757
Deltas may also be given as a combination of the two formats.  For example,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   758
the following is valid: +Yy +D:+H:+MN:+S.  Again, all fields must be given
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   759
in the correct order.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   760
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   761
The word "in" may be given (prepended in English) to the delta ("in 5 years")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   762
and the word "ago" may be given (appended in English) ("6 months ago").  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   763
"in" is completely ignored.  The "ago" has the affect of reversing all signs
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   764
that appear in front of the components of the delta.  I.e. "-12 yr 6 mon ago"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   765
is identical to "+12yr +6mon" (don't forget that there is an implied minus
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   766
sign in front of the 6 because when no sign is explicitly given, it carries
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   767
the previously entered sign).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   768
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   769
One thing is worth noting.  The year/month and day/hour/min/sec parts are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   770
returned in a "normalized" form.  That is, the signs are adjusted so as to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   771
be all positive or all negative.  For example, "+ 2 day - 2hour" does not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   772
return "0:0:0:2:-2:0:0".  It returns "+0:0:0:1:22:0:0" (1 day 22 hours
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   773
which is equivalent).  I find (and I think most others agree) that this is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   774
a more useful form.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   775
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   776
Since the year/month and day/hour/min/sec parts must be normalized
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   777
separately there is the possibility that the sign of the two parts will be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   778
different.  So, the delta "+ 2years -10 months - 2 days + 2 hours" produces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   779
the delta "+1:2:-0:1:22:0:0".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   780
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   781
It is possible to include a sign for all elements that is output.  See the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   782
configuration variable DeltaSigns below.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   783
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   784
NOTE: The internal format of the delta changed in version 5.30 from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   785
Y:M:D:H:MN:S to Y:M:W:D:H:MN:S .  Also, it is going to change again at some
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   786
point in the future to Y:M:W:D:H:MN:S*FLAGS .  Use the routine Delta_Format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   787
to extract information rather than parsing it yourself.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   788
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   789
=item Delta_Format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   790
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   791
 @str = Delta_Format($delta,$dec,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   792
 $str = Delta_Format($delta,$dec,@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   793
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   794
This is similar to the UnixDate routine except that it extracts information
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   795
from a delta.  Unlike the UnixDate routine, most of the formats are 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   796
characters instead of 1.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   797
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   798
Formats currently understood are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   799
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   800
   %Xv     : the value of the field named X
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   801
   %Xd     : the value of the field X, and all smaller fields, expressed in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   802
             units of X
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   803
   %Xh     : the value of field X, and all larger fields, expressed in units
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   804
             of X
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   805
   %Xt     : the value of all fields expressed in units of X
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   806
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   807
   X is one of y,M,w,d,h,m,s (case sensitive).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   808
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   809
   %%      : returns a "%"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   810
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   811
NOTE: Delta_Format only understands "exact" relationships, so for any delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   812
that has a month component, there can be no mixing of the Y/M and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   813
W/D/H/MN/S segments.  In other words, the delta 1:6:1:1:1:1:1 has a month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   814
component, so asking for the total number of years (using the %yd format)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   815
will return 1.5 (which is what 1 year 6 months is).  For deltas which have
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   816
NO month component, the relationship between years and days is known
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   817
(365.25 is used) and all formats work as expected (except that formats with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   818
X equal to "M" are not allowed).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   819
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   820
So, the format "%hd" means the values of H, MN, and S expressed in hours.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   821
So for the delta "0:0:0:0:2:30:0", this format returns 2.5.  Similarly, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   822
format "%yd" means the value (in years) of both the Y and M fields, or,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   823
if the month component is 0, it uses Y, W, D, H, MN, S.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   824
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   825
The format "%hh" returns the value of W, D, and H expressed in hours if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   826
the month component is non-zero, or Y, W, D, H if the month component is 0.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   827
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   828
If $dec is non-zero, the %Xd and %Xt values are formatted to contain $dec
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   829
decimal places.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   830
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   831
=item ParseRecur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   832
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   833
 $recur = ParseRecur($string [,$base,$date0,$date1,$flags]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   834
 @dates = ParseRecur($string [,$base,$date0,$date1,$flags]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   835
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   836
A recurrence refers to a recurring event.  A fully specified recurrence
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   837
requires (in most cases) 4 items: a recur description (describing the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   838
frequency of the event), a base date (a date when the event occurred and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   839
which other occurrences are based on), and a start and end date.  There may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   840
be one or more flags included which modify the behavior of the recur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   841
description.  The fully specified recurrence is written as:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   842
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   843
  recur*flags*base*date0*date1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   844
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   845
Here, base, date0, and date1 are any strings (which must not contain any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   846
asterixes) which can be parsed by ParseDate.  flags is a comma separated
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   847
list of flags (described below), and recur is a string describing a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   848
recurring event.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   849
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   850
If called in scalar context, it returns a string containing a fully
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   851
specified recurrence (or as much of it as can be determined with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   852
unspecified fields left blank).  In list context, it returns a list of all
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   853
dates referred to by a recurrence if enough information is given in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   854
recurrence.  All dates returned are in the range:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   855
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   856
  date0 <= date < date1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   857
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   858
The argument $string can contain any of the parts of a full recurrence.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   859
For example:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   860
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   861
  recur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   862
  recur*flags
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   863
  recur**base*date0*date1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   864
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   865
The only part which is required is the recur description.  Any values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   866
contained in $string are overridden or modified by values passed in as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   867
parameters to ParseRecur.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   868
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   869
A recur description is a string of the format Y:M:W:D:H:MN:S .  Exactly one
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   870
of the colons may optionally be replaced by an asterisk, or an asterisk may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   871
be prepended to the string.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   872
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   873
Any value "N" to the left of the asterisk refers to the "Nth" one.  Any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   874
value to the right of the asterisk refers to a value as it appears on a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   875
calendar/clock.  Values to the right can be listed a single values, ranges
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   876
(2 numbers separated by a dash "-"), or a comma separated list of values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   877
or ranges.  In a few cases, negative values are appropriate.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   878
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   879
This is best illustrated by example.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   880
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   881
  0:0:2:1:0:0:0        every 2 weeks and 1 day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   882
  0:0:0:0:5:30:0       every 5 hours and 30 minutes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   883
  0:0:0:2*12:30:0      every 2 days at 12:30 (each day)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   884
  3*1:0:2:12:0:0       every 3 years on Jan 2 at noon
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   885
  0:1*0:2:12,14:0:0    2nd of every month at 12:00 and 14:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   886
  1:0:0*45:0:0:0       45th day of every year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   887
  0:1*4:2:0:0:0        4th tuesday (day 2) of every month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   888
  0:1*-1:2:0:0:0       last tuesday of every month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   889
  0:1:0*-2:0:0:0       2nd to last day of every month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   890
  0:0:3*2:0:0:0        every 3rd tuesday (every 3 weeks on 2nd day of week)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   891
  1:0*12:2:0:0:0       tuesday of the 12th week of each year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   892
  *1990-1995:12:0:1:0:0:0
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   893
                       Dec 1 in 1990 through 1995
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   894
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   895
  0:1*2:0:0:0:0        the start of the 2nd week of every month (see Note 2)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   896
  1*1:2:0:0:0:0        the start of the 2nd week in January each year (Note 2)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   897
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   898
I realize that this looks a bit cryptic, but after a discussion on the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   899
CALENDAR mailing list, it looked like there was no concise, flexible
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   900
notation for handling recurring events.  ISO 8601 notations were very bulky
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   901
and lacked the flexibility I wanted.  As a result, I developed this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   902
notation (based on crontab formats, but with much more flexibility) which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   903
fits in well with this module, and which is able to express every type of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   904
recurring event I could think of.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   905
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   906
NOTE: If a recurrence has a date0 and date1 in it AND a date0 and date1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   907
are passed in to the function, both sets of criteria apply.  If flags are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   908
passed in, they override any flags in the recurrence UNLESS the flags
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   909
passed in start with a plus (+) character in which case they are appended
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   910
to the flags in the recurrence.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   911
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   912
NOTE: There is no way to express the following with a single recurrence:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   913
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   914
  every day at 12:30 and 1:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   915
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   916
You have to use two recurrences to do this.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   917
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   918
NOTE: A recurrence specifying the week of a month is NOT clearly defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   919
in common usage.  What is the 1st week in a month?  The behavior (with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   920
respect to this module) is well defined (using the FDn and FIn flags
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   921
below), but in common usage, this is so ambiguous that this form should
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   922
probably never be used.  It is included here solely for the sake of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   923
completeness.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   924
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   925
NOTE: Depending on whether M and W are 0 or nonzero, D means different
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   926
things.  This is given in the following table.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   927
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   928
  M  W  D (when right of an asterisk) refers to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   929
  -  -  -------------------------------------------
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   930
  0  0  day of year (1-366)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   931
  M  0  day of month (1-31)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   932
  0  W  day of week (1-7),  W refers to the week of year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   933
  M  W  the Wth (1-5 or -1 to -5) occurrence of Dth (1-7) day of week in month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   934
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   935
NOTE: Base dates are only used with some types of recurrences.  For example,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   936
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   937
  0:0:3*2:0:0:0        every 3rd tuesday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   938
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   939
requires a base date.  If a base date is specified which doesn't match the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   940
criteria (for example, if a base date falling on Monday were passed in with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   941
this recurrence), the base date is moved forward to the first relevant date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   942
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   943
Other dates do not require a base date.  For example:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   944
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   945
  0:0*3:2:0:0:0        third tuesday of every month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   946
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   947
A recurrence written in the above format does NOT provide default values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   948
for base, date0, or date1.  They must be specified in order to get a list
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   949
of dates.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   950
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   951
A base date is not used entirely.  It is only used to provide the parts
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   952
necessary for the left part of a recurrence.  For example, the recurrence:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   953
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   954
  1:3*0:4:0:0:0        every 1 year, 3 months on the 4th day of the month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   955
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   956
would only use the year and month of the base date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   957
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   958
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   959
There are a small handful of English strings which can be parsed in place
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   960
of a numerical recur description.  These include:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   961
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   962
  every 2nd day [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   963
  every 2nd day in June [1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   964
  2nd day of every month [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   965
  2nd tuesday of every month [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   966
  last tuesday of every month [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   967
  every tuesday [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   968
  every 2nd tuesday [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   969
  every 2nd tuesday in June [1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   970
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   971
Each of these set base, date0, and date1 to a default value (the current
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   972
year with Jan 1 being the base date is the default if the year and month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   973
are missing).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   974
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   975
The following flags (case insensitive) are understood:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   976
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   977
  MWn   : n is 1-7.  The first week of the month is the week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   978
          which contains the first occurrence of day n (1=Monday).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   979
          MW2 means that the first week contains the first Tuesday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   980
          of the month.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   981
  MDn   : n is 1-7.  The first week of the month contains the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   982
          actual date (1st through 7th).  MD4 means that the first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   983
          week of the month contains the 4th of that month.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   984
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   985
  PDn   : n is 1-7.  Means the previous day n not counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   986
  PTn   : n is 1-7.  Means the previous day n counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   987
  NDn   : n is 1-7.  Means the next day n not counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   988
  NTn   : n is 1-7.  Means the next day n counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   989
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   990
  FDn   : n is any number.  Means step forward n days.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   991
  BDn   : n is any number.  Means step backward n days.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   992
  FWn   : n is any number.  Means step forward n workdays.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   993
  BWn   : n is any number.  Means step backward n workdays.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   994
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   995
  CWD   : the closest work day (using the TomorrowFirst config variable).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   996
  CWN   : the closest work day (looking forward first).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   997
  CWP   : the closest work day (looking backward first).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   998
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   999
  NWD   : next work day counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1000
  PWD   : previous work day counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1001
  DWD   : next/previous work day (TomorrowFirst config) counting today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1002
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1003
  EASTER: select easter for this year (the M, W, D fields are ignored
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1004
          in the recur).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1005
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1006
NOTE: only one of MWn and MDn can be set.  If both are set, only the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1007
last one is used.  The default is MW7 (i.e. the first week contains
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1008
the first Sunday).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1009
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1010
CWD, CWN, and CWP will usually return the same value, but if you are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1011
starting at the middle day of a 3-day weekend (for example), it will return
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1012
either the first work day of the following week, or the last work day of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1013
the previous week depending on whether it looks forward or backward first.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1014
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1015
All flags are applied AFTER the recurrence dates are calculated, and they
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1016
may move a date outside of the date0 to date1 range.  No check is made for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1017
this.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1018
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1019
The workday flags do not act exactly the same as a business mode calculation.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1020
For example, a date that is Saturday with a FW1 steps forward to the first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1021
workday (i.e. Monday).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1022
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1023
=item Date_Cmp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1024
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1025
 $flag = Date_Cmp($date1,$date2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1026
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1027
This takes two dates and compares them.  Almost all dates can be compared
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1028
using the perl "cmp" command.  The only time this will not work is when
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1029
comparing dates in different timezones.  This routine will take that into
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1030
account.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1031
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1032
NOTE:  This routine currently does little more than use "cmp", but once
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1033
the internal format for storing dates is in place (where timezone information
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1034
is kept as part of the date), this routine will become more important.  You
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1035
should use this routine in prepartation for that version.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1036
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1037
=item DateCalc
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1038
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1039
 $d = DateCalc($d1,$d2 [,\$err] [,$mode]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1040
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1041
This takes two dates, deltas, or one of each and performs the appropriate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1042
calculation with them.  Dates must be a string that can be parsed by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1043
&ParseDateString.  Deltas must be a string that can be parsed by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1044
&ParseDateDelta.  Two deltas add together to form a third delta.  A date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1045
and a delta returns a 2nd date.  Two dates return a delta (the difference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1046
between the two dates).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1047
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1048
Note that in many cases, it is somewhat ambiguous what the delta actually
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1049
refers to.  Although it is ALWAYS known how many months in a year, hours in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1050
a day, etc., it is NOT known how many days form a month.  As a result, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1051
part of the delta containing month/year and the part with sec/min/hr/day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1052
must be treated separately.  For example, "Mar 31, 12:00:00" plus a delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1053
of 1month 2days would yield "May 2 12:00:00".  The year/month is first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1054
handled while keeping the same date.  Mar 31 plus one month is Apr 31 (but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1055
since Apr only has 30 days, it becomes Apr 30).  Apr 30 + 2 days is May 2.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1056
As a result, in the case where two dates are entered, the resulting delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1057
can take on two different forms.  By default ($mode=0), an absolutely
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1058
correct delta (ignoring daylight savings time) is returned in days, hours,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1059
minutes, and seconds.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1060
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1061
If $mode is 1, the math is done using an approximate mode where a delta is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1062
returned using years and months as well.  The year and month part is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1063
calculated first followed by the rest.  For example, the two dates "Mar 12
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1064
1995" and "Apr 13 1995" would have an exact delta of "31 days" but in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1065
approximate mode, it would be returned as "1 month 1 day".  Also, "Mar 31"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1066
and "Apr 30" would have deltas of "30 days" or "1 month" (since Apr 31
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1067
doesn't exist, it drops down to Apr 30).  Approximate mode is a more human
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1068
way of looking at things (you'd say 1 month and 2 days more often then 33
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1069
days), but it is less meaningful in terms of absolute time.  In approximate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1070
mode $d1 and $d2 must be dates.  If either or both is a delta, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1071
calculation is done in exact mode.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1072
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1073
If $mode is 2, a business mode is used.  That is, the calculation is done
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1074
using business days, ignoring holidays, weekends, etc.  In order to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1075
correctly use this mode, a config file must exist which contains the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1076
section defining holidays (see documentation on the config file below).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1077
The config file can also define the work week and the hours of the work
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1078
day, so it is possible to have different config files for different
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1079
businesses.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1080
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1081
For example, if a config file defines the workday as 08:00 to 18:00, a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1082
work week consisting of Mon-Sat, and the standard (American) holidays, then
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1083
from Tuesday at 12:00 to the following Monday at 14:00 is 5 days and 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1084
hours.  If the "end" of the day is reached in a calculation, it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1085
automatically switches to the next day.  So, Tuesday at 12:00 plus 6 hours
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1086
is Wednesday at 08:00 (provided Wed is not a holiday).  Also, a date that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1087
is not during a workday automatically becomes the start of the next
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1088
workday.  So, Sunday 12:00 and Monday at 03:00 both automatically becomes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1089
Monday at 08:00 (provided Monday is not a holiday).  In business mode, any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1090
combination of date and delta may be entered, but a delta should not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1091
contain a year or month field (weeks are fine though).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1092
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1093
See below for some additional comments about business mode calculations.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1094
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1095
Note that a business week is treated the same as an exact week (i.e. from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1096
Tuesday to Tuesday, regardless of holidays).  Because this means that the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1097
relationship between days and weeks is NOT unambiguous, when a delta is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1098
produced from two dates, it will be in terms of d/h/mn/s (i.e. no week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1099
field).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1101
If $mode is 3 (which only applies when two dates are passed in), an exact
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1102
business mode is used.  In this case, it returns a delta as an exact number
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1103
of business days/hours/etc. between the two.  Weeks, months, and years are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1104
ignored.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1105
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1106
Any other non-nil value of $mode is treated as $mode=1 (approximate mode).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1107
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1108
The mode can be automatically set in the dates/deltas passed by including a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1109
key word somewhere in it.  For example, in English, if the word
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1110
"approximately" is found in either of the date/delta arguments, approximate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1111
mode is forced.  Likewise, if the word "business" or "exactly" appears,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1112
business/exact mode is forced (and $mode is ignored).  So, the two
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1113
following are equivalent:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1114
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1115
   $date = DateCalc("today","+ 2 business days",\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1116
   $date = DateCalc("today","+ 2 days",\$err,2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1117
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1118
Note that if the keyword method is used instead of passing in $mode, it is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1119
important that the keyword actually appear in the argument passed in to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1120
DateCalc.  The following will NOT work:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1121
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1122
   $delta = ParseDateDelta("+ 2 business days");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1123
   $today = ParseDate("today");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1124
   $date = DateCalc($today,$delta,\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1126
because the mode keyword is removed from a date/delta by the parse routines,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1127
and the mode is reset each time a parse routine is called.  Since DateCalc
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1128
parses both of its arguments, whatever mode was previously set is ignored.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1130
If \$err is passed in, it is set to:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1131
   1 is returned if $d1 is not a delta or date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1132
   2 is returned if $d2 is not a delta or date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1133
   3 is returned if the date is outside the years 1000 to 9999
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1134
This argument is optional, but if included, it must come before $mode.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1135
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1136
Nothing is returned if an error occurs.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1137
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1138
When a delta is returned, the signs such that it is strictly positive or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1139
strictly negative ("1 day - 2 hours" would never be returned for example).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1140
The only time when this cannot be enforced is when two deltas with a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1141
year/month component are entered.  In this case, only the signs on the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1142
day/hour/min/sec part are standardized.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1143
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1144
=item Date_SetTime
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1145
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1146
 $date = Date_SetTime($date,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1147
 $date = Date_SetTime($date,$time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1149
This takes a date (any string that may be parsed by ParseDateString) and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1150
sets the time in that date.  For example, one way to get the time for 7:30
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1151
tomorrow would be to use the lines:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1152
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1153
   $date = ParseDate("tomorrow");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1154
   $date = Date_SetTime($date,"7:30");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1155
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1156
Note that in this routine (as well as the other routines below which use
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1157
a time argument), no real parsing is done on the times.  As a result,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1158
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1159
   $date = Date_SetTime($date,"13:30");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1160
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1161
works, but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1162
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1163
   $date = Date_SetTime($date,"1:30 PM");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1164
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1165
doesn't.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1166
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1167
=item Date_SetDateField
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1168
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1169
 $date = Date_SetDateField($date,$field,$val [,$nocheck]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1170
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1171
This takes a date and sets one of it's fields to a new value.  $field is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1172
any of the strings "y", "m", "d", "h", "mn", "s" (case insensitive) and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1173
$val is the new value.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1174
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1175
If $nocheck is non-zero, no check is made as to the validity of the date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1176
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1177
=item Date_GetPrev
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1178
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1179
 $date = Date_GetPrev($date,$dow, $curr [,$hr,$min,$sec]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1180
 $date = Date_GetPrev($date,$dow, $curr [,$time]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1181
 $date = Date_GetPrev($date,undef,$curr,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1182
 $date = Date_GetPrev($date,undef,$curr,$time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1183
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1184
This takes a date (any string that may be parsed by ParseDateString) and finds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1185
the previous occurrence of either a day of the week, or a certain time of day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1187
If $dow is defined, the previous occurrence of the day of week is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1188
$dow may either be a string (such as "Fri" or "Friday") or a number
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1189
(between 1 and 7).  The date of the previous $dow is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1190
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1191
If $date falls on the day of week given by $dow, the date returned depends
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1192
on $curr.  If $curr is 0, the date returned is a week before $date.  If
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1193
$curr is 1, the date returned is the same as $date.  If $curr is 2, the date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1194
returned (including the time information) is required to be before $date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1195
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1196
If a time is passed in (either as separate hours, minutes, seconds or as a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1197
time in HH:MM:SS or HH:MM format), the time on this date is set to it.  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1198
following examples should illustrate the use of Date_GetPrev:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1199
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1200
    date                   dow    curr  time            returns
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1201
    Fri Nov 22 18:15:00    Thu    any   12:30           Thu Nov 21 12:30:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1202
    Fri Nov 22 18:15:00    Fri    0     12:30           Fri Nov 15 12:30:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1203
    Fri Nov 22 18:15:00    Fri    1/2   12:30           Fri Nov 22 12:30:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1204
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1205
    Fri Nov 22 18:15:00    Fri    1     18:30           Fri Nov 22 18:30:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1206
    Fri Nov 22 18:15:00    Fri    2     18:30           Fri Nov 15 18:30:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1207
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1208
If $dow is undefined, then a time must be entered, and the date returned is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1209
the previous occurrence of this time.  If $curr is non-zero, the current
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1210
time is returned if it matches the criteria passed in.  In other words, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1211
time returned is the last time that a digital clock (in 24 hour mode) would
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1212
have displayed the time you passed in.  If you define hours, minutes and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1213
seconds default to 0 and you might jump back as much as an entire day.  If
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1214
hours are undefined, you are looking for the last time the minutes/seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1215
appeared on the digital clock, so at most, the time will jump back one hour.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1216
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1217
    date               curr  hr     min    sec      returns
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1218
    Nov 22 18:15:00    0/1   18     undef  undef    Nov 22 18:00:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1219
    Nov 22 18:15:00    0/1   18     30     0        Nov 21 18:30:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1220
    Nov 22 18:15:00    0     18     15     undef    Nov 21 18:15:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1221
    Nov 22 18:15:00    1     18     15     undef    Nov 22 18:15:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1222
    Nov 22 18:15:00    0     undef  15     undef    Nov 22 17:15:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1223
    Nov 22 18:15:00    1     undef  15     undef    Nov 22 18:15:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1224
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1225
=item Date_GetNext
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1226
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1227
 $date = Date_GetNext($date,$dow, $curr [,$hr,$min,$sec]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1228
 $date = Date_GetNext($date,$dow, $curr [,$time]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1229
 $date = Date_GetNext($date,undef,$curr,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1230
 $date = Date_GetNext($date,undef,$curr,$time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1231
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1232
Similar to Date_GetPrev.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1233
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1234
=item Date_IsHoliday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1235
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1236
 $name = Date_IsHoliday($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1237
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1238
This returns undef if $date is not a holiday, or a string containing the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1239
name of the holiday otherwise.  An empty string is returned for an unnamed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1240
holiday.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1241
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1242
=item Events_List
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1243
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1244
 $ref = Events_List($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1245
 $ref = Events_List($date ,0      [,$flag]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1246
 $ref = Events_List($date0,$date1 [,$flag]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1247
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1248
This returns a list of events.  Events are defined in the Events section
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1249
of the config file (discussed below).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1250
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1251
In the first form (a single argument), $date is any string containing a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1252
date.  A list of events active at that precise time will be returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1253
The format is similar to when $flag=0, except only a single time will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1254
be returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1255
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1256
In all other cases, a range of times will be used.  If the 2nd argument
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1257
evaluates to 0, the range of times will be the 24 hour period from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1258
midnight to midnight containing $date.  Otherwise, the range is given
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1259
by the two dates.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1260
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1261
The value of $flag determines the format of the information that is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1262
returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1263
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1264
With $flag=0, the events are returned as a reference to a list of the form:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1265
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1266
  [ date, [ list_of_events ], date, [ list_of_events ], ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1267
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1268
For example, if the following events are defined (using the syntax
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1269
discussed below in the description of the Event section of the config
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1270
file):
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1271
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1272
  2000-01-01 ; 2000-03-21  = Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1273
  2000-03-22 ; 2000-06-21  = Spring
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1274
  2000-02-01               = Event1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1275
  2000-05-01               = Event2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1276
  2000-04-01-12:00:00      = Event3
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1277
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1278
might result in the following output:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1279
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1280
  &Events_List("2000-04-01")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1281
   => [ 2000040100:00:00, [ Spring ] ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1282
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1283
  &Events_List("2000-04-01 12:30");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1284
   => [ 2000040112:30:00, [ Spring, Event3 ] ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1285
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1286
  &Events_List("2000-04-01",0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1287
   => [ 2000040100:00:00, [ Spring ],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1288
        2000040112:00:00, [ Spring, Event3 ],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1289
        2000040113:00:00, [ Spring ] ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1290
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1291
  &Events_List("2000-03-15","2000-04-10");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1292
   => [ 2000031500:00:00, [ Winter ],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1293
        2000032200:00:00, [ Spring ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1294
        2000040112:00:00, [ Spring, Event3 ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1295
        2000040113:00:00, [ Spring ] ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1296
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1297
Much more complicated events can be defined using recurrences.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1298
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1299
When $flag is non-zero, the format of the output is changed.  If $flag
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1300
is 1, then a tally of the amount of time given to each event is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1301
Time for which two or more events apply is counted for both.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1302
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1303
  &Events_List("2000-03-15","2000-04-10",1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1304
   => { Winter => +0:0:1:0:0:0:0,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1305
        Spring => +0:0:2:5:0:0:0,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1306
        Event3 => +0:0:0:0:1:0:0 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1307
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1308
When $flag is 2, a more complex tally with no event counted twice is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1309
returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1311
  &Events_List("2000-03-15","2000-04-10",2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1312
   => { Winter => +0:0:1:0:0:0:0,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1313
        Spring => +0:0:2:4:23:0:0,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1314
        Event3+Spring => +0:0:0:0:1:0:0 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1315
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1316
The hash contains one element for each combination of events.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1317
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1318
=item Date_DayOfWeek
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1319
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1320
 $day = Date_DayOfWeek($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1321
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1322
Returns the day of the week (1 for Monday, 7 for Sunday).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1323
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1324
All arguments must be numeric.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1325
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1326
=item Date_SecsSince1970
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1327
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1328
 $secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1329
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1330
Returns the number of seconds since Jan 1, 1970 00:00 (negative if date is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1331
earlier).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1332
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1333
All arguments must be numeric.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1334
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1335
=item Date_SecsSince1970GMT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1336
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1337
 $secs = Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1338
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1339
Returns the number of seconds since Jan 1, 1970 00:00 GMT (negative if date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1340
is earlier).  If CurrTZ is "IGNORE", the number will be identical to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1341
Date_SecsSince1970 (i.e. the date given will be treated as being in GMT).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1342
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1343
All arguments must be numeric.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1344
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1345
=item Date_DaysSince1BC
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1346
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1347
 $days = Date_DaysSince1BC($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1348
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1349
Returns the number of days since Dec 31, 1BC.  This includes the year 0000.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1350
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1351
All arguments must be numeric.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1352
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1353
=item Date_DayOfYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1354
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1355
 $day = Date_DayOfYear($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1356
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1357
Returns the day of the year (001 to 366)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1358
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1359
All arguments must be numeric.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1360
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1361
=item Date_NthDayOfYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1362
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1363
 ($y,$m,$d,$h,$mn,$s) = Date_NthDayOfYear($y,$n);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1364
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1365
Returns the year, month, day, hour, minutes, and decimal seconds given
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1366
a floating point day of the year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1367
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1368
All arguments must be numeric.  $n must be greater than or equal to 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1369
and less than 366 on non-leap years and 367 on leap years.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1370
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1371
NOTE: When $n is a decimal number, the results are non-intuitive perhaps.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1372
Day 1 is Jan 01 00:00.  Day 2 is Jan 02 00:00.  Intuitively, you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1373
might think of day 1.5 as being 1.5 days after Jan 01 00:00, but this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1374
would mean that Day 1.5 was Jan 02 12:00 (which is later than Day 2).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1375
The best way to think of this function is a timeline starting at 1 and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1376
ending at 366 (in a non-leap year).  In terms of a delta, think of $n
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1377
as the number of days after Dec 31 00:00 of the previous year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1378
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1379
=item Date_DaysInYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1380
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1381
 $days = Date_DaysInYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1382
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1383
Returns the number of days in the year (365 or 366)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1384
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1385
=item Date_DaysInMonth
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1386
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1387
 $days = Date_DaysInMonth($m,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1388
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1389
Returns the number of days in the month.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1390
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1391
=item Date_WeekOfYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1392
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1393
 $wkno = Date_WeekOfYear($m,$d,$y,$first);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1394
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1395
Figure out week number.  $first is the first day of the week which is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1396
usually 1 (Monday) or 7 (Sunday), but could be any number between 1 and 7
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1397
in practice.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1398
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1399
All arguments must be numeric.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1400
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1401
NOTE: This routine should only be called in rare cases.  Use UnixDate with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1402
the %W, %U, %J, %L formats instead.  This routine returns a week between 0
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1403
and 53 which must then be "fixed" to get into the ISO-8601 weeks from 1 to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1404
53.  A date which returns a week of 0 actually belongs to the last week of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1405
the previous year.  A date which returns a week of 53 may belong to the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1406
first week of the next year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1407
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1408
=item Date_LeapYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1409
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1410
 $flag = Date_LeapYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1411
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1412
Returns 1 if the argument is a leap year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1413
Written by David Muir Sharnoff <muir@idiom.com>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1414
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1415
=item Date_DaySuffix
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1416
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1417
 $day = Date_DaySuffix($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1418
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1419
Add `st', `nd', `rd', `th' to a date (ie 1st, 22nd, 29th).  Works for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1420
international dates.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1421
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1422
=item Date_TimeZone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1423
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1424
 $tz = Date_TimeZone;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1425
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1426
This determines and returns the local timezone.  If it is unable to determine
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1427
the local timezone, the following error occurs:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1428
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1429
   ERROR: Date::Manip unable to determine TimeZone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1430
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1431
See The TIMEZONES section below for more information.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1432
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1433
=item Date_ConvTZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1434
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1435
 $date = Date_ConvTZ($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1436
 $date = Date_ConvTZ($date,$from);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1437
 $date = Date_ConvTZ($date,"",$to);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1438
 $date = Date_ConvTZ($date,$from,$to);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1439
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1440
This converts a date (which MUST be in the format returned by ParseDate)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1441
from one timezone to another.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1442
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1443
If it is called with no arguments, the date is converted from the local
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1444
timezone to the timezone specified by the config variable ConvTZ (see
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1445
documentation on ConvTZ below).  If ConvTZ is set to "IGNORE", no
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1446
conversion is done.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1447
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1448
If called with $from but no $to, the timezone is converted from the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1449
timezone in $from to ConvTZ (of TZ if ConvTZ is not set).  Again, no
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1450
conversion is done if ConvTZ is set to "IGNORE".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1451
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1452
If called with $to but no $from, $from defaults to ConvTZ (if set) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1453
local timezone otherwise.  Although this does not seem immediately obvious,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1454
it actually makes sense.  By default, all dates that are parsed are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1455
converted to ConvTZ, so most of the dates being worked with will be stored
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1456
in that timezone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1457
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1458
If Date_ConvTZ is called with both $from and $to, the date is converted
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1459
from the timezone $from to $to.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1460
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1461
NOTE: As in all other cases, the $date returned from Date_ConvTZ has no
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1462
timezone information included as part of it, so calling UnixDate with the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1463
"%z" format will return the timezone that Date::Manip is working in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1464
(usually the local timezone).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1465
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1466
Example:  To convert 2/2/96 noon PST to CST (regardless of what timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1467
you are in, do the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1468
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1469
 $date = ParseDate("2/2/96 noon");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1470
 $date = Date_ConvTZ($date,"PST","CST");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1471
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1472
Both timezones MUST be in one of the formats listed below in the section
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1473
TIMEZONES.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1474
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1475
=item Date_Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1476
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1477
 &Date_Init();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1478
 &Date_Init("VAR=VAL","VAR=VAL",...);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1479
 @list = Date_Init();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1480
 @list = Date_Init("VAR=VAL","VAR=VAL",...);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1481
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1482
Normally, it is not necessary to explicitly call Date_Init.  The first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1483
time any of the other routines are called, Date_Init will be called to set
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1484
everything up.  If for some reason you want to change the configuration of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1485
Date::Manip, you can pass the appropriate string or strings into Date_Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1486
to reinitialize things.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1487
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1488
The strings to pass in are of the form "VAR=VAL".  Any number may be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1489
included and they can come in any order.  VAR may be any configuration
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1490
variable.  A list of all configuration variables is given in the section
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1491
CUSTOMIZING DATE::MANIP below.  VAL is any allowed value for that variable.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1492
For example, to switch from English to French and use non-US format (so
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1493
that 12/10 is Oct 12), do the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1494
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1495
  &Date_Init("Language=French","DateFormat=non-US");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1496
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1497
If Date_Init is called in list context, it will return a list of all
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1498
config variables and their values suitable for passing in to Date_Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1499
to return Date::Manip to the current state.  The only possible problem is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1500
that by default, holidays will not be erased, so you may need to prepend
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1501
the "EraseHolidays=1" element to the list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1502
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1503
=item Date_IsWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1504
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1505
  $flag = Date_IsWorkDay($date [,$flag]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1506
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1507
This returns 1 if $date is a work day.  If $flag is non-zero, the time is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1508
checked to see if it falls within work hours.  It returns an empty string
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1509
if $date is not valid.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1510
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1511
=item Date_NextWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1512
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1513
  $date = Date_NextWorkDay($date,$off [,$time]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1514
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1515
Finds the day $off work days from now.  If $time is passed in, we must also
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1516
take into account the time of day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1517
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1518
If $time is not passed in, day 0 is today (if today is a workday) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1519
next work day if it isn't.  In any case, the time of day is unaffected.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1520
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1521
If $time is passed in, day 0 is now (if now is part of a workday) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1522
start of the very next work day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1523
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1524
=item Date_PrevWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1525
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1526
  $date = Date_PrevWorkDay($date,$off [,$time]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1527
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1528
Similar to Date_NextWorkDay.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1529
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1530
=item Date_NearestWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1531
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1532
  $date = Date_NearestWorkDay($date [,$tomorrowfirst]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1533
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1534
This looks for the work day nearest to $date.  If $date is a work day, it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1535
is returned.  Otherwise, it will look forward or backwards in time 1 day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1536
at a time until a work day is found.  If $tomorrowfirst is non-zero (or if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1537
it is omitted and the config variable TomorrowFirst is non-zero), we look
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1538
to the future first.  Otherwise, we look in the past first.  In other words,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1539
in a normal week, if $date is Wednesday, $date is returned.  If $date is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1540
Saturday, Friday is returned.  If $date is Sunday, Monday is returned.  If
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1541
Wednesday is a holiday, Thursday is returned if $tomorrowfirst is non-nil
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1542
or Tuesday otherwise.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1543
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1544
=item DateManipVersion
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1545
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1546
  $version = DateManipVersion;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1547
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1548
Returns the version of Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1549
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1550
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1551
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1552
=head1 TIMEZONES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1553
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1554
The following timezone names are currently understood (and can be used in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1555
parsing dates).  These are zones defined in RFC 822.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1556
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1557
    Universal:  GMT, UT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1558
    US zones :  EST, EDT, CST, CDT, MST, MDT, PST, PDT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1559
    Military :  A to Z (except J)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1560
    Other    :  +HHMM or -HHMM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1561
    ISO 8601 :  +HH:MM, +HH, -HH:MM, -HH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1562
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1563
In addition, the following timezone abbreviations are also accepted.  In a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1564
few cases, the same abbreviation is used for two different timezones (for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1565
example, NST stands for Newfoundland Standard -0330 and North Sumatra +0630).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1566
In these cases, only 1 of the two is available.  The one preceded by a "#"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1567
sign is NOT available but is documented here for completeness.  This list of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1568
zones comes in part from the Time::Zone module by Graham Barr, David Muir
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1569
Sharnoff, and Paul Foley (with several additions by myself).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1570
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1571
      IDLW    -1200    International Date Line West
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1572
      NT      -1100    Nome
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1573
      HST     -1000    Hawaii Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1574
      CAT     -1000    Central Alaska
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1575
      AHST    -1000    Alaska-Hawaii Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1576
      AKST    -0900    Alaska Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1577
      YST     -0900    Yukon Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1578
      HDT     -0900    Hawaii Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1579
      AKDT    -0800    Alaska Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1580
      YDT     -0800    Yukon Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1581
      PST     -0800    Pacific Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1582
      PDT     -0700    Pacific Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1583
      MST     -0700    Mountain Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1584
      MDT     -0600    Mountain Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1585
      CST     -0600    Central Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1586
      CDT     -0500    Central Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1587
      EST     -0500    Eastern Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1588
      ACT     -0500    Brazil, Acre
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1589
      SAT     -0400    Chile
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1590
      BOT     -0400    Bolivia
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1591
      EDT     -0400    Eastern Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1592
      AST     -0400    Atlantic Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1593
      AMT     -0400    Brazil, Amazon
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1594
      ACST    -0400    Brazil, Acre Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1595
     #NST     -0330    Newfoundland Standard       nst=North Sumatra    +0630
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1596
      NFT     -0330    Newfoundland
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1597
     #GST     -0300    Greenland Standard          gst=Guam Standard    +1000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1598
     #BST     -0300    Brazil Standard             bst=British Summer   +0100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1599
      BRST    -0300    Brazil Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1600
      BRT     -0300    Brazil Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1601
      AMST    -0300    Brazil, Amazon Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1602
      ADT     -0300    Atlantic Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1603
      ART     -0300    Argentina
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1604
      NDT     -0230    Newfoundland Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1605
      AT      -0200    Azores
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1606
      BRST    -0200    Brazil Daylight (official time)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1607
      FNT     -0200    Brazil, Fernando de Noronha
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1608
      WAT     -0100    West Africa
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1609
      FNST    -0100    Brazil, Fernando de Noronha Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1610
      GMT     +0000    Greenwich Mean
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1611
      UT      +0000    Universal (Coordinated)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1612
      UTC     +0000    Universal (Coordinated)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1613
      WET     +0000    Western European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1614
      CET     +0100    Central European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1615
      FWT     +0100    French Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1616
      MET     +0100    Middle European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1617
      MEZ     +0100    Middle European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1618
      MEWT    +0100    Middle European Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1619
      SWT     +0100    Swedish Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1620
      BST     +0100    British Summer              bst=Brazil standard  -0300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1621
      GB      +0100    GMT with daylight savings
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1622
      WEST    +0000    Western European Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1623
      CEST    +0200    Central European Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1624
      EET     +0200    Eastern Europe, USSR Zone 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1625
      FST     +0200    French Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1626
      MEST    +0200    Middle European Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1627
      MESZ    +0200    Middle European Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1628
      METDST  +0200    An alias for MEST used by HP-UX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1629
      SAST    +0200    South African Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1630
      SST     +0200    Swedish Summer              sst=South Sumatra    +0700
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1631
      EEST    +0300    Eastern Europe Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1632
      BT      +0300    Baghdad, USSR Zone 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1633
      MSK     +0300    Moscow
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1634
      EAT     +0300    East Africa
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1635
      IT      +0330    Iran
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1636
      ZP4     +0400    USSR Zone 3
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1637
      MSD     +0300    Moscow Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1638
      ZP5     +0500    USSR Zone 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1639
      IST     +0530    Indian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1640
      ZP6     +0600    USSR Zone 5
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1641
      NOVST   +0600    Novosibirsk time zone, Russia
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1642
      NST     +0630    North Sumatra               nst=Newfoundland Std -0330
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1643
     #SST     +0700    South Sumatra, USSR Zone 6  sst=Swedish Summer   +0200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1644
      JAVT    +0700    Java
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1645
      CCT     +0800    China Coast, USSR Zone 7
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1646
      AWST    +0800    Australian Western Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1647
      WST     +0800    West Australian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1648
      PHT     +0800    Asia Manila
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1649
      JST     +0900    Japan Standard, USSR Zone 8
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1650
      ROK     +0900    Republic of Korea
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1651
      ACST    +0930    Australian Central Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1652
      CAST    +0930    Central Australian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1653
      AEST    +1000    Australian Eastern Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1654
      EAST    +1000    Eastern Australian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1655
      GST     +1000    Guam Standard, USSR Zone 9  gst=Greenland Std    -0300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1656
      ACDT    +1030    Australian Central Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1657
      CADT    +1030    Central Australian Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1658
      AEDT    +1100    Australian Eastern Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1659
      EADT    +1100    Eastern Australian Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1660
      IDLE    +1200    International Date Line East
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1661
      NZST    +1200    New Zealand Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1662
      NZT     +1200    New Zealand
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1663
      NZDT    +1300    New Zealand Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1664
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1665
Others can be added in the future upon request.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1666
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1667
Date::Manip must be able to determine the timezone the user is in.  It does
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1668
this by looking in the following places:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1669
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1670
   $Date::Manip::TZ (set with Date_Init or in Manip.pm)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1671
   $ENV{TZ}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1672
   the unix `date` command (if available)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1673
   $main::TZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1674
   /etc/TIMEZONE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1675
   /etc/timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1676
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1677
At least one of these should contain a timezone in one of the supported
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1678
forms.  If none do by default, the TZ variable must be set with Date_Init.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1679
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1680
The timezone may be in the STD#DST format (in which case both abbreviations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1681
must be in the table above) or any of the formats described above.  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1682
STD#DST format is NOT available when parsing a date however.  The following
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1683
forms are also available and are treated similar to the STD#DST forms:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1684
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1685
      US/Pacific
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1686
      US/Mountain
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1687
      US/Central
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1688
      US/Eastern
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1689
      Canada/Pacific
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1690
      Canada/Mountain
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1691
      Canada/Central
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1692
      Canada/Eastern
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1693
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1694
=head1 BUSINESS MODE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1695
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1696
Anyone using business mode is going to notice a few quirks about it which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1697
should be explained.  When I designed business mode, I had in mind what UPS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1698
tells me when they say 2 day delivery, or what the local business which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1699
promises 1 business day turnaround really means.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1700
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1701
If you do a business day calculation (with the workday set to 9:00-5:00),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1702
you will get the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1703
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1704
   Saturday at noon + 1 business day = Tuesday at 9:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1705
   Saturday at noon - 1 business day = Friday at 9:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1706
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1707
What does this mean?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1708
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1709
We have a business that works 9-5 and they have a drop box so I can drop
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1710
things off over the weekend and they promise 1 business day turnaround.  If
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1711
I drop something off Friday night, Saturday, or Sunday, it doesn't matter.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1712
They're going to get started on it Monday morning.  It'll be 1 business day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1713
to finish the job, so the earliest I can expect it to be done is around
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1714
17:00 Monday or 9:00 Tuesday morning.  Unfortunately, there is some
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1715
ambiguity as to what day 17:00 really falls on, similar to the ambiguity
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1716
that occurs when you ask what day midnight falls on.  Although it's not the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1717
only answer, Date::Manip treats midnight as the beginning of a day rather
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1718
than the end of one.  In the same way, 17:00 is equivalent to 9:00 the next
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1719
day and any time the date calculations encounter 17:00, it automatically
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1720
switch to 9:00 the next day.  Although this introduces some quirks, I think
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1721
this is justified.  You just have to treat 17:00/9:00 as being ambiguous
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1722
(in the same way you treat midnight as being ambiguous).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1723
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1724
Equivalently, if I want a job to be finished on Saturday (despite the fact
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1725
that I cannot pick it up since the business is closed), I have to drop it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1726
off no later than Friday at 9:00.  That gives them a full business day to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1727
finish it off.  Of course, I could just as easily drop it off at 17:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1728
Thursday, or any time between then and 9:00 Friday.  Again, it's a matter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1729
of treating 9:00 as ambiguous.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1730
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1731
So, in case the business date calculations ever produce results that you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1732
find confusing, I believe the solution is to write a wrapper which,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1733
whenever it sees a date with the time of exactly 9:00, it treats it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1734
specially (depending on what you want.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1735
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1736
So Saturday + 1 business day = Tuesday at 9:00 (which means anything
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1737
from Monday 17:00 to Tuesday 9:00), but Monday at 9:01 + 1 business
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1738
day = Tuesday at 9:01 which is exact.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1739
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1740
If this is not exactly what you have in mind, don't use the DateCalc
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1741
routine.  You can probably get whatever behavior you want using the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1742
routines Date_IsWorkDay, Date_NextWorkDay, and Date_PrevWorkDay described
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1743
above.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1744
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1745
=head1 CUSTOMIZING DATE::MANIP
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1746
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1747
There are a number of variables which can be used to customize the way
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1748
Date::Manip behaves.  There are also several ways to set these variables.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1749
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1750
At the top of the Manip.pm file, there is a section which contains all
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1751
customization variables.  These provide the default values.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1752
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1753
These can be overridden in a global config file if one is present (this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1754
file is optional).  If the GlobalCnf variable is set in the Manip.pm file,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1755
it contains the full path to a config file.  If the file exists, it's
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1756
values will override those set in the Manip.pm file.  A sample config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1757
is included with the Date::Manip distribution.  Modify it as appropriate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1758
and copy it to some appropriate directory and set the GlobalCnf variable in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1759
the Manip.pm file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1760
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1761
Each user can have a personal config file which is of the same form as the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1762
global config file.  The variables PersonalCnf and PersonalCnfPath set the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1763
name and search path for the personal config file.  This file is also
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1764
optional.  If present, it overrides any values set in the global file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1765
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1766
NOTE: if you use business mode calculations, you must have a config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1767
(either global or personal) since this is the only place where you can
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1768
define holidays.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1769
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1770
Finally, any variables passed in through Date_Init override all other
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1771
values.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1772
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1773
A config file can be composed of several sections.  The first section sets
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1774
configuration variables.  Lines in this section are of the form:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1775
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1776
   VARIABLE = VALUE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1777
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1778
For example, to make the default language French, include the line:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1779
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1780
   Language = French
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1781
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1782
Only variables described below may be used.  Blank lines and lines beginning
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1783
with a pound sign (#) are ignored.  All spaces are optional and strings are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1784
case insensitive.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1785
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1786
A line which starts with an asterisk (*) designates a new section.  For
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1787
example, the HOLIDAY section starts with a line:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1788
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1789
   *Holiday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1790
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1791
The various sections are defined below.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1792
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1793
=head1 DATE::MANIP VARIABLES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1794
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1795
All Date::Manip variables which can be used are described in the following
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1796
section.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1797
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1798
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1799
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1800
=item IgnoreGlobalCnf
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1801
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1802
If this variable is used (any value is ignored), the global config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1803
is not read.  It must be present in the initial call to Date_Init or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1804
global config file will be read.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1805
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1806
=item EraseHolidays
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1807
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1808
If this variable is used (any value is ignored), the current list of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1809
defined holidays is erased.  A new set will be set the next time a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1810
config file is read in.  This can be set in either the global config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1811
or as a Date_Init argument (in which case holidays can be read in from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1812
both the global and personal config files) or in the personal config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1813
(in which case, only holidays in the personal config file are counted).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1814
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1815
=item PathSep
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1816
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1817
This is a regular expression used to separate multiple paths.  For example,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1818
on Unix, it defaults to a colon (:) so that multiple paths can be written
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1819
PATH1:PATH2 .  For Win32 platforms, it defaults to a semicolon (;) so that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1820
paths such as "c:\;d:\" will work.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1821
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1822
=item GlobalCnf
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1823
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1824
This variable can be passed into Date_Init to point to a global
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1825
configuration file.  The value must be the complete path to a config file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1826
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1827
By default, no global config file is read.  Any time a global config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1828
is read, the holidays are erased.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1829
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1830
Paths may have a tilde (~) expansion on platforms where this is supported
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1831
(currently Unix and VMS).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1832
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1833
=item PersonalCnf
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1834
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1835
This variable can be passed into Date_Init or set in a global config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1836
to set the name of the personal configuration file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1837
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1838
The default name for the config file is .DateManip.cnf on all Unix
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1839
platforms and Manip.cnf on all non-Unix platforms (because some of them
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1840
insist on 8.3 character filenames :-).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1841
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1842
=item PersonalCnfPath
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1843
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1844
This is a list of paths separated by the separator specified by the PathSep
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1845
variable.  These paths are each checked for the PersonalCnf config file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1846
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1847
Paths may have a tilde (~) expansion on platforms where this is supported
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1848
(currently Unix and VMS).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1849
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1850
=item Language
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1851
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1852
Date::Manip can be used to parse dates in many different languages.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1853
Currently, it is configured to read  the following languages (the version
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1854
in which they added is included for historical interest):
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1855
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1856
  English      (default)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1857
  French       (5.02)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1858
  Swedish      (5.05)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1859
  German       (5.31)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1860
  Dutch        (5.32)     aka Nederlands
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1861
  Polish       (5.32)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1862
  Spanish      (5.33)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1863
  Portuguese   (5.34)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1864
  Romanian     (5.35)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1865
  Italian      (5.35)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1866
  Russian      (5.41)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1867
  Turkish      (5.41)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1868
  Danish       (5.41)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1869
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1870
Others can be added easily.  Language is set to the language used to parse
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1871
dates.  If you are interested in providing a translation for a new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1872
language, email me (see the AUTHOR section below) and I'll send you a list
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1873
of things that I need.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1874
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1875
=item DateFormat
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1876
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1877
Different countries look at the date 12/10 as Dec 10 or Oct 12.  In the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1878
United States, the first is most common, but this certainly doesn't hold
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1879
true for other countries.  Setting DateFormat to "US" forces the first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1880
behavior (Dec 10).  Setting DateFormat to anything else forces the second
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1881
behavior (Oct 12).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1882
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1883
=item TZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1884
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1885
If set, this defines the local timezone.  See the TIMEZONES section above
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1886
for information on it's format.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1887
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1888
=item ConvTZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1889
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1890
All date comparisons and calculations must be done in a single time zone in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1891
order for them to work correctly.  So, when a date is parsed, it should be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1892
converted to a specific timezone.  This allows dates to easily be compared
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1893
and manipulated as if they are all in a single timezone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1894
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1895
The ConvTZ variable determines which timezone should be used to store dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1896
in.  If it is left blank, all dates are converted to the local timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1897
(see the TZ variable above).  If it is set to one of the timezones listed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1898
above, all dates are converted to this timezone.  Finally, if it is set to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1899
the string "IGNORE", all timezone information is ignored as the dates are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1900
read in (in this case, the two dates "1/1/96 12:00 GMT" and "1/1/96 12:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1901
EST" would be treated as identical).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1902
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1903
=item Internal
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1904
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1905
When a date is parsed using ParseDate, that date is stored in an internal
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1906
format which is understood by the Date::Manip routines UnixDate and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1907
DateCalc.  Originally, the format used to store the date internally was:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1908
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1909
   YYYYMMDDHH:MN:SS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1910
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1911
It has been suggested that I remove the colons (:) to shorten this to:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1912
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1913
   YYYYMMDDHHMNSS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1914
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1915
The main advantage of this is that some databases are colon delimited which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1916
makes storing a date from Date::Manip tedious.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1917
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1918
In order to maintain backwards compatibility, the Internal variable was
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1919
introduced.  Set it to 0 (to use the old format) or 1 (to use the new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1920
format).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1921
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1922
=item FirstDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1923
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1924
It is sometimes necessary to know what day of week is regarded as first.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1925
By default, this is set to Monday, but many countries and people will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1926
prefer Sunday (and in a few cases, a different day may be desired).  Set
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1927
the FirstDay variable to be the first day of the week (1=Monday, 7=Sunday)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1928
Monday should be chosen to to comply with ISO 8601.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1929
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1930
=item WorkWeekBeg, WorkWeekEnd
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1931
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1932
The first and last days of the work week.  By default, Monday and Friday.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1933
WorkWeekBeg must come before WorkWeekEnd numerically.  The days are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1934
numbered from 1 (Monday) to 7 (Sunday).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1935
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1936
There is no way to handle an odd work week of Thu to Mon for example or 10
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1937
days on, 4 days off.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1938
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1939
=item WorkDay24Hr
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1940
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1941
If this is non-nil, a work day is treated as being 24 hours long.  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1942
WorkDayBeg and WorkDayEnd variables are ignored in this case.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1943
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1944
=item WorkDayBeg, WorkDayEnd
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1945
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1946
The times when the work day starts and ends.  WorkDayBeg must come before
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1947
WorkDayEnd (i.e. there is no way to handle the night shift where the work
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1948
day starts one day and ends another).  Also, the workday MUST be more than
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1949
one hour long (of course, if this isn't the case, let me know... I want a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1950
job there!).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1951
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1952
The time in both can be in any valid time format (including international
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1953
formats), but seconds will be ignored.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1954
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1955
=item TomorrowFirst
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1956
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1957
Periodically, if a day is not a business day, we need to find the nearest
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1958
business day to it.  By default, we'll look to "tomorrow" first, but if this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1959
variable is set to 0, we'll look to "yesterday" first.  This is only used in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1960
the Date_NearestWorkDay and is easily overridden (see documentation for that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1961
function).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1962
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1963
=item DeltaSigns
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1964
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1965
Prior to Date::Manip version 5.07, a negative delta would put negative
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1966
signs in front of every component (i.e. "0:0:-1:-3:0:-4").  By default,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1967
5.07 changes this behavior to print only 1 or two signs in front of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1968
year and day elements (even if these elements might be zero) and the sign
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1969
for year/month and day/hour/minute/second are the same.  Setting this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1970
variable to non-zero forces deltas to be stored with a sign in front of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1971
every element (including elements equal to 0).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1972
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1973
=item Jan1Week1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1974
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1975
ISO 8601 states that the first week of the year is the one which contains
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1976
Jan 4 (i.e. it is the first week in which most of the days in that week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1977
fall in that year).  This means that the first 3 days of the year may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1978
be treated as belonging to the last week of the previous year.  If this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1979
is set to non-nil, the ISO 8601 standard will be ignored and the first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1980
week of the year contains Jan 1.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1981
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1982
=item YYtoYYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1983
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1984
By default, a 2 digit year is treated as falling in the 100 year period of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1985
CURR-89 to CURR+10.  YYtoYYYY may be set to any integer N to force a 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1986
digit year into the period CURR-N to CURR+(99-N).  A value of 0 forces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1987
the year to be the current year or later.  A value of 99 forces the year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1988
to be the current year or earlier.  Since I do no checking on the value of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1989
YYtoYYYY, you can actually have it any positive or negative value to force
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1990
it into any century you want.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1991
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1992
YYtoYYYY can also be set to "C" to force it into the current century, or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1993
to "C##" to force it into a specific century.  So, no (1998), "C" forces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1994
2 digit years to be 1900-1999 and "C18" would force it to be 1800-1899.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1995
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1996
It can also be set to the form "C####" to force it into a specific 100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1997
year period.  C1950 refers to 1950-2049.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1998
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1999
=item UpdateCurrTZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2001
If a script is running over a long period of time, the timezone may change
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2002
during the course of running it (i.e. when daylight savings time starts or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2003
ends).  As a result, parsing dates may start putting them in the wrong time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2004
zone.  Since a lot of overhead can be saved if we don't have to check the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2005
current timezone every time a date is parsed, by default checking is turned
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2006
off.  Setting this to non-nil will force timezone checking to be done every
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2007
time a date is parsed... but this will result in a considerable performance
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2008
penalty.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2009
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2010
A better solution would be to restart the process on the two days per year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2011
where the timezone switch occurs.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2012
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2013
=item IntCharSet
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2014
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2015
If set to 0, use the US character set (7-bit ASCII) to return strings such
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2016
as the month name.  If set to 1, use the appropriate international character
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2017
set.  For example, If you want your French representation of Decemeber to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2018
have the accent over the first "e", you'll want to set this to 1.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2019
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2020
=item ForceDate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2021
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2022
This variable can be set to a date in the format: YYYY-MM-DD-HH:MN:SS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2023
to force the current date to be interpreted as this date.  Since the current
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2024
date is used in parsing, this string will not be parsed and MUST be in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2025
format given above.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2026
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2027
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2028
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2029
=head1 HOLIDAY SECTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2030
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2031
The holiday section of the config file is used to define holidays.  Each
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2032
line is of the form:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2033
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2034
   DATE = HOLIDAY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2035
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2036
HOLIDAY is the name of the holiday (or it can be blank in which case the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2037
day will still be treated as a holiday... for example the day after
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2038
Thanksgiving or Christmas is often a work holiday though neither are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2039
named).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2040
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2041
DATE is a string which can be parsed to give a valid date in any year.  It
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2042
can be of the form
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2043
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2044
   Date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2045
   Date + Delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2046
   Date - Delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2047
   Recur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2048
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2049
A valid holiday section would be:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2050
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2051
   *Holiday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2052
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2053
   1/1                             = New Year's Day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2054
   third Monday in Feb             = Presidents' Day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2055
   fourth Thu in Nov               = Thanksgiving
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2056
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2057
   # The Friday after Thanksgiving is an unnamed holiday most places
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2058
   fourth Thu in Nov + 1 day       =
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2059
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2060
   1*0:0:0:0:0:0*EASTER            = Easter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2061
   1*11:0:11:0:0:0*CWD             = Veteran's Day (observed)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2062
   1*0:0:0:0:0:0*EASTER,PD5        = Good Friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2063
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2064
In a Date + Delta or Date - Delta string, you can use business mode by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2065
including the appropriate string (see documentation on DateCalc) in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2066
Date or Delta.  So (in English), the first workday before Christmas could
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2067
be defined as:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2068
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2069
   12/25 - 1 business day          =
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2070
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2071
The date's may optionally contain the year.  For example, the dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2072
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2073
  1/1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2074
  1/1/1999
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2075
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2076
refers to Jan 1 in any year or in only 1999 respectively.  For dates that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2077
refer to any year, the date must be written such that by simply appending
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2078
the year (separated by spaces) it can be correctly interpreted.  This
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2079
will work for everything except ISO 8601 dates, so ISO 8601 dates may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2080
not be used in this case.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2081
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2082
In cases where you are interested in business type calculations, you'll
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2083
want to define most holidays using recurrences, since they can define
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2084
when a holiday is celebrated in the financial world.  For example,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2085
Christmas chould be defined as:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2086
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2087
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2088
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2089
NOTE: It was pointed out to me that using a similar type recurrence to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2090
define New Years does not work.  The recurrence:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2091
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2092
   1*12:0:31:0:0:0*FW1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2093
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2094
fails (worse, it goes into an infinite loop).  The problem is that each
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2095
holiday definition is applied to a specific year and it expects to find
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2096
the holiday for that year.  When this recurrence is applied to the year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2097
1995, it returns the holiday for 1996 and fails.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2098
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2099
Use the recurrence:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2101
   1*1:0:1:0:0:0*NWD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2102
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2103
instead.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2104
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2105
If you wanted to define both Christmas and Boxing days (Boxing is the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2106
day after Christmas, and is celebrated in some parts of the world), you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2107
could do it in one of the following ways:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2108
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2109
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2110
   1*12:0:25:0:0:0*FW1  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2111
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2112
    1*12:0:24:0:0:0*FW1 = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2113
   01*12:0:24:0:0:0*FW1 = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2114
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2115
   1*12:0:24:0:0:0*FW1   = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2116
   1*12:0:25:0:0:0*FW1,a = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2117
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2118
The following examples will NOT work:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2119
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2120
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2121
   1*12:0:24:0:0:0*FW2  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2122
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2123
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2124
   1*12:0:24:0:0:0*FW1  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2126
The reasoning behind all this is as follows:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2127
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2128
Holidays go into affect the minute they are parsed.  So, in the case of:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2130
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2131
   1*12:0:24:0:0:0*FW2  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2132
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2133
the minute the first line is parsed, Christmas is defined as a holiday.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2134
The second line then steps forward 2 work days (skipping Christmas since
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2135
that's no longer a work day) and define the work day two days after
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2136
Christmas, NOT the day after Christmas.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2137
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2138
An good alternative would appear to be:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2139
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2140
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2141
   1*12:0:24:0:0:0*FW1  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2142
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2143
This unfortunately fails because the recurrences are currently stored in a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2144
hash.  Since these two recurrences are identical, they fail (the first one
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2145
is overwritten by the second and in essense, Christmas is never defined).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2146
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2147
To fix this, make them unique with either a fake flag (which is ignored):
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2149
   1*12:0:24:0:0:0*FW1,a  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2150
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2151
or adding an innocuous 0 somewhere:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2152
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2153
   01*12:0:24:0:0:0*FW1   = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2154
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2155
The other good alternative would be to make two completely different
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2156
recurrences such as:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2157
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2158
   1*12:0:24:0:0:0*FW1  = Christmas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2159
   1*12:0:25:0:0:0*FW1  = Boxing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2160
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2161
At times, you may want to switch back and forth between two holiday files.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2162
This can be done by calling the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2163
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2164
  &Date_Init("EraseHolidays=1","PersonalCnf=FILE1");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2165
  ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2166
  &Date_Init("EraseHolidays=1","PersonalCnf=FILE2");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2167
  ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2168
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2169
=head1 EVENTS SECTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2170
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2171
The Events section of the config file is similar to the Holiday section.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2172
It is used to name certain days or times, but there are a few important
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2173
differences:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2174
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2175
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2176
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2177
=item Events can be assigned to any time and duration
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2178
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2179
All holidays are exactly 1 day long.  They are assigned to a period
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2180
of time from midnight to midnight.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2181
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2182
Events can be based at any time of the day, and may be of any duration.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2183
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2184
=item Events don't affect business mode calculations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2185
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2186
Unlike holidays, events are completely ignored when doing business
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2187
mode calculations.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2188
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2189
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2190
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2191
Whereas holidays were added with business mode math in mind, events
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2192
were added with calendar and scheduling applications in mind.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2193
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2194
Every line in the events section is of the form:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2195
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2196
   EVENT = NAME
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2197
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2198
where NAME is the name of the event, and EVENT defines when it occurs
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2199
and it's duration.  An EVENT can be defined in the following ways:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2201
   Date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2202
   Date*
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2203
   Recur    [NYI]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2204
   Recur*   [NYI]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2205
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2206
   Date  ; Date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2207
   Date  ; Delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2208
   Recur ; Delta   [NYI]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2209
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2210
   Date  ; Delta ; Delta   [NYI]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2211
   Recur ; Delta ; Delta   [NYI]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2212
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2213
Here, Date* refers to a string containing a Date with NO TIME fields
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2214
(Jan 12, 1/1/2000, 2010-01-01) while Date does contain time fields.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2215
Similarily, Recur* stands for a recurrence with the time fields all
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2216
equal to 0) while Recur stands for a recurrence with at least one
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2217
non-zero time field.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2218
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2219
Both Date* and Recur* refer to an event very similar to a holiday which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2220
goes from midnight to midnight.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2221
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2222
Date and Recur refer to events which occur at the time given and with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2223
a duration of 1 hour.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2224
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2225
Events given by "Date ; Date", "Date ; Delta", and "Recur ; Delta"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2226
contain both the starting date and either ending date or duration.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2227
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2228
Events given as three elements "Date ; Delta ; Delta" or "Recur ; Delta ;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2229
Delta" take a date and add both deltas to it to give the starting and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2230
ending time of the event.  The order and sign of the deltas is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2231
unimportant (and both can be the same sign to give a range of times
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2232
which does not contain the base date).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2233
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2234
Items marked with [NYI] are not yet implemented but will be by the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2235
time this is released.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2236
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2237
=head1 BACKWARDS INCOMPATIBILITIES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2238
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2239
For the most part, Date::Manip has remained backward compatible at every
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2240
release.  There have been a few minor incompatibilities introduced at
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2241
various stages.  Major differences are marked with bullets.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2242
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2243
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2244
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2245
=item VERSION 5.41
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2246
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2247
=item Changed path separator for VMS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2248
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2249
Since ":" is used in some VMS paths, it should not have been used as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2250
the path separator.  It has been changed to a newline ("\n") character.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2251
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2252
=item Delta_Format behavior changed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2253
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2254
The entire delta is exact if no month component is present (previously,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2255
no year or month component could be present).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2256
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2257
=item VERSION 5.38
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2258
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2259
=item Removed Date_DaysSince999
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2260
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2261
The Date_DaysSince999 function (deprecated in 5.35) has been removed.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2262
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2263
=item VERSION 5.35
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2264
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2265
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2266
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2267
=item Deprected Date_DaysSince999
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2268
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2269
In fixing support for the years 0000-0999, I rewrote Date_DaysSince999 to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2270
be Date_DaysSince1BC.  The Date_DaysSince999 function will be removed.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2271
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2272
=item * Added PathSep variable
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2273
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2274
In order to better support Win32 platforms, I added the PathSep config
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2275
variable.  This will allow the use of paths such as "c:\date" on Win32
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2276
platforms.  Old config files on Win32 platforms (which were not working
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2277
correctly in many cases) may not work if they contain path information to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2278
the personal config file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2279
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2280
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2281
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2282
=item VERSION 5.34
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2283
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2284
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2285
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2286
=item * All Date::Manip variables are no longer accessible
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2287
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2288
Previously, Date::Manip variables were declared using a full package name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2289
Now, they are declared with the my() function.  This means that internal
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2290
variables are no longer accessible outside of the module.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2291
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2292
=item Week interpretation in business mode deltas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2293
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2294
A business mode delta containing a week value used to be treated as 7 days.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2295
A much more likely interpretation of a week is Monday to Monday, regardless
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2296
of holidays, so this is now the behavior.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2297
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2298
=item %z UnixDate format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2299
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2300
The %z UnixDate format used to return the Timezone abbreviation.  It now
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2301
returns it as a GMT offset (i.e. -0500).  %Z still returns the Timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2302
abbreviation.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2303
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2304
=item Formats "22nd sunday" returns the intuitive value
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2305
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2306
The date "22nd sunday" used to return the Sunday of the 22nd week of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2307
year (which could be the 21st, 22nd, or 23rd Sunday of the year depending
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2308
on how weeks were defined).  Now, it returns the 22nd Sunday of the year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2309
regardless.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2311
=item Separator in DD/YYmmm and mmmDD/YY formats no longer optional
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2312
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2313
Previously, the date "Dec1065" would return Dec 10, 1965.  After adding
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2314
the YYYYmmm and mmmYYYY formats, this was no longer possible.  The separator
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2315
between DD and YY is no longer optional, so
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2316
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2317
   Dec1065     returns December 1, 1065
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2318
   Dec10/65    returns December 10, 1965
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2319
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2320
=item * Date_Cmp added
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2321
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2322
This is not a backwards incompatibility... but is added to help prepare for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2323
a future incompatibility.  In one of the next versions of Date::Manip, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2324
internal format of the date will change to include timezone information.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2325
All date comparisons should be made using Date_Cmp (which currently does
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2326
nothing more than call the perl "cmp" command, but which will important
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2327
when comparing dates that include the timezone).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2328
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2329
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2330
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2331
=item VERSION 5.32
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2332
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2333
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2334
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2335
=item Date_Init arguments
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2336
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2337
The old style Date_Init arguments that were deprecated in version 5.07
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2338
have been removed.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2339
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2340
=item * DateManip.cnf change
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2341
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2342
Changed .DateManip.cnf to Manip.cnf (to get rid of problems on OS's
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2343
that insist on 8.3 filenames) for all non-Unix platforms (Wintel, VMS,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2344
Mac).  For all Unix platforms, it's still .DateManip.cnf .  It will only
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2345
look in the user's home directory on VMS and Unix.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2346
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2347
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2348
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2349
=item VERSION 5.30
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2350
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2351
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2352
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2353
=item * Delta format changed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2354
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2355
A week field has been added to the internal format of the delta.  It now
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2356
reads "Y:M:W:D:H:MN:S" instead of "Y:M:D:H:MN:S".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2357
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2358
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2359
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2360
=item VERSION 5.21
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2361
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2362
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2363
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2364
=item Long running processes may give incorrect timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2365
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2366
A process that runs during a timezone change (Daylight Saving Time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2367
specifically) may report the wrong timezone.  See the UpdateCurrTZ variable
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2368
for more information.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2369
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2370
=item UnixDate "%J", "%W", and "%U" formats fixed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2371
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2372
The %J, %W, and %U will no longer report a week 0 or a week 53 if it should
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2373
really be week 1 of the following year.  They now report the correct week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2374
number according to ISO 8601.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2375
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2376
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2377
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2378
=item VERSION 5.20
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2379
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2380
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2381
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2382
=item * ParseDate formats removed (ISO 8601 compatibility)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2383
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2384
Full support for ISO 8601 formats was added.  As a result, some formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2385
which previously worked may no longer be parsed since they conflict with an
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2386
ISO 8601 format.  These include MM-DD-YY (conflicts with YY-MM-DD) and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2387
YYMMDD (conflicts with YYYYMM).  MM/DD/YY still works, so the first form
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2388
can be kept easily by changing "-" to "/".  YYMMDD can be changed to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2389
YY-MM-DD before being parsed.  Whenever parsing dates using dashes as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2390
separators, they will be treated as ISO 8601 dates.  You can get around
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2391
this by converting all dashes to slashes.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2392
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2393
=item * Week day numbering
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2394
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2395
The day numbering was changed from 0-6 (sun-sat) to 1-7 (mon-sun) to be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2396
ISO 8601 compatible.  Weeks start on Monday (though this can be overridden
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2397
using the FirstDay config variable) and the 1st week of the year contains
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2398
Jan 4 (though it can be forced to contain Jan 1 with the Jan1Week1 config
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2399
variable).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2400
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2401
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2402
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2403
=item VERSION 5.07
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2404
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2405
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2406
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2407
=item UnixDate "%s" format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2408
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2409
Used to return the number of seconds since 1/1/1970 in the current
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2410
timezone.  It now returns the number of seconds since 1/1/1970 GMT.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2411
The "%o" format was added which returns what "%s" previously did.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2412
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2413
=item Internal format of delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2414
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2415
The format for the deltas returned by ParseDateDelta changed.  Previously,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2416
each element of a delta had a sign attached to it (+1:+2:+3:+4:+5:+6).  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2417
new format removes all unnecessary signs by default (+1:2:3:4:5:6).  Also,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2418
because of the way deltas are normalized (see documentation on
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2419
ParseDateDelta), at most two signs are included.  For backwards
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2420
compatibility, the config variable DeltaSigns was added.  If set to 1, all
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2421
deltas include all 6 signs.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2422
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2423
=item Date_Init arguments
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2424
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2425
The format of the Date_Init calling arguments changed.  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2426
old method
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2427
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2428
  &Date_Init($language,$format,$tz,$convtz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2429
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2430
is still supported , but this support will likely disappear in the future.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2431
Use the new calling format instead:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2432
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2433
  &Date_Init("var=val","var=val",...);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2434
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2435
NOTE:  The old format is no longer supported as of version 5.32 .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2436
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2437
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2438
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2439
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2440
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2441
=head1 KNOWN PROBLEMS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2442
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2443
The following are not bugs in Date::Manip, but they may give some people
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2444
problems.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2445
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2446
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2447
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2448
=item Unable to determine TimeZone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2449
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2450
Perhaps the most common problem occurs when you get the error:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2451
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2452
   Error: Date::Manip unable to determine TimeZone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2453
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2454
Date::Manip tries hard to determine the local timezone, but on some
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2455
machines, it cannot do this (especially non-unix systems).  To fix this,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2456
just set the TZ variable, either at the top of the Manip.pm file,, in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2457
DateManip.cnf file, or in a call to Date_Init.  I suggest using the form
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2458
"EST5EDT" so you don't have to change it every 6 months when going to or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2459
from daylight savings time.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2460
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2461
Windows NT does not seem to set the TimeZone by default.  From the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2462
Perl-Win32-Users mailing list:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2463
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2464
   > How do I get the TimeZone on my NT?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2465
   >
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2466
   >      $time_zone = $ENV{'TZ'};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2467
   >
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2468
   You have to set the variable before, WinNT doesn't set it by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2469
   default.  Open the properties of "My Computer" and set a SYSTEM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2470
   variable TZ to your timezone.   Jenda@Krynicky.cz
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2471
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2472
This might help out some NT users.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2473
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2474
A minor (false) assumption that some users might make is that since
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2475
Date::Manip passed all of it's tests at install time, this should not occur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2476
and are surprised when it does.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2477
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2478
Some of the tests are timezone dependent.  Since the tests all include
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2479
input and expected output, I needed to know in advance what timezone they
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2480
would be run in.  So, the tests all explicitly set the timezone using the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2481
TZ configuration variable passed into Date_Init.  Since this overrides any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2482
other method of determining the timezone, Date::Manip uses this and doesn't
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2483
have to look elsewhere for the timezone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2484
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2485
When running outside the tests, Date::Manip has to rely on it's other
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2486
methods for determining the timezone.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2487
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2488
=item Complaining about getpwnam/getpwuid
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2489
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2490
Another problem is when running on Micro$oft OS'es.  I have added many
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2491
tests to catch them, but they still slip through occasionally.  If any ever
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2492
complain about getpwnam/getpwuid, simply add one of the lines:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2493
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2494
  $ENV{OS} = Windows_NT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2495
  $ENV{OS} = Windows_95
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2496
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2497
to your script before
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2498
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2499
  use Date::Manip
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2500
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2501
=item Date::Manip is slow
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2502
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2503
The reasons for this are covered in the SHOULD I USE DATE::MANIP section
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2504
above.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2505
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2506
Some things that will definitely help:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2507
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2508
Version 5.21 does run noticeably faster than earlier versions due to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2509
rethinking some of the initialization, so at the very least, make sure you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2510
are running this version or later.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2511
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2512
ISO-8601 dates are parsed first and fastest.  Use them whenever possible.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2513
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2514
Avoid parsing dates that are referenced against the current time (in 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2515
days, today at noon, etc.).  These take a lot longer to parse.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2516
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2517
   Example:  parsing 1065 dates with version 5.11 took 48.6 seconds, 36.2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2518
   seconds with version 5.21, and parsing 1065 ISO-8601 dates with version
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2519
   5.21 took 29.1 seconds (these were run on a slow, overloaded computer with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2520
   little memory... but the ratios should be reliable on a faster computer).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2521
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2522
Business date calculations are extremely slow.  You should consider
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2523
alternatives if possible (i.e. doing the calculation in exact mode and then
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2524
multiplying by 5/7).  There will be an approximate business mode in one of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2525
the next versions which will be much faster (though less accurate) which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2526
will do something like this.  Whenever possible, use this mode.  And who
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2527
needs a business date more accurate than "6 to 8 weeks" anyway huh :-)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2528
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2529
Never call Date_Init more than once.  Unless you're doing something very
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2530
strange, there should never be a reason to anyway.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2531
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2532
=item Sorting Problems
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2533
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2534
If you use Date::Manip to sort a number of dates, you must call Date_Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2535
either explicitly, or by way of some other Date::Manip routine before it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2536
is used in the sort.  For example, the following code fails:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2537
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2538
   use Date::Manip;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2539
   # &Date_Init;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2540
   sub sortDate {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2541
       my($date1, $date2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2542
       $date1 = &ParseDate($a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2543
       $date2 = &ParseDate($b);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2544
       return (&Date_Cmp($date1,$date2));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2545
   }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2546
   @dates = ("Fri 16 Aug 96",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2547
            "Mon 19 Aug 96",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2548
            "Thu 15 Aug 96");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2549
   @i=sort sortDate @dates;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2550
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2551
but if you uncomment the Date_Init line, it works.  The reason for this is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2552
that the first time you call Date_Init, it initializes a number of items
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2553
used by Date::Manip.  Some of these have to be sorted (regular expressions
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2554
sorted by length to ensure the longest match).  It turns out that perl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2555
has a bug in it which does not allow a sort within a sort.  At some point,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2556
this should be fixed, but for now, the best thing to do is to call Date_Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2557
explicitly.  The bug exists in all versions up to 5.005 (I haven't
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2558
tested 5.6.0 yet).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2559
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2560
NOTE: This is an EXTREMELY inefficient way to sort data.  Instead, you
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2561
should parse the dates with ParseDate, sort them using a normal string
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2562
comparison, and then convert them back to the format desired using
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2563
UnixDate.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2564
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2565
=item RCS Control
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2566
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2567
If you try to put Date::Manip under RCS control, you are going to have
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2568
problems.  Apparently, RCS replaces strings of the form "$Date...$" with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2569
the current date.  This form occurs all over in Date::Manip.  To prevent the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2570
RCS keyword expansion, checkout files using "co -ko".  Since very few people
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2571
will ever have a desire to do this (and I don't use RCS), I have not worried
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2572
about it.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2573
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2574
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2575
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2576
=head1 KNOWN BUGS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2577
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2578
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2579
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2580
=item Daylight Savings Times
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2581
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2582
Date::Manip does not handle daylight savings time, though it does handle
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2583
timezones to a certain extent.  Converting from EST to PST works fine.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2584
Going from EST to PDT is unreliable.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2585
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2586
The following examples are run in the winter of the US East coast (i.e.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2587
in the EST timezone).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2588
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2589
	print UnixDate(ParseDate("6/1/97 noon"),"%u"),"\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2590
        => Sun Jun  1 12:00:00 EST 1997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2591
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2592
June 1 EST does not exist.  June 1st is during EDT.  It should print:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2593
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2594
        => Sun Jun  1 00:00:00 EDT 1997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2595
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2596
Even explicitly adding the timezone doesn't fix things (if anything, it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2597
makes them worse):
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2598
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2599
	print UnixDate(ParseDate("6/1/97 noon EDT"),"%u"),"\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2600
        => Sun Jun  1 11:00:00 EST 1997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2601
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2602
Date::Manip converts everything to the current timezone (EST in this case).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2603
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2604
Related problems occur when trying to do date calculations over a timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2605
change.  These calculations may be off by an hour.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2606
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2607
Also, if you are running a script which uses Date::Manip over a period of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2608
time which starts in one time zone and ends in another (i.e. it switches
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2609
form Daylight Savings Time to Standard Time or vice versa), many things may
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2610
be wrong (especially elapsed time).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2611
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2612
I hope to fix these problems in a future release so that it would convert
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2613
everything to the current zones (EST or EDT).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2614
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2615
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2616
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2617
=head1 BUGS AND QUESTIONS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2618
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2619
If you find a bug in Date::Manip, please send it directly to me (see the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2620
AUTHOR section below) rather than posting it to one of the newsgroups.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2621
Although I try to keep up with the comp.lang.perl.* groups, all too often I
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2622
miss news (flaky news server, articles expiring before I caught them, 1200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2623
articles to wade through and I missed one that I was interested in, etc.).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2624
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2625
When filing a bug report, please include the following information:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2626
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2627
  o  The version of Date::Manip you are using.  You can get this by using
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2628
     the script:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2629
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2630
        use Date::Manip;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2631
        print &DateManipVersion(),"\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2632
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2633
  o  The output from "perl -V"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2634
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2635
If you have a problem using Date::Manip that perhaps isn't a bug (can't
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2636
figure out the syntax, etc.), you're in the right place.  Go right back to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2637
the top of this man page and start reading.  If this still doesn't answer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2638
your question, mail me (again, please mail me rather than post to the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2639
newsgroup).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2640
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2641
=head1 YEAR 2000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2642
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2643
In hindsight, the fact that I've only been asked once (so far) if Date::Manip
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2644
is year 2000 compliant surprises me a bit.  Still, as 2000 approaches and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2645
this buzzword starts flying around more and more frantically, other's might
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2646
follow suit, so this section answers the question.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2647
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2648
Is Date::Manip year 2000 compliant?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2649
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2650
This question is largely meaningless.  Date::Manip is basically just a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2651
parser.  You give it a date and it'll manipulate it.  Date::Manip does
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2652
store the date internally as a 4 digit year, and performs all operations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2653
using this internal representation, so I will state that Date::Manip is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2654
CAPABLE of writing Y2K compliant code.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2656
But Date::Manip is simply a library.  If you use it correctly, your code
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2657
can be Y2K compliant.  If you don't, your code may not be Y2K compliant.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2658
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2659
The bottom line is this:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2660
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2661
  Date::Manip is a library that is capable of being used to write Y2K
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2662
  compliant code.  It may also be used to write non-Y2K compliant code.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2663
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2664
  If your code is NOT Y2K compliant, it is NOT due to any deficiency in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2665
  Date::Manip.  Rather, it is due to poor programming on the part of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2666
  person using Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2667
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2668
For an excellent treatment of the Y2K problem, see the article by Tom
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2669
Christiansen at:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2670
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2671
  http://language.perl.com/news/y2k.html
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2672
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2673
A slightly better question is "Is Perl year 2000 compliant"?  This is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2674
covered in the perl FAQ (section 4) and in the article by Tom Crhistiansen.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2675
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2676
The best question is "For what dates is Date::Manip useful?"  It definitely
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2677
can't handle BC dates, or dates past Dec 31, 9999.  So Date::Manip works
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2678
during the years 1000 to 9999.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2679
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2680
In practical terms however, Date::Manip deals with the Gregorian calendar,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2681
and is therefore useful in the period that that calendar has been, or will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2682
be, in effect.  The Gregorian calendar was first adopted by the Catholic
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2683
church in 1582, but some countries were still using the Julian calendar as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2684
late as the early part of the 20th century.  Also, at some point (probably
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2685
no earlier than the year 3000 and possibly much later), the Gregorian
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2686
system is going to have to be modified slightly since the current system of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2687
leap years is off by a few seconds a year.  So...  in practical terms,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2688
Date::Manip is _probably_ useful from 1900 to 3000.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2689
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2690
One other note is that Date::Manip will NOT handle 3 digit years.  So, if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2691
you store the year as an offset from 1900 (which is 2 digits now, but will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2692
become 3 digits in 2000), these will NOT be parsable by Date::Manip.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2693
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2694
=head1 VERSION NUMBERS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2695
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2696
A note about version numbers.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2697
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2698
Prior to version 5.00, Date::Manip was distributed as a perl4 library.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2699
There were no numbering conventions in place, so I used a simple
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2700
MAJOR.MINOR numbering scheme.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2701
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2702
With version 5.00, I switched to a perl5 module and at that time switched
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2703
to the perl5 numbering convention of a major version followed by a 2 digit
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2704
minor version.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2705
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2706
As of 5.41/5.42, all versions released to CPAN will be even numbered.  Odd
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2707
numbered will be development versions available from my web site.  For
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2708
example, after 5.40 was released, I started making changes, and called
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2709
the development version 5.41.  When released to CPAN, it was called 5.42.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2710
I may add a third digit to development versions (i.e. 5.41.9) to keep
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2711
track of important changes in the development version.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2712
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2713
=head1 ACKNOWLEDGMENTS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2714
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2715
There are many people who have contributed to Date::Manip over the years
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2716
that I'd like to thank.  The most important contributions have come in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2717
form of suggestions and bug reports by users.  I have tried to include the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2718
name of every person who first suggested each improvement or first reported
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2719
each bug.  These are included in the HISTORY file in the Date::Manip
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2720
distribution in the order the changes are made.  The list is simply too
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2721
long to appear here, but I appreciate their help.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2722
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2723
A number of people have made suggestions or reported bugs which are not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2724
mentioned in the HISTORY file.  These include suggestions which have not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2725
been implemented and people who have made a suggestion or bug report which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2726
has already been suggested/reported by someone else.  For those who's
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2727
suggestions have not yet been implemented, they will be added to the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2728
HISTORY file when (if) their suggestions are implemented.  For everyone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2729
else, thank you too.  I'd much rather have a suggestion made twice than not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2730
at all.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2731
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2732
Thanks to Alan Cezar and Greg Schiedler for paying me to implement the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2733
Events_List routine.  They gave me the idea, and were then willing to pay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2734
me for my time to get it implemented quickly.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2735
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2736
I'd also like a couple of authors.  Date::Manip has recently been getting
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2737
some really good press in a couple of books.  Since no one's paying me to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2738
write Date::Manip, seeing my module get a good review in a book written by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2739
someone else really makes my day.  My thanks to Nate Padwardhan and Clay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2740
Irving (Programming with Perl Modules -- part of the O'Reilly Perl Resource
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2741
Kit); and Tom Christiansen and Nathan Torkington (The Perl Cookbook).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2742
Also, thanks to any other authors who've written about Date::Manip who's
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2743
books I haven't seen.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2744
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2745
=head1 AUTHOR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2746
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2747
Sullivan Beck (sbeck@cpan.org)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2748
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2749
You can always get the newest beta version of Date::Manip (which may fix
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2750
problems in the current CPAN version... and may add others) from my home
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2751
page:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2752
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2753
http://www.cise.ufl.edu/~sbeck/
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2754
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2755
=cut