The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Time::Moment::Epoch

DESCRIPTION

Convert various epoch times to and from datetimes using Time::Moment.

SYNOPSIS

        use Time::Moment::Epoch;

        say Time::Moment::Epoch::unix(1234567890);
                        # 2009-02-13T23:31:30Z
        say Time::Moment::Epoch::to_unix('2009-02-13T23:31:30Z');
                        # 1234567890

        say Time::Moment::Epoch::chrome(12879041490654321);
                        # 2009-02-13T23:31:30.654321Z
        say Time::Moment::Epoch::to_chrome('2009-02-13T23:31:30.654321Z');
                        # 12879041490654321

CONVERSIONS

The following functions convert an epoch of the specified type to a Time::Moment object.

They each have a corresponding to_$type function which accepts a datetime string (in any format accepted by the from_string method of Time::Moment) and returns the corresponding epoch.

apfs

APFS time is the number of nanoseconds since the Unix epoch. Cf., APFS filesystem format (https://blog.cugu.eu/post/apfs/).

chrome

Chrome time is the number of microseconds since 1601-01-01.

cocoa

Cocoa time is the number of seconds since 2001-01-01.

google_calendar

Google Calendar time is 32-day months from the day before the Unix epoch.

icq

ICQ time is the number of days (with an allowed fractional part) since 1899-12-30.

java

Java time is the number of milliseconds since the Unix epoch.

mozilla

Mozilla time is the number of microseconds since the Unix epoch.

ole

OLE time is the number of days since 1899-12-30, packed as a double-precision float in native format.

symbian

Symbian time is the number of microseconds since the year 0.

unix

Unix time is the number of seconds since 1970-01-01.

uuid_v1

UUID version 1 time (RFC 4122) is the number of hectonanoseconds (100 ns) since 1582-10-15.

windows_date

Windows date time (e.g., .NET) is the number of hectonanoseconds (100 ns) since 0001-01-01.

windows_file

Windows file time (e.g., NTFS) is the number of hectonanoseconds (100 ns) since 1601-01-01.

SEE ALSO

Time::Moment