Debian Codegraph @

t/rt106105.t

raw
1 use strict;
2 use warnings;
3 use Test::More tests => 6;
4 use Date::Parse qw(strptime);
5
6 # RT#106105: Date::Parse inconsistent year handling for years before 1901
7 # strptime() must return year as offset from 1900 consistently, regardless of
8 # whether the year is before or after 1900. Previously, years <= 1900 were
9 # returned as the full 4-digit year rather than (year - 1900).
10 {
11 # 1901: already worked — year=1, century=19
12 my @t1901 = strptime('1 Jan 1901 12:00');
13 is($t1901[5], 1, "RT#106105: strptime year field is 1 for 1901 (offset from 1900)");
14 is($t1901[7], 19, "RT#106105: strptime century field is 19 for 1901");
15
16 # 1900: boundary — year=0, century=19
17 my @t1900 = strptime('1 Jan 1900 12:00');
18 is($t1900[5], 0, "RT#106105: strptime year field is 0 for 1900 (offset from 1900)");
19 is($t1900[7], 19, "RT#106105: strptime century field is 19 for 1900");
20
21 # 1899: previously broken — returned 1899 instead of -1
22 my @t1899 = strptime('1 Jan 1899 12:00');
23 is($t1899[5], -1, "RT#106105: strptime year field is -1 for 1899 (offset from 1900)");
24 is($t1899[7], 18, "RT#106105: strptime century field is 18 for 1899");
25 }