Advanced-Config

 view release on metacpan or  search on metacpan

t/09-basic_date.t  view on Meta::CPAN

my %dl_tests = (
        "wed Jun 16"                           => "%04d-06-16",
        "wed 16 Jun"                           => "%04d-06-16",
        # "wed 2016 Jun"                       => "2016-06-01",  # Doesn't work
    );

my %german_tests = (
        "1995:01:24T09:08:17.1823213"          => "1995-01-24",
        "1995-01-24T09:08:17.1823213"          => "1995-01-24",
        "Mit, 16 Jun 94 07:29:35 CST"          => "1994-06-16",
        "Don, 13 Okt 94 10:13:13 -0700"        => "1994-10-13",
        "Don, 13 Oktober 94 10:13:13 -0700"    => "1994-10-13",
        "Mit, 9 Nov 1994 09:50:32 -0500 (EST)" => "1994-11-09",
        "25 dez 2017 17:05"                    => "2017-12-25",
        "25/dez/2017 17:05"                    => "2017-12-25",
        "17/dez/25 17:05"                      => "2017-12-25",   # Ambiguous
        "Mon, 25/dez/2017 17:05"               => "2017-12-25",
        "mon Dez. 25th 17 17:05"               => "2017-12-25",
        "Mon Dezember 25th 17 17:05"           => "2017-12-25",
        "Mon Dezember 25th 03:45:08 2017"      => "2017-12-25",
        "Mon Dezember 25 03:45:08 2017"        => "2017-12-25",
        "Mon Dezember 25, 2017 03:45:08"       => "2017-12-25",
        "Mit,  16    Jun   94 07:29:35 CST"    => "1994-06-16",
        "März 23rd, 2019"                      => "2019-03-23",
        "MÄRZ 22nd, 2019"                      => "2019-03-22",
    );

my %spanish_tests = (
        "1995:01:24T09:08:17.1823213"          => "1995-01-24",
        "1995-01-24T09:08:17.1823213"          => "1995-01-24",
        "Mié, 16 Jun 94 07:29:35 CST"          => "1994-06-16",
        "Jue, 13 Oct 94 10:13:13 -0700"        => "1994-10-13",
        "Jue, 13 Octubre 94 10:13:13 -0700"    => "1994-10-13",
        "Mié, 9 Nov 1994 09:50:32 -0500 (EST)" => "1994-11-09",
        "25 dic 2017 17:05"                    => "2017-12-25",
        "25/dic/2017 17:05"                    => "2017-12-25",
        "17/dic/25 17:05"                      => "2017-12-25",   # Ambiguous
        "Lun, 25/dic/2017 17:05"               => "2017-12-25",
        "Lun Dic. 25to 17 17:05"               => "2017-12-25",
        "Lun Diciembre 25to 17 17:05"          => "2017-12-25",
        "Lun Diciembre 25to 03:45:08 2017"     => "2017-12-25",
        "Lun Diciembre 25 03:45:08 2017"       => "2017-12-25",
        "Lun Diciembre 25, 2017 03:45:08"      => "2017-12-25",
        "Mié, 16    Jun    94 07:29:35 CST"    => "1994-06-16",
    );

my %no_tests;

