NAME Time::Moment - Represents a date and time of day combined with a time zone offset from UTC SYNOPSIS $tm = Time::Moment->now; $tm = Time::Moment->from_epoch($seconds [, $microsecond [, $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] $epoch = $tm->epoch; $offset = $tm->offset; # [-1080, 1080] $tm2 = $tm1->with_offset($offset); $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 combined with a time zone offset from UTC in the ISO 8601 calendar with microsecond resolution. 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($epoch); $tm = Time::Moment->from_epoch($epoch, $microsecond); $tm = Time::Moment->from_epoch($epoch, $microsecond, $offset); 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 component of the time of day may have a decimal fraction. All ISO 8601 date and time of day representations are supported in both basic and extended format. The constructor raises an exception if the given string cannot be parsed. 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, 999999]. 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 result is at the same instant. 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 object in one of the following ISO 8601 formats: YYYY-MM-DDThh:mmZ YYYY-MM-DDThh:mm±hh YYYY-MM-DDThh:mm±hh:mm YYYY-MM-DDThh:mm:ss.fffZ YYYY-MM-DDThh:mm:ss.fff±hh YYYY-MM-DDThh:mm:ss.fff±hh:mm YYYY-MM-DDThh:mm:ss.ffffffZ YYYY-MM-DDThh:mm:ss.ffffff±hh YYYY-MM-DDThh:mm:ss.ffffff±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 XXX %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 (microsecond) as a decimal number [000000, 999999]. %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 XXX %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. ISO 8601 calendar week number. %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 ISO 8601 calendar date in extended format. Equivalent to %F. %X Replaced by ISO 8601 local time of day in extended format. 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, $nano) = $tm->utc_rd_values; 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, $nano) = $tm->local_rd_values; 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.