NAME
Time::Keeper::Time - a time of day, on no date
VERSION
Version 0.11
SYNOPSIS
use Time::Keeper;
my $tm = Time::Keeper::Time->new(hour => 9, minute => 5);
my $tm = Time::Keeper::Time->parse('09:05:07.25');
my $tm = Time::Keeper::Time->now(zone => 'Europe/London');
my $tm = $t->to_time;
$tm->plus(hours => 1); # 10:05:07.250
Time::Keeper::Time->new(hour => 23, minute => 30)->plus(hours => 1); # 00:30:00
$tm->round(to => 'minute', increment => 15);
$tm->format('h:mm a'); # 9:05 AM
$date->at($tm, zone => 'Europe/London'); # a Time::Keeper value
"$tm"; # 09:05:07.250
DESCRIPTION
A time of day with no date and no zone: an alarm, an opening hour, a schedule. It is not a Time::Keeper value: it has no year, no day of the week and no zone, a pattern letter that needs one is an error, and it compares only with another time of day. Arithmetic wraps at midnight, as Temporal's PlainTime does: 23:30 plus an hour is 00:30. There is no second 60: a leap second is an instant on one day, and "to_time" in Time::Keeper during one gives the last nanosecond before it.
CONSTRUCTORS
new
Time::Keeper::Time->new(hour => 9, minute => 5, second => 7, nanosecond => 250_000_000);
Time::Keeper::Time->new(hour => 9, locale => 'fr');
Each part defaults to 0; second is 0 to 59.
now
Time::Keeper::Time->now; # the UTC time of day
Time::Keeper::Time->now(zone => 'Asia/Tokyo');
The time of day now in the zone, from the clock "TESTING" in Time::Keeper describes.
parse
strptime
parse_cldr
Time::Keeper::Time->parse('09:05:07.25'); # also T09:05, 0905, 09.5
Time::Keeper::Time->strptime('9:05 PM', '%I:%M %p');
Time::Keeper::Time->parse_cldr('09 h 05', "HH 'h' mm", locale => 'fr');
parse reads ISO 8601's time forms, extended and basic, with or without a leading T, with a fraction on the last part given; a Z, an offset, a zone or 24:00 is an error. Under a pattern, a date the pattern reads is dropped. Each takes locale.
try_new
try_parse
try_strptime
try_parse_cldr
As the method without try_, but undef where it would die, with $@ left as it was.
ACCESSORS
hour
minute
second
nanosecond
millisecond
microsecond
hour_12
am_pm
locale
As "ACCESSORS" in Time::Keeper.
NEW VALUES FROM OLD
with
$tm->with(minute => 0, second => 0);
in_locale
The same time of day in another locale.
ARITHMETIC
plus
minus
$tm->plus(hours => 1);
$tm->plus(minutes => 90, seconds => 5);
$tm->minus($duration);
$tm->minus($other); # a signed duration, never wrapped
Hours, minutes, seconds and smaller, by name or as a Time::Keeper::Duration, wrapping at midnight either way. Days and months are an error: a time of day has no calendar. minus with another time gives the duration from it to this one, negative when it is earlier. + and - do the same.
truncate
round
end_of
$tm->truncate(to => 'hour');
$tm->round(to => 'minute', increment => 15, mode => 'floor');
To an hour, minute, second, millisecond, microsecond or nanosecond, as "truncate" in Time::Keeper and "round" in Time::Keeper; a round past 23:59:59 wraps to 00:00:00.
COMPARING AND PRINTING
compare
As "compare" in Time::Keeper::Date, between times of day only.
iso8601
TO_JSON
hms
time
$tm->iso8601; # 09:05:07.250: 3, 6 or 9 digits, or none
$tm->iso8601(precision => 0); # 09:05:07
$tm->hms; $tm->hms('.'); $tm->time;
"$tm" and "TO_JSON" are "iso8601". "hms" and "time" never write the fraction.
FORMATTING
strftime
format
format_time
format_skeleton
$tm->format('h:mm a');
$tm->strftime('%I:%M %p');
$tm->format_time('short'); # 9:05 AM
$tm->format_skeleton('Hms');
A letter that needs a date, a day of the week or a zone is an error naming it; so format_time('full') and 'long' are, since the locale's full and long time formats name the zone.
SERIALISATION
STORABLE_freeze
STORABLE_thaw
FREEZE
THAW
As Time::Keeper::Date's.
SEE ALSO
Time::Keeper, Time::Keeper::Date.
AUTHOR
LNATION, <email at lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)