# date => [hyd, DoW, DoY]
my %hyd_tests = (
	"1899-12-31"    => [     0,  0, 365 ],         # Special case.

	# Start of -hyd tests
	"1899-12-30"    => [    -1,  6, 364 ],
	"1899-11-30"    => [   -31,  4, 334 ],

	# Leap Year tests -hyd
	"1820-02-28"    => [ -29161, 1,  59 ],
	"1820-02-29"    => [ -29160, 2,  60 ],
	"1820-03-01"    => [ -29159, 3,  61 ],
	# "1821-02-29"  => [ undef, undef, undef ],    # Bad Leap Year

	# A year's worth of edge cases: -hyd
	"1822-12-31"    => [ -28124, 2, 365 ],
	"1823-01-01"    => [ -28123, 3,   1 ],
	"1823-01-31"    => [ -28093, 5,  31 ],
	"1823-02-01"    => [ -28092, 6,  32 ],
	"1823-02-28"    => [ -28065, 5,  59 ],
	"1823-03-01"    => [ -28064, 6,  60 ],
	"1823-03-31"    => [ -28034, 1,  90 ],
	"1823-04-01"    => [ -28033, 2,  91 ],
	"1823-04-30"    => [ -28004, 3, 120 ],
	"1823-05-01"    => [ -28003, 4, 121 ],
	"1823-05-31"    => [ -27973, 6, 151 ],
	"1823-06-01"    => [ -27972, 0, 152 ],
	"1823-06-30"    => [ -27943, 1, 181 ],
	"1823-07-01"    => [ -27942, 2, 182 ],
	"1823-07-31"    => [ -27912, 4, 212 ],
	"1823-08-01"    => [ -27911, 5, 213 ],
	"1823-08-31"    => [ -27881, 0, 243 ],
	"1823-09-01"    => [ -27880, 1, 244 ],
	"1823-09-30"    => [ -27851, 2, 273 ],
	"1823-10-01"    => [ -27850, 3, 274 ],
	"1823-10-31"    => [ -27820, 5, 304 ],
	"1823-11-01"    => [ -27819, 6, 305 ],
	"1823-11-30"    => [ -27790, 0, 334 ],
	"1823-12-01"    => [ -27789, 1, 335 ],
	"1823-12-31"    => [ -27759, 3, 365 ],
	"1824-01-01"    => [ -27758, 4,   1 ],

	# A year's worth of middle of the road test cases: -hyd
	"1824-01-15"    => [ -27744, 4,  15 ],
	"1824-02-15"    => [ -27713, 0,  46 ],
	"1824-03-15"    => [ -27684, 1,  75 ],
	"1824-04-15"    => [ -27653, 4, 106 ],
	"1824-05-15"    => [ -27623, 6, 136 ],
	"1824-06-15"    => [ -27592, 2, 167 ],
	"1824-07-15"    => [ -27562, 4, 197 ],
	"1824-08-15"    => [ -27531, 0, 228 ],
	"1824-09-15"    => [ -27500, 3, 259 ],
	"1824-10-15"    => [ -27470, 5, 289 ],
	"1824-11-15"    => [ -27439, 1, 320 ],
	"1824-12-15"    => [ -27409, 3, 350 ],

	# Start of +hyd tests
	"1900-01-01"    => [      1, 1,   1 ],
	"1900-12-31"    => [    365, 1, 365 ],
	"2013-06-04"    => [  41428, 2, 155 ],

	# Leap Year tests +hyd
	"2020-02-28"    => [  43888, 5,  59 ],
	"2020-02-29"    => [  43889, 6,  60 ],
	"2020-03-01"    => [  43890, 0,  61 ],
	# "2021-02-29"  => [ undef, undef, undef ],    # Bad Leap Year

	# A year's worth of edge cases: +hyd
	"2022-12-31"    => [  44925, 6, 365 ],
	"2023-01-01"    => [  44926, 0,   1 ],
	"2023-01-31"    => [  44956, 2,  31 ],
	"2023-02-01"    => [  44957, 3,  32 ],
	"2023-02-28"    => [  44984, 2,  59 ],
	"2023-03-01"    => [  44985, 3,  60 ],
	"2023-03-31"    => [  45015, 5,  90 ],
	"2023-04-01"    => [  45016, 6,  91 ],
	"2023-04-30"    => [  45045, 0, 120 ],
	"2023-05-01"    => [  45046, 1, 121 ],
	"2023-05-31"    => [  45076, 3, 151 ],
	"2023-06-01"    => [  45077, 4, 152 ],
	"2023-06-30"    => [  45106, 5, 181 ],
	"2023-07-01"    => [  45107, 6, 182 ],
	"2023-07-31"    => [  45137, 1, 212 ],
	"2023-08-01"    => [  45138, 2, 213 ],
	"2023-08-31"    => [  45168, 4, 243 ],
	"2023-09-01"    => [  45169, 5, 244 ],
	"2023-09-30"    => [  45198, 6, 273 ],
	"2023-10-01"    => [  45199, 0, 274 ],
	"2023-10-31"    => [  45229, 2, 304 ],
	"2023-11-01"    => [  45230, 3, 305 ],
	"2023-11-30"    => [  45259, 4, 334 ],
	"2023-12-01"    => [  45260, 5, 335 ],
	"2023-12-31"    => [  45290, 0, 365 ],
	"2024-01-01"    => [  45291, 1,   1 ],

	# A year's worth of middle of the road test cases: +hyd
	"2024-01-15"    => [  45305, 1,  15 ],
	"2024-02-15"    => [  45336, 4,  46 ],
	"2024-03-15"    => [  45365, 5,  75 ],
	"2024-04-15"    => [  45396, 1, 106 ],
	"2024-05-15"    => [  45426, 3, 136 ],
	"2024-06-15"    => [  45457, 6, 167 ],
	"2024-07-15"    => [  45487, 1, 197 ],
	"2024-08-15"    => [  45518, 4, 228 ],
	"2024-09-15"    => [  45549, 0, 259 ],
	"2024-10-15"    => [  45579, 2, 289 ],
	"2024-11-15"    => [  45610, 5, 320 ],
	"2024-12-15"    => [  45640, 0, 350 ],
    );

   # idx => [date, years, months, answer]
   my %adj_tests = (
	# Middle of month tests
	"a08"    => [ "1999-12-15", 0, -46, "1996-02-15" ],
	"a09"    => [ "1999-12-15", 0, -36, "1996-12-15" ],
	"a10"    => [ "1999-12-15", 0, -13, "1998-11-15" ],
	"a11"    => [ "1999-12-15", 0, -12, "1998-12-15" ],
	"a12"    => [ "1999-12-15", 0, -11, "1999-01-15" ],
	"a13"    => [ "1999-12-15", 0, -10, "1999-02-15" ],
	"a14"    => [ "1999-12-15", 0,  -9, "1999-03-15" ],
	"a15"    => [ "1999-12-15", 0,  -8, "1999-04-15" ],
	"a16"    => [ "1999-12-15", 0,  -7, "1999-05-15" ],
	"a17"    => [ "1999-12-15", 0,  -6, "1999-06-15" ],
	"a18"    => [ "1999-12-15", 0,  -5, "1999-07-15" ],
	"a19"    => [ "1999-12-15", 0,  -4, "1999-08-15" ],
	"a20"    => [ "1999-12-15", 0,  -3, "1999-09-15" ],



( run in 1.359 second using v1.01-cache-2.11-cpan-d80b1682f3f )