Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / HTTP::Date.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "HTTP::Date 3"
132 .TH HTTP::Date 3 "2009-10-03" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 HTTP::Date \- date conversion routines
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \& use HTTP::Date;
139 .Ve
140 .PP
141 .Vb 2
142 \& $string = time2str($time);    # Format as GMT ASCII time
143 \& $time = str2time($string);    # convert ASCII date to machine time
144 .Ve
145 .SH "DESCRIPTION"
146 .IX Header "DESCRIPTION"
147 This module provides functions that deal the date formats used by the
148 \&\s-1HTTP\s0 protocol (and then some more).  Only the first two functions,
149 \&\fItime2str()\fR and \fIstr2time()\fR, are exported by default.
150 .IP "time2str( [$time] )" 4
151 .IX Item "time2str( [$time] )"
152 The \fItime2str()\fR function converts a machine time (seconds since epoch)
153 to a string.  If the function is called without an argument or with an
154 undefined argument, it will use the current time.
155 .Sp
156 The string returned is in the format preferred for the \s-1HTTP\s0 protocol.
157 This is a fixed length subset of the format defined by \s-1RFC\s0 1123,
158 represented in Universal Time (\s-1GMT\s0).  An example of a time stamp
159 in this format is:
160 .Sp
161 .Vb 1
162 \&   Sun, 06 Nov 1994 08:49:37 GMT
163 .Ve
164 .ie n .IP "str2time( $str\fR [, \f(CW$zone] )" 4
165 .el .IP "str2time( \f(CW$str\fR [, \f(CW$zone\fR] )" 4
166 .IX Item "str2time( $str [, $zone] )"
167 The \fIstr2time()\fR function converts a string to machine time.  It returns
168 \&\f(CW\*(C`undef\*(C'\fR if the format of \f(CW$str\fR is unrecognized, otherwise whatever the
169 \&\f(CW\*(C`Time::Local\*(C'\fR functions can make out of the parsed time.  Dates
170 before the system's epoch may not work on all operating systems.  The
171 time formats recognized are the same as for \fIparse_date()\fR.
172 .Sp
173 The function also takes an optional second argument that specifies the
174 default time zone to use when converting the date.  This parameter is
175 ignored if the zone is found in the date string itself.  If this
176 parameter is missing, and the date string format does not contain any
177 zone specification, then the local time zone is assumed.
178 .Sp
179 If the zone is not "\f(CW\*(C`GMT\*(C'\fR\*(L" or numerical (like \*(R"\f(CW\*(C`\-0800\*(C'\fR\*(L" or
180 \&\*(R"\f(CW+0100\fR"), then the \f(CW\*(C`Time::Zone\*(C'\fR module must be installed in order
181 to get the date recognized.
182 .ie n .IP "parse_date( $str )" 4
183 .el .IP "parse_date( \f(CW$str\fR )" 4
184 .IX Item "parse_date( $str )"
185 This function will try to parse a date string, and then return it as a
186 list of numerical values followed by a (possible undefined) time zone
187 specifier; ($year, \f(CW$month\fR, \f(CW$day\fR, \f(CW$hour\fR, \f(CW$min\fR, \f(CW$sec\fR, \f(CW$tz\fR).  The \f(CW$year\fR
188 returned will \fBnot\fR have the number 1900 subtracted from it and the
189 \&\f(CW$month\fR numbers start with 1.
190 .Sp
191 In scalar context the numbers are interpolated in a string of the
192 \&\*(L"\s-1YYYY\-MM\-DD\s0 hh:mm:ss \s-1TZ\s0\*(R"\-format and returned.
193 .Sp
194 If the date is unrecognized, then the empty list is returned.
195 .Sp
196 The function is able to parse the following formats:
197 .Sp
198 .Vb 5
199 \& "Wed, 09 Feb 1994 22:23:32 GMT"       \-\- HTTP format
200 \& "Thu Feb  3 17:03:55 GMT 1994"        \-\- ctime(3) format
201 \& "Thu Feb  3 00:00:00 1994",           \-\- ANSI C asctime() format
202 \& "Tuesday, 08\-Feb\-94 14:15:29 GMT"     \-\- old rfc850 HTTP format
203 \& "Tuesday, 08\-Feb\-1994 14:15:29 GMT"   \-\- broken rfc850 HTTP format
204 .Ve
205 .Sp
206 .Vb 4
207 \& "03/Feb/1994:17:03:55 \-0700"   \-\- common logfile format
208 \& "09 Feb 1994 22:23:32 GMT"     \-\- HTTP format (no weekday)
209 \& "08\-Feb\-94 14:15:29 GMT"       \-\- rfc850 format (no weekday)
210 \& "08\-Feb\-1994 14:15:29 GMT"     \-\- broken rfc850 format (no weekday)
211 .Ve
212 .Sp
213 .Vb 6
214 \& "1994\-02\-03 14:15:29 \-0100"    \-\- ISO 8601 format
215 \& "1994\-02\-03 14:15:29"          \-\- zone is optional
216 \& "1994\-02\-03"                   \-\- only date
217 \& "1994\-02\-03T14:15:29"          \-\- Use T as separator
218 \& "19940203T141529Z"             \-\- ISO 8601 compact format
219 \& "19940203"                     \-\- only date
220 .Ve
221 .Sp
222 .Vb 4
223 \& "08\-Feb\-94"         \-\- old rfc850 HTTP format    (no weekday, no time)
224 \& "08\-Feb\-1994"       \-\- broken rfc850 HTTP format (no weekday, no time)
225 \& "09 Feb 1994"       \-\- proposed new HTTP format  (no weekday, no time)
226 \& "03/Feb/1994"       \-\- common logfile format     (no time, no offset)
227 .Ve
228 .Sp
229 .Vb 2
230 \& "Feb  3  1994"      \-\- Unix 'ls \-l' format
231 \& "Feb  3 17:03"      \-\- Unix 'ls \-l' format
232 .Ve
233 .Sp
234 .Vb 1
235 \& "11\-15\-96  03:52PM" \-\- Windows 'dir' format
236 .Ve
237 .Sp
238 The parser ignores leading and trailing whitespace.  It also allow the
239 seconds to be missing and the month to be numerical in most formats.
240 .Sp
241 If the year is missing, then we assume that the date is the first
242 matching date \fIbefore\fR current month.  If the year is given with only
243 2 digits, then \fIparse_date()\fR will select the century that makes the
244 year closest to the current date.
245 .IP "time2iso( [$time] )" 4
246 .IX Item "time2iso( [$time] )"
247 Same as \fItime2str()\fR, but returns a \*(L"\s-1YYYY\-MM\-DD\s0 hh:mm:ss\*(R"\-formatted
248 string representing time in the local time zone.
249 .IP "time2isoz( [$time] )" 4
250 .IX Item "time2isoz( [$time] )"
251 Same as \fItime2str()\fR, but returns a \*(L"\s-1YYYY\-MM\-DD\s0 hh:mm:ssZ\*(R"\-formatted
252 string representing Universal Time.
253 .SH "SEE ALSO"
254 .IX Header "SEE ALSO"
255 \&\*(L"time\*(R" in perlfunc, Time::Zone
256 .SH "COPYRIGHT"
257 .IX Header "COPYRIGHT"
258 Copyright 1995\-1999, Gisle Aas
259 .PP
260 This library is free software; you can redistribute it and/or
261 modify it under the same terms as Perl itself.