Debian Codegraph @

README

raw
1 NAME
2 Time::ParseDate -- date parsing both relative and absolute
3
4 SYNOPSIS
5 use Time::ParseDate;
6 $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", NO_RELATIVE => 1)
7 $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", %options)
8
9 OPTIONS
10 Date parsing can also use options. The options are as follows:
11
12 FUZZY -> it's okay not to parse the entire date string
13 NOW -> the "current" time for relative times (defaults to time())
14 ZONE -> local timezone (defaults to $ENV{TZ})
15 WHOLE -> the whole input string must be parsed
16 GMT -> input time is assumed to be GMT, not localtime
17 UK -> prefer UK style dates (dd/mm over mm/dd)
18 DATE_REQUIRED -> do not default the date
19 TIME_REQUIRED -> do not default the time
20 NO_RELATIVE -> input time is not relative to NOW
21 TIMEFIRST -> try parsing time before date [not default]
22 PREFER_PAST -> when year or day of week is ambiguous, assume past
23 PREFER_FUTURE -> when year or day of week is ambiguous, assume future
24 SUBSECOND -> parse fraction seconds
25 VALIDATE -> only accept normal values for HHMMSS, YYMMDD. Otherwise
26 days like -1 might give the last day of the previous month.
27
28 DATE FORMATS RECOGNIZED
29 Absolute date formats
30 Dow, dd Mon yy
31 Dow, dd Mon yyyy
32 Dow, dd Mon
33 dd Mon yy
34 dd Mon yyyy
35 Month day{st,nd,rd,th}, year
36 Month day{st,nd,rd,th}
37 Mon dd yyyy
38 yyyy/mm/dd
39 yyyy-mm-dd (usually the best date specification syntax)
40 yyyy/mm
41 mm/dd/yy
42 mm/dd/yyyy
43 mm/yy
44 yy/mm (only if year > 12, or > 31 if UK)
45 yy/mm/dd (only if year > 12 and day < 32, or year > 31 if UK)
46 dd/mm/yy (only if UK, or an invalid mm/dd/yy or yy/mm/dd)
47 dd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy)
48 dd/mm (only if UK, or an invalid mm/dd)
49
50 Relative date formats:
51 count "days"
52 count "weeks"
53 count "months"
54 count "years"
55 Dow "after next"
56 Dow "before last"
57 Dow (requires PREFER_PAST or PREFER_FUTURE)
58 "next" Dow
59 "tomorrow"
60 "today"
61 "yesterday"
62 "last" dow
63 "last week"
64 "now"
65 "now" "+" count units
66 "now" "-" count units
67 "+" count units
68 "-" count units
69 count units "ago"
70
71 Absolute time formats:
72 hh:mm:ss[.ddd]
73 hh:mm
74 hh:mm[AP]M
75 hh[AP]M
76 hhmmss[[AP]M]
77 "noon"
78 "midnight"
79
80 Relative time formats:
81 count "minutes" (count can be franctional "1.5" or "1 1/2")
82 count "seconds"
83 count "hours"
84 "+" count units
85 "+" count
86 "-" count units
87 "-" count
88 count units "ago"
89
90 Timezone formats:
91 [+-]dddd
92 GMT[+-]d+
93 [+-]dddd (TZN)
94 TZN
95
96 Special formats:
97 [ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd]
98 yy/mm/dd.hh:mm
99
100 DESCRIPTION
101 This module recognizes the above date/time formats. Usually a date and a
102 time are specified. There are numerous options for controlling what is
103 recognized and what is not.
104
105 The return code is always the time in seconds since January 1st, 1970 or
106 undef if it was unable to parse the time.
107
108 If a timezone is specified it must be after the time. Year
109 specifications can be tacked onto the end of absolute times.
110
111 If "parsedate()" is called from array context, then it will return two
112 elements. On successful parses, it will return the seconds and what
113 remains of its input string. On unsuccessful parses, it will return
114 "undef" and an error string.
115
116 EXAMPLES
117 $seconds = parsedate("Mon Jan 2 04:24:27 1995");
118 $seconds = parsedate("Tue Apr 4 00:22:12 PDT 1995");
119 $seconds = parsedate("04.04.95 00:22", ZONE => PDT);
120 $seconds = parsedate("Jan 1 1999 11:23:34.578", SUBSECOND => 1);
121 $seconds = parsedate("122212 950404", ZONE => PDT, TIMEFIRST => 1);
122 $seconds = parsedate("+3 secs", NOW => 796978800);
123 $seconds = parsedate("2 months", NOW => 796720932);
124 $seconds = parsedate("last Tuesday");
125 $seconds = parsedate("Sunday before last");
126
127 ($seconds, $remaining) = parsedate("today is the day");
128 ($seconds, $error) = parsedate("today is", WHOLE=>1);
129
130 AUTHOR
131 Best Practical Solutions, LLC <[email protected]>
132
133 ORIGINAL AUTHOR
134 David Muir Sharnoff
135
136 BUGS
137 All bugs should be reported via email to
138
139 L<[email protected]|mailto:[email protected]>
140
141 or via the web at
142
143 L<rt.cpan.org|http://rt.cpan.org/Public/Dist/Display.html?Name=Time-ParseDate>.
144
145 LICENSE AND COPYRIGHT
146 Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google,
147 Inc. Copyright (C) 2026 Best Practical Solutions, LLC.
148
149 This library is free software; you can redistribute it and/or modify it
150 under the same terms as Perl itself.
151