File: README

package info (click to toggle)
datemanip 5.33-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 480 kB
  • ctags: 87
  • sloc: perl: 6,461; makefile: 40; sh: 3
file content (244 lines) | stat: -rw-r--r-- 10,019 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
Copyright (c) 1995-1998 Sullivan Beck. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

For information on installing Date::Manip, see the INSTALL file included in
the distribution.

Please send questions or bug reports to me rather than posting them to
a newsgroup since I may miss them there, BUT read the next paragraph
before you automatically start firing off email to me!

If you have questions about Date::Manip, refer to the Date::Manip man page
included as pod documentation in the Manip.pm file.  Don't know what I'm
talking about?  Read the perlpod man page.  Alternately, an online version
of the Date::Manip man page is included in my home page given below.
PLEASE read the man page thoroughly before posting any questions about
Date::Manip to a newsgroup or emailing me.  If you've done this, I'll be
glad to answer any questions not covered in the man page.


** IMPORTANT NOTE (5.30) **
The internal format of a delta has changed (a week field has been added).
I realize that this is going to cause some problems, but I am adding two
other types of data (granularity and recurrence) to Date::Manip.  Both
will resemble a delta, and both will have week fields, and I wanted all three
to be as similar as possible.  You should use Delta_Format to extract
information from a delta from now on rather than doing it manually.  This is
especially important since the format for a delta will be changed again in one
of the next versions from Y:M:W:D:H:MN:S to Y:M:W:D:H:MN:S*FLAGS.

I also plan on changing the internal format for a date to include
the timezone ( YYYYMMDDHH:MN:SS+HHMN ).  Using UnixDate to extract information
from a date is recommended.


Notes for version 5.33:
  A bug fix to fix a fairly bad bug in 5.32.  I broke parsing of "1 month ago".
    This corrects that.  A side affect of this fix is that many "deltas" may
    be parsed as dates.  I.e. &ParseDate("1 hour 20 minutes ago") is equivalent
    to &DateCalc("now","1 hour 20 minutes ago").  Only text deltas can be used
    in this way (i.e. &ParseDate("-0:0:0:0:1:20:0") will not work).
  Added Spanish support.

Notes for version 5.32:
  Mainly a bug fix release.
  Added Polish and Dutch support.
  *** Changed .DateManip.cnf to Manip.cnf (to get rid of problems on OS's
     that insist on 8.3 filenames) for all non-Unix platforms (Wintel, VMS,
     Mac).  For all Unix platforms, it's still .DateManip.cnf .  It will only
     look in the user's home directory on VMS and Unix.
  Added "in N days" and "N days ago" parse formats.
  Added "N days/weeks/months later" parse formats (both dates and deltas).
  Allow timezones in the formats "STD-#DST-#" and "+HHMM (NAME)".
  Added several timezones.
  Added "A.M." parsing (not just "AM").

Backwards incompatibilities:

  Version 5.32
    Old style Date_Init arguments no longer supported.
    *** .DateManip.cnf changed to Manip.cnf on all non-Unix platforms.

  Version 5.30
    The internal format of a delta has changed.  This will cause some people
       problems.  Use the routine Delta_Format to extract information from
       a delta.

  ############################################################################
  If you would like to stay informed about future versions of this module,
  and especially if you are interested in beta testing future versions,
  please let me know by email at:
    sbeck@cise.ufl.edu

  The newest version (which should be considered a beta version) is available
  through my home page:
    http://www.cise.ufl.edu/~sbeck/
  Feel free to try it out.

  The current (non-beta) version of this module is available from you nearest
  CPAN site and is NOT available from my home page.  I will announce new
  (non-beta) releases in comp.lang.perl.misc and comp.lang.perl.announce.
  ############################################################################


This is a set of routines designed to make any common date/time
manipulation easy to do.  Operations such as comparing two times,
calculating a time a given amount of time from another, or parsing
international times are all easily done.  From the very beginning, the main
focus of Date::Manip has been to be able to do ANY desired date/time
operation easily, not necessarily quickly.  There are other modules that
can do a small subset of the operations available in Date::Manip much
quicker than those presented here, so if speed is a primary issue, you
should look elsewhere.  Check out the CPAN listing of Time and Date
modules.  But for sheer flexibility, I believe that Date::Manip is your
best bet.

