163 lines
4.3 KiB
HTML
163 lines
4.3 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Date::Parse</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Date::Parse</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Date::Parse - Parse date strings into time values
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Date::Parse;
|
|
|
|
$time = str2time($date);
|
|
|
|
($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date);
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
<TT>"Date::Parse"</TT> provides two routines for parsing date strings into time values.
|
|
<DL COMPACT>
|
|
<DT id="1">str2time(<FONT SIZE="-1">DATE</FONT> [, <FONT SIZE="-1">ZONE</FONT>])<DD>
|
|
|
|
|
|
<TT>"str2time"</TT> parses <TT>"DATE"</TT> and returns a unix time value, or undef upon failure.
|
|
<TT>"ZONE"</TT>, if given, specifies the timezone to assume when parsing if the
|
|
date string does not specify a timezone.
|
|
<DT id="2">strptime(<FONT SIZE="-1">DATE</FONT> [, <FONT SIZE="-1">ZONE</FONT>])<DD>
|
|
|
|
|
|
<TT>"strptime"</TT> takes the same arguments as str2time but returns an array of
|
|
values <TT>"($ss,$mm,$hh,$day,$month,$year,$zone,$century)"</TT>. Elements are only
|
|
defined if they could be extracted from the date string. The <TT>$zone</TT> element
|
|
is the timezone offset in seconds from <FONT SIZE="-1">GMT.</FONT> An empty array is returned upon
|
|
failure.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>MULTI-LANGUAGE SUPPORT</H2>
|
|
|
|
|
|
|
|
Date::Parse is capable of parsing dates in several languages, these include
|
|
English, French, German and Italian.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$lang = Date::Language->new('German');
|
|
$lang->str2time("25 Jun 1996 21:09:55 +0100");
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>EXAMPLE DATES</H2>
|
|
|
|
|
|
|
|
Below is a sample list of dates that are known to be parsable with Date::Parse
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
1995:01:24T09:08:17.1823213 ISO-8601
|
|
1995-01-24T09:08:17.1823213
|
|
Wed, 16 Jun 94 07:29:35 CST Comma and day name are optional
|
|
Thu, 13 Oct 94 10:13:13 -0700
|
|
Wed, 9 Nov 1994 09:50:32 -0500 (EST) Text in ()'s will be ignored.
|
|
21 dec 17:05 Will be parsed in the current time zone
|
|
21-dec 17:05
|
|
21/dec 17:05
|
|
21/dec/93 17:05
|
|
1999 10:02:18 "GMT"
|
|
16 Nov 94 22:28:20 PST
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>LIMITATION</H2>
|
|
|
|
|
|
|
|
Date::Parse uses Time::Local internally, so is limited to only parsing dates
|
|
which result in valid values for Time::Local::timelocal. This generally means dates
|
|
between 1901-12-17 00:00:00 <FONT SIZE="-1">GMT</FONT> and 2038-01-16 23:59:59 <FONT SIZE="-1">GMT</FONT>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
|
|
|
|
When both the month and the date are specified in the date as numbers
|
|
they are always parsed assuming that the month number comes before the
|
|
date. This is the usual format used in American dates.
|
|
<P>
|
|
|
|
The reason why it is like this and not dynamic is that it must be
|
|
deterministic. Several people have suggested using the current locale,
|
|
but this will not work as the date being parsed may not be in the format
|
|
of the current locale.
|
|
<P>
|
|
|
|
My plans to address this, which will be in a future release, is to allow
|
|
the programmer to state what order they want these values parsed in.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Graham Barr <<A HREF="mailto:gbarr@pobox.com">gbarr@pobox.com</A>>
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (c) 1995-2009 Graham Barr. This program is free
|
|
software; you can redistribute it and/or modify it under the same terms
|
|
as Perl itself.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="6"><A HREF="#lbAE">MULTI-LANGUAGE SUPPORT</A><DD>
|
|
<DT id="7"><A HREF="#lbAF">EXAMPLE DATES</A><DD>
|
|
<DT id="8"><A HREF="#lbAG">LIMITATION</A><DD>
|
|
<DT id="9"><A HREF="#lbAH">BUGS</A><DD>
|
|
<DT id="10"><A HREF="#lbAI">AUTHOR</A><DD>
|
|
<DT id="11"><A HREF="#lbAJ">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:38 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|