NAME Time::Moment - Represents a date and time of day with an offset from UTC SYNOPSIS $tm = Time::Moment->now; $tm = Time::Moment->from_epoch($seconds [, $nanosecond [, $offset ]]); $tm = Time::Moment->from_object($object); $tm = Time::Moment->from_string($string); $year = $tm->year; # [1, 9999] $quarter = $tm->quarter; # [1, 4] $month = $tm->month; # [1, 12] $week = $tm->week; # [1, 53] $day = $tm->day_of_year; # [1, 366] $day = $tm->day_of_quarter; # [1, 92] $day = $tm->day_of_month; # [1, 31] $day = $tm->day_of_week; # [1=Monday, 7=Sunday] $hour = $tm->hour; # [0, 23] $minute = $tm->minute; # [0, 59] $second = $tm->second; # [0, 59] $millisecond = $tm->millisecond; # [0, 999] $microsecond = $tm->microsecond; # [0, 999_999] $nanosecond = $tm->nanosecond; # [0, 999_999_999] $epoch = $tm->epoch; $offset = $tm->offset; # [-1080, 1080] $tm2 = $tm1->with_offset($offset); $tm2 = $tm1->with_nanosecond($nanosecond); $boolean = $tm1->is_before($tm2); $boolean = $tm1->is_after($tm2); $boolean = $tm1->is_equal($tm2); $integer = $tm1->compare($tm2); $string = $tm->to_string; $string = $tm->strftime($format); @values = $tm->utc_rd_values; $seconds = $tm->utc_rd_as_seconds; @values = $tm->local_rd_values; $seconds = $tm->local_rd_as_seconds; $boolean = $tm1 == $tm2; $boolean = $tm1 != $tm2; $boolean = $tm1 < $tm2; $boolean = $tm1 > $tm2; $boolean = $tm1 <= $tm2; $boolean = $tm1 >= $tm2; $string = "$tm"; # YYYY-MM-DDThh:mm:ss.ffffff±hh:mm DESCRIPTION Represents a date and time of day with an offset from UTC in the ISO 8601 calendar system. IMPORTANT: This is an early preview release available for testing and feedback. The API is still subject to change. METHODS now $tm = Time::Moment->now; Constructs an instance of "Time::Moment" that is set to the current date and time from the system clock in the system time-zone, with the offset set to the local time's offset from UTC. from_epoch $tm = Time::Moment->from_epoch($seconds); $tm = Time::Moment->from_epoch($seconds, $nanosecond); $tm = Time::Moment->from_epoch($seconds, $nanosecond, $offset); Constructs an instance of "Time::Moment" from the given *seconds* from the epoch of 1970-01-01T00:00:00Z. The optional parameter *nanosecond* specifies the nano of second [0, 999_999_999]. The optional parameter *offset* specifies the offset from UTC in minutes [-1080, 1080]. from_object $tm = Time::Moment->from_object($object); from_string $tm = Time::Moment->from_string($string); Constructs an instance of "Time::Moment" from the given *string*. The string must consist of a complete representation of a date and time of day followed by a zone designator. The second part of the time of day may have a decimal fraction. The following are examples of complete representations of date and time of day representations: Basic format: Example: YYYYMMDDThhmmssZ 20121224T121530Z YYYYMMDDThhmmss±hhmm 20121224T121530+0100 YYYYMMDDThhmmss±hh 20121224T121530+01 Extended format: Example: YYYY-MM-DDThh:mm:ssZ 2012-12-24T12:15:30Z YYYY-MM-DDThh:mm:ss±hh:mm 2012-12-24T12:15:30+01:00 YYYY-MM-DDThh:mm:ss±hh 2012-12-24T12:15:30+01 Where complete representations using calendar dates are shown, ordinal dates or week dates may be substituted. year $year = $tm->year; Returns the year [1, 9999]. quarter $quarter = $tm->quarter; Returns the quarter of the year [1, 4]. month $month = $tm->month; Returns the month of the year [1, 12]. week $week = $tm->week; Returns the week of the year [1, 53]. day_of_year $day = $tm->day_of_year; Returns the day of the year [1, 366]. day_of_quarter $day = $tm->day_of_quarter; Returns the day of the quarter [1, 92]. day_of_month $day = $tm->day_of_month; Returns the day of the month [1, 31]. day_of_week $day = $tm->day_of_week; Returns the day of the week [1=Monday, 7=Sunday]. hour $hour = $tm->hour; Returns the hour of day [0, 23]. minute $minute = $tm->minute; Returns the minute of hour [0, 59]. second $second = $tm->second; Returns the second of minute [0, 59]. millisecond $millisecond = $tm->millisecond; Returns the milli of second [0, 999]. microsecond $microsecond = $tm->microsecond; Returns the micro of second [0, 999_999]. nanosecond $nanosecond = $tm->nanosecond; Returns the nano of second [0, 999_999_999]. epoch $epoch = $tm->epoch; Returns the number of seconds from the epoch of 1970-01-01T00:00:00Z. offset $offset = $tm->offset; Returns the offset from UTC in minutes [-1080, 1080]. with_offset $tm2 = $tm1->with_offset($offset); Returns a copy of this time with the given *offset* altered. The resulting time is at the same instant. with_nanosecond $tm2 = $tm1->with_nanosecond($nanosecond); Returns a copy of this time with the given *nanosecond* altered. is_before $boolean = $tm->is_before($other); Returns a boolean indicating whether or not the instant of this time is before the other time. is_after $boolean = $tm->is_after($other); Returns a boolean indicating whether or not the instant of this time is after the other time. is_equal $boolean = $tm->is_equal($other); Returns a boolean indicating whether or not the instant of this time is equal the other time. compare $integer = $tm->compare($other); Returns an integer indicating whether the instant of this time is before, after or equal another time. Returns a value less than zero if this time is before the other; zero if this date is equal the other time; a value greater than zero if this time is after the other time. to_string $string = $tm->to_string; Returns a string representation of the instance in one of the following formats: YYYY-MM-DDThh:mm YYYY-MM-DDThh:mm:ss YYYY-MM-DDThh:mm:ss.fff YYYY-MM-DDThh:mm:ss.ffffff YYYY-MM-DDThh:mm:ss.fffffffff Followed by a zone designator in one of the following formats: Z ±hh ±hh:mm The shortest representation will be used where the omitted parts are implied to be zero. strftime $string = $tm->strftime($format); Formats time according to the conversion specifications in the given format string. The format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters are copied directly into the resulting string. A conversion specification consists of a percent sign "%" and one other character. The following conversion specifications are supported: %a Replaced by the C locale's abbreviated day of the week name. Example: Mon, Tue, ..., Sun. %A Replaced by the C locale's full day of the week name. Example: Monday, Tuesday, ..., Sunday. %b Replaced by the C locale's abbreviated month name. Example: Jan, Feb, ..., Dec. %B Replaced by the C locale's full month name. Example: January, February, ..., December. %c Replaced by the C locale's date and time representation. Equivalent to "%a %b %e %H:%M:%S %Y". %C Replaced by the year divided by 100 and truncated to an integer, as a decimal number [00, 99]. %d Replaced by the day of the month as a decimal number [01, 31]. %D Equivalent to "%m/%d/%y". %e Replaced by the day of the month as a decimal number [1, 31]; a single digit is preceded by a space. %f Replaced by the fractional second including preceding decimal point or by an empty string if no fractional second exists. .fff (millisecond) .ffffff (microsecond) .fffffffff (nanosecond) The shortest representation is used. *Please note that this this conversion specification is an extension to the "IEEE Std 1003.1, 2013 Edition" *. %F Equivalent to "%Y-%m-%d". %g Replaced by the last 2 digits of the year of the week as a decimal number [00, 99]. %h Equivalent to %b. %H Replaced by the hour (24-hour clock) as a decimal number [00, 23]. %I Replaced by the hour (12-hour clock) as a decimal number [01, 12]. %j Replaced by the day of the year as a decimal number [001, 366]. %m Replaced by the month of the year as a decimal number [01, 12]. %M Replaced by the minute as a decimal number [00, 59]. %n Replaced by a character. %N Replaced by the fractional second as a decimal number. This conversion specification permits use of a optional width flag where the default width of 0 will use the shortest representation. Example: %N or %0N is replaced by one of the following (shortest representation): fff (millisecond) ffffff (microsecond) fffffffff (nanosecond) %N4 is replaced by exactly four fractional digits, zero padded or truncated if needed. ffff *Please note that this this conversion specification is an extension to the "IEEE Std 1003.1, 2013 Edition" *. %p Replaced by the C locale's meridian notation. Example: AM, PM. %r Replaced by the C locale's time in a.m. and p.m. notation. Equivalent to "%I:%M:%S %p". %R Replaced by the time in 24-hour notation. Equivalent to "%H:%M". %s Replaced by the number of seconds from the epoch of 1970-01-01T00:00:00Z. %S Replaced by the second as a decimal number [00, 60]. %t Replaced by a character. %T Replaced by the time of day. Equivalent to "%H:%M:%S". %u Replaced by the day of the week as a decimal number [1, 7], with 1 representing Monday. %U Replaced by the week number of the year as a decimal number [00, 53]. The first Sunday of January is the first day of week 1; days in the new year before this are in week 0. %V Replaced by the week number of the year (Monday as the first day of the week) as a decimal number [01, 53]. If the week containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. Both January 4th and the first Thursday of January are always in week 1. %W Replaced by the week number of the year as a decimal number [00, 53]. The first Monday of January is the first day of week 1; days in the new year before this are in week 0. %x Replaced by the C locale's date representation. Equivalent to "%D". %X Replaced by the C locale's time representation. Equivalent to "%T". %y Replaced by the last two digits of the year as a decimal number [00, 99]. %Y Replaced by the year as a decimal number [0001, 9999]. %z Replaced by the offset from UTC in the ISO 8601 basic format (±hhmm). %Z Replaced by the offset from UTC in the ISO 8601 extended format or with UTC designator (±hh:mm or Z). "%%" Replaced by %. utc_rd_values ($rd, $sod, $nanosecond) = $tm->utc_rd_values; Returns a list of three elements: $rd The number of days from the Rata Die epoch of 0001-01-01. $sod The second of the day [0, 86_399]. $nanosecond The nano of the second [0, 999_999_999]. utc_rd_as_seconds $seconds = $tm->utc_rd_as_seconds; Returns the number of seconds from the Rata Die epoch of 0001-01-01T00:00:00Z. local_rd_values ($rd, $sod, $nanosecond) = $tm->local_rd_values; Returns a list of three elements: $rd The number of days from the Rata Die epoch of 0001-01-01. $sod The second of the day [0, 86_399]. $nanosecond The nano of the second [0, 999_999_999]. local_rd_as_seconds $seconds = $tm->local_rd_as_seconds; Returns the number of seconds from the Rata Die epoch of 0001-01-01T00:00:00. DIAGNOSTICS (F) Usage: %s Method called with wrong number of arguments. SEE ALSO SUPPORT Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. SOURCE CODE This is open source software. The code repository is available for public review and contribution under the terms of the license. git clone https://github.com/chansen/p5-time-moment AUTHOR Christian Hansen "chansen@cpan.org" COPYRIGHT Copyright 2013 by Christian Hansen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.