packaged::Timestamp;useutf8;usestrict;useTime::Local;=pod=head1 NAMEd::Timestamp - AnomieBOT timestamp handling decorator=head1 SYNOPSIS use AnomieBOT::API; $api = new AnomieBOT::API('conf.ini', 1); $api->decorators(qw/d::Timestamp/);=head1 DESCRIPTIONC<d::Timestamp> contains timestamp-related utility functions for use by anAnomieBOT task. When "d::Timestamp" is used as a decorator on the API object,the following methods are available.=head1 METHODS PROVIDED=over=item $api->ISO2timestamp( $ts )Convert an ISO-format timestamp into a standard epoch value.=item $api->timestamp2ISO( $ts )Convert an epoch value to an ISO-format timestamp.=cutsubISO2timestamp{my$api=shift;my$t=shift;returnundefunlessdefined($t);returntimegm($6,$5,$4,$3,$2-1,$1-1900)if$t=~/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/;returnundef;}subtimestamp2ISO{my$api=shift;my@t=gmtime(shift);returnundefunless@t;returnsprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0]);}1;=pod=back=head1COPYRIGHTCopyright2008–2013AnomieThislibraryisfreesoftware;youcanredistributeitand/ormodifyitunderthesametermsasPerlitself.