/date.pl

Perl timezone converter script

Primary LanguagePerl

date.pl - Perl timezone converter script

Convert NZ-time strings to UK-time and vice-versa.

SYNOPSIS

date.pl [Options]

Options:
    --local_tz=  Optional local timezone. Defaults to Pacific/Auckland.
    --remote_tz= Optional remote timezone. Defaults to Europe/London.
    --help       Show this text.

Examples:

    # Show current time locally, remotely, and in UTC.
    $ date.pl
    Pacific/Auckland: Thu 2015-09-24T21:47:50 NZST
    Europe/London: Thu 2015-09-24T10:47:50 BST
                UTC: Thu 2015-09-24T09:47:50 UTC

    # Use non-default local and remote timezones.
    $ date.pl --local_tz Australia/Melbourne --remote_tz America/New_York
    Australia/Melbourne: Sun 2018-07-01T16:22:19 AEST
       America/New_York: Sun 2018-07-01T02:22:19 EDT
                    UTC: Sun 2018-07-01T06:22:19 UTC

    # Parse common date formats
    $ date.pl Tue Feb 03 07:00 NZDT 2015
    $ date.pl 3rd March 2015 at 7AM
    $ date.pl 2015-02-03 07:00:00
    Pacific/Auckland: Tue 2015-02-03T07:00:00 NZDT
    Europe/London: Mon 2015-02-02T18:00:00 GMT
                UTC: Mon 2015-02-02T18:00:00 UTC

    # Parse a unix epoch timestamp.
    $ date.pl 1427318966
    Pacific/Auckland: Thu 2015-03-26T10:29:26 NZDT
    Europe/London: Wed 2015-03-25T21:29:26 GMT
                UTC: Wed 2015-03-25T21:29:26 UTC

    # Parse simple N $units ago
    $ date.pl 7 hours ago
    Pacific/Auckland: Sat 2017-05-06T02:23:46 NZST
    Europe/London: Fri 2017-05-05T15:23:46 BST
                UTC: Fri 2017-05-05T14:23:46 UTC

INSTALLATION

Simply copy the date.pl script to a directory in your $PATH.

DEPENDENCIES

This module requires these other modules and libraries:

LICENCE

Copyright 2017 Dave Webb

date.pl is free software. You can do anything you like with it.

CHANGES

  • 2017-05-06 - VERSION 1.00

    Add the day name to the prints.

    Abstract out the format, and loop for the prints.

    Always output UTC.

  • 2015-09-24 - VERSION 0.94

    Local and remote timezones are now constants().

    run() now defaults input date string to local now.

    run() now aligns printout of the dates, plus prints UTC as well if the remote time is different.

  • 2015-03-26 - VERSION 0.93

    Removed old attempt at extra timezone parsing. It didn't work well.

    Added support for "N (minutes|hours|days) ago".

    Converted functions to methods, so they can access the object's particular local and remote timezones.

  • 2015-03-26 - VERSION 0.92

    Convert to modulino in prep for testing.

  • 2015-03-26 - VERSION 0.91

    Handle dates of the form "26 March 2015 at 06:55" as gmail presents in replies.

    Handle unix timestamps.

    Attempt to parse TZ from strings before calling DataParse.

  • 2015-02-09 - VERSION 0.9

    First release. Basic but working.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 77:

=over without closing =back