NAME
WARC::Date - datestamp objects for WARC library
SYNOPSIS
use WARC::Date;
$datestamp = WARC::Date->now(); # construct from current time
$datestamp = WARC::Date->from_epoch(time); # likewise
# construct from string
$datestamp = parse WARC::Date ($text); # full-featured
$datestamp = WARC::Date->from_text($string); # standard format only
$time = $datestamp->as_epoch; # as seconds since epoch
$text = $datestamp->as_string; # as "YYYY-MM-DDThh:mm:ssZ"
DESCRIPTION
WARC::Date
objects encapsulate the details of the required format for timestamps in WARC headers.
Methods
- $datestamp = WARC::Date->now
-
Construct a
WARC::Date
object representing the current time. - $datestamp = WARC::Date->from_epoch( $timestamp )
-
Construct a
WARC::Date
object representing the time indicated by an epoch timestamp. - $datestamp = WARC::Date->from_text( $string )
-
Construct a
WARC::Date
object representing the time indicated by a string in the same format returned by theas_string
method. - $datestamp = parse WARC::Date ($text)
-
Construct a
WARC::Date
object from a textual representation. If HTTP::Date is installed, accepts any input acceptable toHTTP::Date::str2time
. Otherwise, this method is equivalent to thefrom_text
method. - $datestamp->as_string
-
Return a string in the format specified by [W3C-NOTE-datetime] restricted to 14 digits and UTC time zone, which is "YYYY-MM-DDThh:mm:ssZ".
CAVEATS
WARC::Date
objects use epoch time internally and are therefore limited by the range of Perl's integers.
AUTHOR
Jacob Bachmeyer, <jcb@cpan.org>
SEE ALSO
[W3C-NOTE-datetime] "Date and Time Formats" http://www.w3.org/TR/NOTE-datetime.
COPYRIGHT AND LICENSE
Copyright (C) 2019 by Jacob Bachmeyer
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.