NAME
    Mo::utils::Date - Mo date utilities.

SYNOPSIS
     use Mo::utils::Date qw(check_date check_date_dmy check_date_ddmmyy check_date_yymmdd check_date_order);

     check_date($self, $key);
     check_date_dmy($self, $key);
     check_date_ddmmyy($self, $key);
     check_date_yymmdd($self, $key);
     check_date_order($self, $key1, $key2);

DESCRIPTION
    Utilities for checking of date values.

SUBROUTINES
  "check_date"
     check_date($self, $key);

    *Since version 0.01. Described functionality since version 0.02.*

    Check parameter defined by $key which is date and that date isn't
    greater than actual year.

    Possible dates: - YYYY-MM-DD - YYYY-M-D - YYYY-MM - YYYY-M - YYYY

    Put error if check isn't ok.

    Returns undef.

  "check_date_dmy"
     check_date_dmy($self, $key);

    *Since version 0.02. Described functionality since version 0.03.*

    Check parameter defined by $key which is date in right format.

    Possible dates. - D.M.YYYY - DD.MM.YYYY

    Date is checked via DateTime if is real.

    Put error if check isn't ok.

    Returns undef.

  "check_date_ddmmyy"
     check_date_ddmmyy($self, $key);

    *Since version 0.03.*

    Check parameter defined by $key which is date in ddmmyy format.

    Possible dates. - DDMMYY

    Function is working only for date years > 2000.

    Date is checked via DateTime if it is real.

    Put error if check isn't ok.

    Returns undef.

  "check_date_yymmdd"
     check_date_yymmdd($self, $key);

    *Since version 0.05.*

    Check parameter defined by $key which is date in yymmdd format.

    Possible dates. - YYMMDD

    Function is working only for date years > 2000.

    Date is checked via DateTime if it is real.

    Put error if check isn't ok.

    Returns undef.

  "check_date_order"
     check_date_order($self, $key1, $key2);

    *Since version 0.01. Described functionality since version 0.04.*

    Check if date with $key1 is lesser than date with $key2.

    Possible date formats:

    *   YYYY-MM-DD

    *   -YYYY-MM-DD

    *   YEAR

    *   DateTime object

    Put error if check isn't ok.

    Returns undef.

ERRORS
     check_date():
             Parameter '%s' for date is in bad format.
                     Value: %s
             Parameter '%s' has year greater than actual year.

     check_date_dmy():
             Parameter '%s' for date is in bad format.
                     Value: %s
             Parameter '%s' is bad date.
                     Value: %s
                     DateTime error: %s

     check_date_ddmmyy():
             Parameter '%s' for date is in bad date format.
                     Value: %s
             Parameter '%s' is bad date.
                     Value: %s
                     DateTime error: %s

     check_date_yymmdd():
             Parameter '%s' for date is in bad date format.
                     Value: %s
             Parameter '%s' is bad date.
                     Value: %s
                     DateTime error: %s

     check_date_order():
             Cannot parse date/time string.
                     Value: %s
             Cannot construct DateTime object from date.
                     Value: %s
                     DateTime error: %s
             Parameter '%s' has date greater or same as parameter '%s' date.

EXAMPLES
  EXAMPLE1
     use strict;
     use warnings;

     use Mo::utils::Date qw(check_date);

     my $self = {
             'key' => '2022-01-15',
     };
     check_date($self, 'key');

     # Print out.
     print "ok\n";

     # Output:
     # ok

  EXAMPLE2
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Date qw(check_date);

     $Error::Pure::TYPE = 'Error';

     my $self = {
             'key' => 'foo',
     };
     check_date($self, 'key');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Utils.pm:?] Parameter 'key' is in bad format.

  EXAMPLE3
     use strict;
     use warnings;

     use Mo::utils::Date qw(check_date_ddmmyy);

     my $self = {
             'key' => '151120',
     };
     check_date_ddmmyy($self, 'key');

     # Print out.
     print "ok\n";

     # Output:
     # ok

  EXAMPLE4
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Date qw(check_date_ddmmyy);

     $Error::Pure::TYPE = 'Error';

     my $self = {
             'key' => 'foo',
     };
     check_date_ddmmyy($self, 'key');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Utils.pm:?] Parameter 'key' for date is in bad format.

  EXAMPLE5
     use strict;
     use warnings;

     use Mo::utils::Date qw(check_date_yymmdd);

     my $self = {
             'key' => '201115',
     };
     check_date_yymmdd($self, 'key');

     # Print out.
     print "ok\n";

     # Output:
     # ok

  EXAMPLE6
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Date qw(check_date_yymmdd);

     $Error::Pure::TYPE = 'Error';

     my $self = {
             'key' => 'foo',
     };
     check_date_yymmdd($self, 'key');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Utils.pm:?] Parameter 'key' for date is in bad format.

DEPENDENCIES
    DateTime, English, Exporter, Error::Pure, Readonly.

SEE ALSO
    Mo::utils
        Mo utilities.

REPOSITORY
    <https://github.com/michal-josef-spacek/Mo-utils-Date>

AUTHOR
    Michal Josef Špaček <mailto:skim@cpan.org>

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2022-2026 Michal Josef Špaček

    BSD 2-Clause License

VERSION
    0.05

