Date::TimeOfDay - Represent time of day (hh:mm:ss)
version 0.005
use Date::TimeOfDay; my $tod = Date::TimeOfDay->new( hour=>23, minute=>59, second=>59, # nanosecond => 999_999_999, # optional );
EARLY RELEASE, API MIGHT CHANGE WITHOUT NOTICE.
This is a simple module to represent time of day. Interface is modelled after DateTime. Internal representation is currently float (number of seconds from midnight 00:00:00). Currently does not handle leap second nor time zone.
TODO:
* set * strftime * add DateTime + TimeOfDay * add TimeOfDay + TimeOfDay * convert to duration * convert to another time zone
Example:
my $tod = Date::TimeOfDay->from_hms(hms => "23:59:59"); say $tod; # => "23:59:59"
my $tod = Date::TimeOfDay->from_float(float => 86399); say $tod; # => "23:59:59"
Usage:
$tod->hms([ $sep ])
Default separator is ":".
Is also invoked via overload of q("").
$tod->compare($tod2); # -1 if $tod is less than $tod2, 0 if equal, 1 if greater than
DateTime
perlancar <perlancar@cpan.org>
This software is copyright (c) 2018 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Date::TimeOfDay, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::TimeOfDay
CPAN shell
perl -MCPAN -e shell install Date::TimeOfDay
For more information on module installation, please visit the detailed CPAN module installation guide.