Date::Manip deals with time as it is presented the Gregorian calendar (the
one currently in use).  The Julian calendar defined leap years as every 4th
year.  The Gregorian calendar improved this by making every 100th year NOT
a leap year, unless it was also the 400th year.  The Gregorian calendar has
been extrapolated back to the year 1000 AD and forward to the year 9999 AD.
Note that in historical context, the Julian calendar was in use until 1582
when the Gregorian calendar was adopted by the Catholic church.  Protestant
countries did not accept it until later; Germany and Netherlands in 1698,
British Empire in 1752, Russia in 1918.  Note that the Gregorian calendar
is itself imperfect.  Each year is on average 26 seconds too long, which
means that every 3,323 years, a day should be removed from the calendar.
No attempt is made to correct for that.

Date::Manip is therefore not equipped to truly deal with historical dates,
but should be able to perform (virtually) any operation dealing with a
modern time and date.

Date::Manip has (or will have) functionality to work with several fundamental
types of data.

DATE

Although the word date is used extensively here, it is actually somewhat
misleading.  Date::Manip works with the full date AND time (year, month,
day, hour, minute, second).  It doesn't work with fractional seconds.
Timezones are also supported.

NOTE:  Much better support for timezones (including Daylight Savings Time)
is planned for the future.

DELTA

This refers to a duration or elapsed time.  One thing to note is that, as
used in this module, a delta refers only to the amount of time elapsed.  It
includes no information about a starting or ending time.

RECURRENCE

A recurrence is simply a notation for defining when a recurring event
occurs.  For example, if an event occurs every other Friday or every
4 hours, this can be defined as a recurrence.  With a recurrence and a
starting and ending date, you can get a list of dates in that period when
a recurring event occurs.

GRAIN

The granularity of a time basically refers to how accurate you wish to
treat a date.  For example, if you want to compare two dates to see if
they are identical at a granularity of days, then they only have to occur
on the same day.  At a granularity of an hour, they have to occur within
an hour of each other, etc.

NOTE:  Support for this will be added soon.

Among other things, Date::Manip allow you to:

1.  Enter a date and be able to choose any format conveniant

2.  Compare two dates, entered in widely different formats to determine
    which is earlier

3.  Extract any information you want from ANY date using a format string
    similar to the Unix date command

4.  Determine the amount of time between two dates

5.  Add a time offset to a date to get a second date (i.e. determine the
    date 132 days ago or 2 years and 3 months after Jan 2, 1992)

6.  Work with dates with dates using international formats (foreign month
    names, 12/10/95 referring to October rather than December, etc.).

7.  To find a list of dates where a recurring event happens.

Each of these tasks is trivial (one or two lines at most) with this package.

EXAMPLES:

1.  Parsing a date from any conveniant format

  $date=&ParseDate("today");
  $date=&ParseDate("1st thursday in June 1992");
  $date=&ParseDate("05/10/93");
  $date=&ParseDate("12:30 Dec 12th 1880");
  $date=&ParseDate("8:00pm december tenth");
  if (! $date) {
    # Error in the date
  }

2.  Compare two dates

  $date1=&ParseDate($string1);
  $date2=&ParseDate($string2);
  if ($date1 lt $date2) {
    # date1 is earlier
  } else {
    # date2 is earlier (or the two dates are identical)
  }

3.  Extract information from a date.

  print &UnixDate("today","The time is now %T on %b %e, %Y.");
  =>  "The time is now 13:24:08 on Feb  3, 1996."

4.  The amount of time between two dates.

  $date1=&ParseDate($string1);
  $date2=&ParseDate($string2);
  $delta=&DateCalc($date1,$date2,\$err);
  => 0:0:DD:HH:MM:SS   the days, hours, minutes, and seconds between the two
  $delta=&DateCalc($date1,$date2,\$err,1);
  => YY:MM:DD:HH:MM:SS  the years, months, etc. between the two

  Read the documentation in the man page for an explanation of the difference.

5.  To determine a date a given offset from another.

  $date=&DateCalc("today","+ 3hours 12minutes 6 seconds",\$err);
  $date=&DateCalc("12 hours ago","12:30 6Jan90",\$err);

  It even works with business days:

  $date=&DateCalc("today","+ 3 business days",\$err);

6.  To work with dates in another language.

  &Date_Init("Language=French","DateFormat=non-US");
  $date=&ParseDate("1er decembre 1990");

7.  To find a list of dates where a recurring event happens.

  # To find the 2nd tuesday of every month
  @date=&ParseRecur("0:1*2:2:0:0:0",$base,$start,$stop);

NOTE: Some date forms do not work as well in languages other than English,
but this is not because DateManip is incapable of doing so (almost nothing
in this module is language dependent).  It is simply that I do not have the
correct translation available for some words.  If there is a date form that
works in English but does not work in a language you need, let me know and
if you can provide me the translation, I will fix DateManip.

For documentation on all of the date manipulation routines, read the
man page.

AUTHOR

Sullivan Beck (sbeck@cise.ufl.edu)