Net::API::REST::DateTime - HTTP DateTime Manipulation and Formatting
use Net::API::REST::DateTime; my $d = Net::API::REST::DateTime->new( debug => 3 ); my $dt = DateTime->now; $dt->set_formatter( $d ); print( "$dt\n" ); ## will produce Sun, 15 Dec 2019 15:32:12 GMT my( @parts ) = $d->parse_date( $date_string ); my $datetime_object = $d->str2datetime( $date_string ); $datetime_object->set_formatter( $d ); my $timestamp_in_seconds = $d->str2time( $date_string ); my $datetime_object = $d->time2datetime( $timestamp_in_seconds ); my $datetime_string = $d->time2str( $timestamp_in_seconds );
v0.1
This module contains methods to create and manipulate datetime representation from and to DateTime object or unix timestamps.
DateTime
When using it as a formatter to a DateTime object, this will make sure it is properly formatted for its use in http headers and cookies.
This initiates the package and take the following parameters:
Optional. If set with a positive integer, this will activate verbose debugging message
Provided a DateTime object, this returns a http compliant string representation, such as:
Sun, 15 Dec 2019 15:32:12 GMT
that can be used in http headers and cookies' expires property as per rfc6265.
Given a datetime string, this returns, in list context, a list of day, month, year, hour, minute, second and time zone or an iso 8601 datetime string in scalar context.
This is used by the method str2datetime
Given a string that looks like a date, this will parse it and return a DateTime object.
Given a string that looks like a date, this returns its representation as a unix timestamp in second since epoch.
In the background, it calls str2datetime for parsing.
Given a unix timestamp in seconds since epoch, this returns a DateTime object.
Given a unix timestamp in seconds since epoch, this returns a string representation of the timestamp suitable for http headers and cookies. The format is like Sat, 14 Dec 2019 22:12:30 GMT
Sat, 14 Dec 2019 22:12:30 GMT
Jacques Deguest <jack@deguest.jp>
CPAN ID: jdeguest
https://git.deguest.jp/jack/Net-API-REST
Copyright (c) 2018-2019 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
To install Net::API::REST, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::API::REST
CPAN shell
perl -MCPAN -e shell install Net::API::REST
For more information on module installation, please visit the detailed CPAN module installation guide.