1Time::ParseDate(3)    User Contributed Perl Documentation   Time::ParseDate(3)
2
3
4

NAME

6       Time::ParseDate -- date parsing both relative and absolute
7

SYNOPSIS

9               use Time::ParseDate;
10               $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", NO_RELATIVE => 1)
11               $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", %options)
12

OPTIONS

14       Date parsing can also use options.  The options are as follows:
15
16               FUZZY   -> it's okay not to parse the entire date string
17               NOW     -> the "current" time for relative times (defaults to time())
18               ZONE    -> local timezone (defaults to $ENV{TZ})
19               WHOLE   -> the whole input string must be parsed
20               GMT     -> input time is assumed to be GMT, not localtime
21               UK      -> prefer UK style dates (dd/mm over mm/dd)
22               DATE_REQUIRED -> do not default the date
23               TIME_REQUIRED -> do not default the time
24               NO_RELATIVE -> input time is not relative to NOW
25               TIMEFIRST -> try parsing time before date [not default]
26               PREFER_PAST -> when year or day of week is ambigueous, assume past
27               PREFER_FUTURE -> when year or day of week is ambigueous, assume future
28               SUBSECOND -> parse fraction seconds
29               VALIDATE -> only accept normal values for HHMMSS, YYMMDD.  Otherwise
30                       days like -1 might give the last day of the previous month.
31

DATE FORMATS RECOGNIZED

33       Absolute date formats
34
35               Dow, dd Mon yy
36               Dow, dd Mon yyyy
37               Dow, dd Mon
38               dd Mon yy
39               dd Mon yyyy
40               Month day{st,nd,rd,th}, year
41               Month day{st,nd,rd,th}
42               Mon dd yyyy
43               yyyy/mm/dd
44               yyyy/mm
45               mm/dd/yy
46               mm/dd/yyyy
47               mm/yy
48               yy/mm      (only if year > 12, or > 31 if UK)
49               yy/mm/dd   (only if year > 12 and day < 32, or year > 31 if UK)
50               dd/mm/yy   (only if UK, or an invalid mm/dd/yy or yy/mm/dd)
51               dd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy)
52               dd/mm      (only if UK, or an invalid mm/dd)
53
54       Relative date formats:
55
56               count "days"
57               count "weeks"
58               count "months"
59               count "years"
60               Dow "after next"
61               Dow                     (requires PREFER_PAST or PREFER_FUTURE)
62               "next" Dow
63               "tomorrow"
64               "today"
65               "yesterday"
66               "last" dow
67               "last week"
68               "now"
69               "now" "+" count units
70               "now" "-" count units
71               "+" count units
72               "-" count units
73               count units "ago"
74
75       Absolute time formats:
76
77               hh:mm:ss[.ddd]
78               hh:mm
79               hh:mm[AP]M
80               hh[AP]M
81               hhmmss[[AP]M]
82               "noon"
83               "midnight"
84
85       Relative time formats:
86
87               count "minutes"
88               count "seconds"
89               count "hours"
90               "+" count units
91               "+" count
92               "-" count units
93               "-" count
94               count units "ago"
95
96       Timezone formats:
97
98               [+-]dddd
99               GMT[+-]d+
100               [+-]dddd (TZN)
101               TZN
102
103       Special formats:
104
105               [ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd]
106               yy/mm/dd.hh:mm
107

DESCRIPTION

109       This module recognizes the above date/time formats.   Usually a date
110       and a time are specified.  There are numerous options for controlling
111       what is recognized and what is not.
112
113       The return code is always the time in seconds since January 1st, 1970
114       or undef if it was unable to parse the time.
115
116       If a timezone is specified it must be after the time.  Year specifica‐
117       tions can be tacked onto the end of absolute times.
118
119       If "parsedate()" is called from array context, then it will return two
120       elements.  On sucessful parses, it will return the seconds and what
121       remains of its input string.  On unsucessful parses, it will return
122       "undef" and an error string.
123

EXAMPLES

125               $seconds = parsedate("Mon Jan  2 04:24:27 1995");
126               $seconds = parsedate("Tue Apr 4 00:22:12 PDT 1995");
127               $seconds = parsedate("04.04.95 00:22", ZONE => PDT);
128               $seconds = parsedate("Jan 1 1999 11:23:34.578", SUBSECOND => 1);
129               $seconds = parsedate("122212 950404", ZONE => PDT, TIMEFIRST => 1);
130               $seconds = parsedate("+3 secs", NOW => 796978800);
131               $seconds = parsedate("2 months", NOW => 796720932);
132               $seconds = parsedate("last Tuesday");
133
134               ($seconds, $remaining) = parsedate("today is the day");
135               ($seconds, $error) = parsedate("today is", WHOLE=>1);
136

AUTHOR

138       David Muir Sharnoff <muir@idiom.com>.
139

LICENSE

141       Copyright (C) 1996-1999 David Muir Sharnoff.  License hereby granted
142       for anyone to use, modify or redistribute this module at their own
143       risk.  Please feed useful changes back to muir@idiom.com.
144
145
146
147perl v5.8.8                       2003-11-25                Time::ParseDate(3)
Impressum