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

is_epoch - Guess if the given string could be an epoch time.

NAME

is_epoch - guess if the given number is an epoch

SYNOPSIS

is_epoch [OPTIONS] number [number ...]

EXAMPLES

Default is year 0001 to 9999, which is probably too much output. To get less, change the min and max values:

    $ is_epoch 1234567890 --min 2007 --max 2017
    2016-12-22T00:22:36Z    (1234567890, decimal, dos)
    2009-02-13T23:31:30Z    (1234567890, decimal, unix)
    2007-03-16T23:31:30Z    (1234567890, decimal, google_calendar)

You can also ask for JSON output instead.

    $ is_epoch 1234567890 --min 2007 --max 2017 --output=as_json
    {"1234567890":{"decimal":{"dos":"2016-12-22T00:22:36Z","unix":"2009-02-13T23:31:30Z","google_calendar":"2007-03-16T23:31:30Z"}}}

To make it more readable, just pipe it json_xs or jq whatever your favorite JSON prettifier is.

    $ is_epoch 1234567890 --min 2007 --max 2017 --output=as_json | json_xs
    {
       "1234567890" : {
          "decimal" : {
             "unix" : "2009-02-13T23:31:30Z",
             "dos" : "2016-12-22T00:22:36Z",
             "google_calendar" : "2007-03-16T23:31:30Z"
          }
       }
    }

Most things are looking for a decimal or hexadecimal string, but you can also put a whole UUID in and it will grab the parts that make the date-time.

    $ is_epoch 33c41a44-6cea-11e7-907b-a6006ad3dba0
    2017-07-20T01:24:40.472634Z    (33c41a44-6cea-11e7-907b-a6006ad3dba0, uuid_v1, uuid_v1)

OPTIONS

--debug

Prints extra messages.

--help

Prints a brief help message and exits.

--man

Prints the manual page and exits.

--max_date=STRING

Maximum date to print out. Default is 9999-12-31T23:59:59Z. It's just a string compare, so you can include as little or as much of an ISO-8601 date as you want (e.g., --max_date=2017).

--min_date=STRING

Minimum date to print out. Default is 0001-01-01T00:00:00Z. It's just a string compare, so you can include as little or as much of an ISO-8601 date as you want (e.g., --min_date=2017).

--output=STRING

Output format (as_string or as_json). Default as_string.

--verbose

Prints results in more detail.

DESCRIPTION

is_epoch will guess if any of the conversions from Time::Moment::Epoch gives a reasonable date for the given numbers.

VERSION

version 1.003003

AUTHOR

Tim Heaney <heaney@cpan.org>

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.