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
$datestamp = WARC::Date->from_string($string);# construct from string
$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.
These objects have overloaded string and number conversions. As a string, a WARC::Date
object produces the [W3C-NOTE-datetime] format, while conversion to a number yields an epoch timestamp.
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_string( $string )
-
Construct a
WARC::Date
object representing the time indicated by a string in the same format returned by theas_string
method. - $datestamp->as_epoch
-
Return the represented time as an epoch timestamp.
- $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
Conversion to epoch time is limited by the range of Time::Local
.
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.