WARC::Date - datestamp objects for WARC library
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"
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.
- $datestamp = WARC::Date->now
WARC::Dateobject representing the current time.
- $datestamp = WARC::Date->from_epoch( $timestamp )
WARC::Dateobject representing the time indicated by an epoch timestamp.
- $datestamp = WARC::Date->from_string( $string )
WARC::Dateobject representing the time indicated by a string in the same format returned by the
Return the represented time as an epoch timestamp.
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".
Conversion to epoch time is limited by the range of
Jacob Bachmeyer, <email@example.com>
[W3C-NOTE-datetime] "Date and Time Formats" http://www.w3.org/TR/NOTE-datetime.
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.