6 use Support::TestSetup;
8 Support::TestSetup::login();
11 my ($string, $expected, $msg, %args) = @_;
13 is($::locale->format_date_object($::locale->parse_date_to_object($string, %args), numberformat => '1000.00', dateformat => 'yy-mm-dd', precision => 'millisecond'), $expected, $msg);
16 is($::locale->parse_date_to_object('in-valid!'), undef, 'defaults, invalid');
18 delete $::myconfig{numberformat};
19 delete $::myconfig{dateformat};
21 is_dt('2014-05-31', '2014-05-31 00:00:00.000', 'defaults, no precision');
22 is_dt('2014-05-31 2', '2014-05-31 02:00:00.000', 'defaults, precision hour');
23 is_dt('2014-05-31 2:04', '2014-05-31 02:04:00.000', 'defaults, precision minute');
24 is_dt('2014-05-31 2:04:59', '2014-05-31 02:04:59.000', 'defaults, precision second');
25 is_dt('2014-05-31 02:4:59.098', '2014-05-31 02:04:59.098', 'defaults, precision millisecond');
26 is_dt('2014-05-31 02:4:59.09', '2014-05-31 02:04:59.090', 'defaults, precision centisecond');
28 $::myconfig{numberformat} = '1.000,00';
29 $::myconfig{dateformat} = 'dd.mm.yy';
31 is_dt('31.05.2014', '2014-05-31 00:00:00.000', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, no precision');
32 is_dt('31.05.2014 2', '2014-05-31 02:00:00.000', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision hour');
33 is_dt('31.05.2014 2:04', '2014-05-31 02:04:00.000', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision minute');
34 is_dt('31.05.2014 2:04:59', '2014-05-31 02:04:59.000', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision second');
35 is_dt('31.05.2014 02:4:59,098', '2014-05-31 02:04:59.098', 'myconfig numberformat 1.000,00 dateformat dd.mm.yy, precision millisecond');
37 is_dt('05/31/2014', '2014-05-31 00:00:00.000', 'myconfig numberformat 1.000,00 explicit dateformat mm/dd/yy, no precision', dateformat => 'mm/dd/yy');
38 is_dt('05/31/2014 2', '2014-05-31 02:00:00.000', 'myconfig numberformat 1.000,00 explicit dateformat mm/dd/yy, precision hour', dateformat => 'mm/dd/yy');
39 is_dt('05/31/2014 2:04', '2014-05-31 02:04:00.000', 'myconfig numberformat 1.000,00 explicit dateformat mm/dd/yy, precision minute', dateformat => 'mm/dd/yy');
40 is_dt('05/31/2014 2:04:59', '2014-05-31 02:04:59.000', 'myconfig numberformat 1.000,00 explicit dateformat mm/dd/yy, precision second', dateformat => 'mm/dd/yy');
41 is_dt('05/31/2014 02:4:59,098', '2014-05-31 02:04:59.098', 'myconfig numberformat 1.000,00 explicit dateformat mm/dd/yy, precision millisecond', dateformat => 'mm/dd/yy');
43 is_dt('05/31/2014', '2014-05-31 00:00:00.000', 'explicit numberformat 1000.00 explicit dateformat mm/dd/yy, no precision', dateformat => 'mm/dd/yy', numberformat => '1000.00');
44 is_dt('05/31/2014 2', '2014-05-31 02:00:00.000', 'explicit numberformat 1000.00 explicit dateformat mm/dd/yy, precision hour', dateformat => 'mm/dd/yy', numberformat => '1000.00');
45 is_dt('05/31/2014 2:04', '2014-05-31 02:04:00.000', 'explicit numberformat 1000.00 explicit dateformat mm/dd/yy, precision minute', dateformat => 'mm/dd/yy', numberformat => '1000.00');
46 is_dt('05/31/2014 2:04:59', '2014-05-31 02:04:59.000', 'explicit numberformat 1000.00 explicit dateformat mm/dd/yy, precision second', dateformat => 'mm/dd/yy', numberformat => '1000.00');
47 is_dt('05/31/2014 02:4:59.098', '2014-05-31 02:04:59.098', 'explicit numberformat 1000.00 explicit dateformat mm/dd/yy, precision millisecond', dateformat => 'mm/dd/yy', numberformat => '1000.00');