summaryrefslogtreecommitdiff
path: root/t/format.t
blob: c1ad071f4567f48c99057c0c09bc4cd823117522 (plain)
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
#!perl 
use Test::More tests=>17;
use DateTime;
use DateTime::Format::GeekTime;
 
{
my $dt=DateTime->new(year=>2010,month=>3,day=>8,
                     hour=>17,minute=>56,second=>23,
                     time_zone=>'Europe/Rome',
                 );
is(DateTime::Format::GeekTime->format_datetime($dt),
   "0xB4B1 on day 0x042 \x{b4b1}");
}
 
{
my $dt=DateTime::Format::GeekTime->parse_datetime("0xB4B1 0x0042 \x{b4b0}");
is($dt->month,3);
is($dt->day,8);
is($dt->hour,16);
is($dt->minute,56);
is($dt->second,23);
is($dt->time_zone->name,'UTC');
 
my $other=DateTime::Format::GeekTime->parse_datetime("0xB4B1 0x0042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("0xB4B1 on day 0x0042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("B4B1 0042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("B4B10042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("b4b10042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("0xB4B1 0x042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("B4B1 042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("B4B1042");
cmp_ok($dt,'==',$other);
$other=DateTime::Format::GeekTime->parse_datetime("b4b1042");
cmp_ok($dt,'==',$other);
}
 
# bad codepoint 
my $dt=DateTime::Format::GeekTime->parse_datetime('0xdc01 0x000');
is(DateTime::Format::GeekTime->format_datetime($dt),
   '0xDC01 on day 0x000');
}