6 use Support::TestSetup;
8 Support::TestSetup::login();
10 my $dt = DateTime->new(year => 2014, month => 5, day => 31, hour => 23, minute => 9, second => 8, nanosecond => 12000000);
12 delete $::myconfig{numberformat};
13 delete $::myconfig{dateformat};
15 is($::locale->format_date_object($dt), '2014-05-31', 'defaults, no precision');
16 is($::locale->format_date_object($dt, precision => 'day'), '2014-05-31', 'defaults, precision day');
17 is($::locale->format_date_object($dt, precision => 'hour'), '2014-05-31 23', 'defaults, precision hour');
18 is($::locale->format_date_object($dt, precision => 'minute'), '2014-05-31 23:09', 'defaults, precision minute');
19 is($::locale->format_date_object($dt, precision => 'second'), '2014-05-31 23:09:08', 'defaults, precision second');
20 is($::locale->format_date_object($dt, precision => 'millisecond'), '2014-05-31 23:09:08.012', 'defaults, precision millisecond');
22 $::myconfig{numberformat} = '1.000,00';
23 $::myconfig{dateformat} = 'dd.mm.yy';
25 is($::locale->format_date_object($dt), '31.05.2014', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, no precision');
26 is($::locale->format_date_object($dt, precision => 'day'), '31.05.2014', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision day');
27 is($::locale->format_date_object($dt, precision => 'hour'), '31.05.2014 23', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision hour');
28 is($::locale->format_date_object($dt, precision => 'minute'), '31.05.2014 23:09', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision minute');
29 is($::locale->format_date_object($dt, precision => 'second'), '31.05.2014 23:09:08', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision second');
30 is($::locale->format_date_object($dt, precision => 'millisecond'), '31.05.2014 23:09:08,012', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision millisecond');
32 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy'), '05/31/2014', 'myconfig numberformat 1.000,00, explicit dateformat mm/dd/yy, no precision');
33 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', precision => 'day'), '05/31/2014', 'myconfig numberformat 1.000,00, explicit dateformat mm/dd/yy, precision day');
34 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', precision => 'hour'), '05/31/2014 23', 'myconfig numberformat 1.000,00, explicit dateformat mm/dd/yy, precision hour');
35 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', precision => 'minute'), '05/31/2014 23:09', 'myconfig numberformat 1.000,00, explicit dateformat mm/dd/yy, precision minute');
36 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', precision => 'second'), '05/31/2014 23:09:08', 'myconfig numberformat 1.000,00, explicit dateformat mm/dd/yy, precision second');
37 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', precision => 'millisecond'), '05/31/2014 23:09:08,012', 'myconfig numberformat 1.000,00, explicit dateformat mm/dd/yy, precision millisecond');
39 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', numberformat => '1000.00'), '05/31/2014', 'explicit numberformat 1000.00 dateformat mm/dd/yy, no precision');
40 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', numberformat => '1000.00', precision => 'day'), '05/31/2014', 'explicit numberformat 1000.00 dateformat mm/dd/yy, precision day');
41 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', numberformat => '1000.00', precision => 'hour'), '05/31/2014 23', 'explicit numberformat 1000.00 dateformat mm/dd/yy, precision hour');
42 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', numberformat => '1000.00', precision => 'minute'), '05/31/2014 23:09', 'explicit numberformat 1000.00 dateformat mm/dd/yy, precision minute');
43 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', numberformat => '1000.00', precision => 'second'), '05/31/2014 23:09:08', 'explicit numberformat 1000.00 dateformat mm/dd/yy, precision second');
44 is($::locale->format_date_object($dt, dateformat => 'mm/dd/yy', numberformat => '1000.00', precision => 'millisecond'), '05/31/2014 23:09:08.012', 'explicit numberformat 1000.00 dateformat mm/dd/yy, precision millisecond');