NAME
    App::DateUtils - An assortment of date-/time-related CLI utilities

VERSION
    This document describes version 0.122 of App::DateUtils (from Perl
    distribution App-DateUtils), released on 2019-11-29.

SYNOPSIS
    This distribution provides the following command-line utilities related
    to date/time:

    *   dateconv

    *   datediff

    *   durconv

    *   parse-date

    *   parse-date-using-df-alami-en

    *   parse-date-using-df-alami-id

    *   parse-date-using-df-flexible

    *   parse-date-using-df-natural

    *   parse-duration

    *   parse-duration-using-df-alami-en

    *   parse-duration-using-df-alami-id

    *   parse-duration-using-df-natural

    *   parse-duration-using-td-parse

FUNCTIONS
  dateconv
    Usage:

     dateconv(%args) -> any

    Convert date to another format.

    Examples:

    *   Convert "today" to epoch:

         dateconv(date => "today"); # -> [200, "OK", 1574985600]

    *   Convert epoch to ymd:

         dateconv(date => 1463702400, to => "ymd"); # -> "2016-05-20"

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   date* => *date*

    *   to => *str* (default: "epoch")

    Return value: (any)

  datediff
    Usage:

     datediff(%args) -> any

    Diff (subtract) two dates, show as ISO8601 duration.

    Examples:

    *   Example #1:

         datediff( date1 => "2019-06-18T20:08:42", date2 => "2019-06-19T06:02:03"); # -> "PT9H53M21S"

    *   Example #2:

         datediff(
           date1 => "2019-06-18T20:08:42",
           date2 => "2019-06-19T06:02:03",
           as => "hms"
         );

        Result:

         "09:53:21"

    *   Example #3:

         datediff(
           date1 => "2019-06-18T20:08:42",
           date2 => "2019-06-22T06:02:03",
           as => "concise_hms"
         );

        Result:

         "3d 09:53:21"

    *   Example #4:

         datediff(
           date1 => "2019-06-18T20:08:42",
           date2 => "2019-06-19T06:02:03",
           as => "seconds"
         );

        Result:

         35601

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   as => *str* (default: "iso8601")

    *   date1* => *date*

    *   date2* => *date*

    Return value: (any)

  durconv
    Usage:

     durconv(%args) -> any

    Convert duration to another format.

    Examples:

    *   Convert "3h2m" to number of seconds:

         durconv(duration => "3h2m"); # -> 10920

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   duration* => *duration*

    *   to => *str* (default: "secs")

    Return value: (any)

  parse_date
    Usage:

     parse_date(%args) -> [status, msg, payload, meta]

    Parse date string(s) using one of several modules.

    Examples:

    *   Example #1:

         parse_date( dates => ["23 sep 2015", "tomorrow", "foo"]);

        Result:

         [
           {
             module          => "DateTime::Format::Flexible",
             original        => "23 sep 2015",
             is_parseable    => 1,
             as_epoch        => 1442966400,
             as_datetime_obj => "2015-09-23T00:00:00",
           },
           {
             module          => "DateTime::Format::Flexible",
             original        => "tomorrow",
             is_parseable    => 1,
             as_epoch        => 1575072000,
             as_datetime_obj => "2019-11-30T00:00:00",
           },
           {
             module       => "DateTime::Format::Flexible",
             original     => "foo",
             is_parseable => 0,
             error_msg    => "Invalid date format: foo at /home/u1/perl5/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/Perinci/Access.pm line 81. ",
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   all_modules => *bool*

        Parse using all installed modules and return all the result at once.

    *   dates* => *array[str]*

    *   module => *str* (default: "DateTime::Format::Flexible")

    *   time_zone => *str*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_date_using_df_alami_en
    Usage:

     parse_date_using_df_alami_en(%args) -> [status, msg, payload, meta]

    Parse date string(s) using DateTime::Format::Alami::EN.

    Examples:

    *   Example #1:

         parse_date_using_df_alami_en(dates => ["23 May"]);

        Result:

         [
           {
             module          => "DateTime::Format::Alami::EN",
             original        => "23 May",
             is_parseable    => 1,
             as_epoch        => 1558569600,
             as_datetime_obj => "2019-05-23T00:00:00",
             pattern         => "p_dateymd",
           },
         ]

    *   Example #2:

         parse_date_using_df_alami_en(dates => ["foo"]);

        Result:

         [
           {
             module => "DateTime::Format::Alami::EN",
             original => "foo",
             is_parseable => 0,
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   dates* => *array[str]*

    *   time_zone => *str*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_date_using_df_alami_id
    Usage:

     parse_date_using_df_alami_id(%args) -> [status, msg, payload, meta]

    Parse date string(s) using DateTime::Format::Alami::ID.

    Examples:

    *   Example #1:

         parse_date_using_df_alami_id(dates => ["23 Mei"]);

        Result:

         [
           {
             module          => "DateTime::Format::Alami::ID",
             original        => "23 Mei",
             is_parseable    => 1,
             as_epoch        => 1558569600,
             as_datetime_obj => "2019-05-23T00:00:00",
             pattern         => "p_dateymd",
           },
         ]

    *   Example #2:

         parse_date_using_df_alami_id(dates => ["foo"]);

        Result:

         [
           {
             module => "DateTime::Format::Alami::ID",
             original => "foo",
             is_parseable => 0,
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   dates* => *array[str]*

    *   time_zone => *str*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_date_using_df_flexible
    Usage:

     parse_date_using_df_flexible(%args) -> [status, msg, payload, meta]

    Parse date string(s) using DateTime::Format::Flexible.

    Examples:

    *   Example #1:

         parse_date_using_df_flexible(dates => ["23rd Jun"]);

        Result:

         [
           {
             module          => "DateTime::Format::Flexible",
             original        => "23rd Jun",
             is_parseable    => 1,
             as_epoch        => 1561248000,
             as_datetime_obj => "2019-06-23T00:00:00",
           },
         ]

    *   Example #2:

         parse_date_using_df_flexible(dates => ["23 Dez"], lang => "de");

        Result:

         [
           {
             module          => "DateTime::Format::Flexible(de)",
             original        => "23 Dez",
             is_parseable    => 1,
             as_epoch        => 1577059200,
             as_datetime_obj => "2019-12-23T00:00:00",
           },
         ]

    *   Example #3:

         parse_date_using_df_flexible(dates => ["foo"]);

        Result:

         [
           {
             module       => "DateTime::Format::Flexible",
             original     => "foo",
             is_parseable => 0,
             error_msg    => "Invalid date format: foo at /home/u1/perl5/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/Perinci/Access.pm line 81. ",
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   dates* => *array[str]*

    *   lang => *str* (default: "en")

    *   time_zone => *str*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_date_using_df_natural
    Usage:

     parse_date_using_df_natural(%args) -> [status, msg, payload, meta]

    Parse date string(s) using DateTime::Format::Natural.

    Examples:

    *   Example #1:

         parse_date_using_df_natural(dates => ["23rd Jun"]);

        Result:

         [
           {
             module          => "DateTime::Format::Natural",
             original        => "23rd Jun",
             is_parseable    => 1,
             as_epoch        => 1561248000,
             as_datetime_obj => "2019-06-23T00:00:00",
           },
         ]

    *   Example #2:

         parse_date_using_df_natural(dates => ["foo"]);

        Result:

         [
           {
             module       => "DateTime::Format::Natural",
             original     => "foo",
             is_parseable => 0,
             error_msg    => "'foo' does not parse (perhaps you have some garbage?)",
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   dates* => *array[str]*

    *   time_zone => *str*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_duration
    Usage:

     parse_duration(%args) -> [status, msg, payload, meta]

    Parse duration string(s) using one of several modules.

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   all_modules => *bool*

        Parse using all installed modules and return all the result at once.

    *   durations* => *array[str]*

    *   module => *str* (default: "Time::Duration::Parse")

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_duration_using_df_alami_en
    Usage:

     parse_duration_using_df_alami_en(%args) -> [status, msg, payload, meta]

    Parse duration string(s) using DateTime::Format::Alami::EN.

    Examples:

    *   Example #1:

         parse_duration_using_df_alami_en(durations => ["2h, 3mins"]);

        Result:

         [
           {
             module       => "DateTime::Format::Alami::EN",
             original     => "2h, 3mins",
             is_parseable => 1,
             as_secs      => 7380,
             as_dtdur_obj => "PT2H3M",
           },
         ]

    *   Example #2:

         parse_duration_using_df_alami_en(durations => ["foo"]);

        Result:

         [
           {
             module => "DateTime::Format::Alami::EN",
             original => "foo",
             is_parseable => 0,
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   durations* => *array[str]*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_duration_using_df_alami_id
    Usage:

     parse_duration_using_df_alami_id(%args) -> [status, msg, payload, meta]

    Parse duration string(s) using DateTime::Format::Alami::ID.

    Examples:

    *   Example #1:

         parse_duration_using_df_alami_id(durations => ["2j, 3mnt"]);

        Result:

         [
           {
             module       => "DateTime::Format::Alami::ID",
             original     => "2j, 3mnt",
             is_parseable => 1,
             as_secs      => 7380,
             as_dtdur_obj => "PT2H3M",
           },
         ]

    *   Example #2:

         parse_duration_using_df_alami_id(durations => ["foo"]);

        Result:

         [
           {
             module => "DateTime::Format::Alami::ID",
             original => "foo",
             is_parseable => 0,
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   durations* => *array[str]*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_duration_using_df_natural
    Usage:

     parse_duration_using_df_natural(%args) -> [status, msg, payload, meta]

    Parse duration string(s) using DateTime::Format::Natural.

    Examples:

    *   Example #1:

         parse_duration_using_df_natural(durations => ["for 2 weeks"]);

        Result:

         [
           {
             module => "DateTime::Format::Natural",
             original => "for 2 weeks",
             is_parseable => 1,
             as_secs => 1209600,
             as_dtdur_obj => "P14D",
             date1 => "2019-11-29T02:17:55",
             date2 => "2019-12-13T02:17:55",
           },
         ]

    *   Example #2:

         parse_duration_using_df_natural(durations => ["from 23 Jun to 29 Jun"]);

        Result:

         [
           {
             module => "DateTime::Format::Natural",
             original => "from 23 Jun to 29 Jun",
             is_parseable => 1,
             as_secs => 13157275,
             as_dtdur_obj => "P5MT2H17M55S",
             date1 => "2019-11-29T02:17:55",
             date2 => "2019-06-29T00:00:00",
           },
         ]

    *   Example #3:

         parse_duration_using_df_natural(durations => ["foo"]);

        Result:

         [
           {
             module       => "DateTime::Format::Natural",
             original     => "foo",
             is_parseable => 0,
             error_msg    => "'foo' does not parse (perhaps you have some garbage?)",
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   durations* => *array[str]*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  parse_duration_using_td_parse
    Usage:

     parse_duration_using_td_parse(%args) -> [status, msg, payload, meta]

    Parse duration string(s) using Time::Duration::Parse.

    Examples:

    *   Example #1:

         parse_duration_using_td_parse(durations => ["2 days 13 hours"]);

        Result:

         [
           {
             module       => "Time::Duration::Parse",
             original     => "2 days 13 hours",
             is_parseable => 1,
             as_secs      => 219600,
           },
         ]

    *   Example #2:

         parse_duration_using_td_parse(durations => ["foo"]);

        Result:

         [
           {
             module       => "Time::Duration::Parse",
             original     => "foo",
             is_parseable => 0,
             error_msg    => "Unknown timespec: foo at lib/App/DateUtils.pm line 374. ",
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   durations* => *array[str]*

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/App-DateUtils>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-App-DateUtils>.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    <https://rt.cpan.org/Public/Dist/Display.html?Name=App-DateUtils>

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

SEE ALSO
    dateparse. The official CLI for DateTime::Format::Natural.

    App::datecalc

AUTHOR
    perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2019, 2017, 2016, 2015 by
    perlancar@cpan.org.

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

