-
Notifications
You must be signed in to change notification settings - Fork 1
/
07-week.t
56 lines (41 loc) · 1.08 KB
/
07-week.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
plan tests => 324;
use Time::C;
use Time::F;
use Time::P;
my @ts;
for my $year (1990 .. 2016) {
push @ts,
Time::C->new($year),
Time::C->new($year, 1, 22),
Time::C->new($year, 12, 31),
;
}
my $fmt = "%G: %V-%w";
foreach my $t (@ts) {
my $str = strftime $t, $fmt;
my $str2 = $t->tm->strftime($fmt);
is ($str, $str2, "Week for $t formatted correctly.") or BAIL_OUT;
}
$fmt = "%Y: %W-%w";
foreach my $t (@ts) {
my $str = strftime $t, $fmt;
my $str2 = $t->tm->strftime($fmt);
is ($str, $str2, "Week for $t formatted correctly.") or BAIL_OUT;
}
$fmt = "%G: %V-%w";
foreach my $t (@ts) {
my $str = strftime $t, $fmt;
my $t2 = Time::C->strptime($str, $fmt);
is ($t2, $t, "Week for $t parsed correctly.") or diag "$t => ($fmt) => $str => $t2";
}
$fmt = "%Y: %W-%w";
foreach my $t (@ts) {
my $str = strftime $t, $fmt;
my $t2 = Time::C->strptime($str, $fmt);
is ($t2, $t, "Week for $t parsed correctly.") or diag "$t => ($fmt) => $str => $t2";
}
#done_testing;