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 - Convert various epoch times to Time::Moment times.

NAME

Time::Moment::Epoch

DESCRIPTION

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

SYNOPSIS

use Time::Moment::Epoch qw(:all);

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

say chrome(12879041490654321);                  # 2009-02-13T23:31:30.654321Z
say 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.

dos

DOS time stores dates since 1980-01-01 in bitfields.

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.

windows_system

Windows system time is a sixteen byte representation of Windows file time. It's in eight sixteen-bit segments...sort of like a ctime.

year 1601..30827 month 1..12 (January..December) day_of_week 0..6 (Sunday..Saturday) day 1..31 hour 0..23 minute 0..59 second 0..59 milliseconds 0..999

Note that Time::Moment day_of_week is one-based and starts on Monday (so Sunday is 7 instead of 0).

SEE ALSO

Time::Moment

VERSION

version 1.004001

AUTHOR

Tim Heaney <heaney@cpan.org>

CONTRIBUTORS

  • Alexandr Ciornii <alexchorny@gmail.com>

  • Mary Ehlers <regina.verb.ae@gmail.com>

  • Tim Heaney <oylenshpeegul@proton.me>

  • iopuckoi <iopuckoi@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Tim Heaney.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.