The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Date::TimeOfDay - Represent time of day (hh:mm:ss)

VERSION

This document describes version 0.006 of Date::TimeOfDay (from Perl distribution Date-TimeOfDay), released on 2022-09-22.

SYNOPSIS

 use Date::TimeOfDay;

 my $tod = Date::TimeOfDay->new(
     hour=>23, minute=>59, second=>59,
     # nanosecond => 999_999_999, # optional
 );

DESCRIPTION

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

METHODS

new

from_hms

Example:

 my $tod = Date::TimeOfDay->from_hms(hms => "23:59:59");
 say $tod; # => "23:59:59"

from_float

Example:

 my $tod = Date::TimeOfDay->from_float(float => 86399);
 say $tod; # => "23:59:59"

now_local

hires_now_local

now_utc

hires_now_utc

hour

minute

second

nanosecond

float

hms

Usage:

 $tod->hms([ $sep ])

Default separator is ":".

(TODO) set

(TODO) strftime

stringify

Is also invoked via overload of q("").

compare

Example:

 $tod->compare($tod2); # -1 if $tod is less than $tod2, 0 if equal, 1 if greater than

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Date-TimeOfDay.

SOURCE

Source repository is at https://github.com/perlancar/perl-Date-TimeOfDay.

SEE ALSO

DateTime

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022, 2018 by perlancar <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.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Date-TimeOfDay

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.