File: parse_date.t

package info (click to toggle)
libdatetime-format-pg-perl 0.16007-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 276 kB
  • sloc: perl: 1,656; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,968 bytes parent folder | download | duplicates (6)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
# $Id: parse_date.t 1039 2003-05-30 14:04:49Z cfaerber $
use Test::More tests => 18;
use DateTime 0.10;
use DateTime::TimeZone 0.12;
use DateTime::Format::Pg 0.02;

my $dt;

# ISO 
#
$dt = DateTime::Format::Pg->parse_date('2003-04-26');
is($dt->ymd(), '2003-04-26');

$dt = DateTime::Format::Pg->parse_date('1900-01-01');
is($dt->ymd(), '1900-01-01');

$dt = DateTime::Format::Pg->parse_date('0001-12-24 BC');
is($dt->ymd(), '0000-12-24');

# PostgreSQL
#
$dt = DateTime::Format::Pg->parse_date('26-04-2003', 'european' => 1);
is($dt->ymd(), '2003-04-26');

$dt = DateTime::Format::Pg->parse_date('01-01-1900', 'european' => 1);
is($dt->ymd(), '1900-01-01');

$dt = DateTime::Format::Pg->parse_date('24-12-0001 BC', 'european' => 1);
is($dt->ymd(), '0000-12-24');

$dt = DateTime::Format::Pg->parse_date('04-26-2003', 'european' => 0);
is($dt->ymd(), '2003-04-26');

$dt = DateTime::Format::Pg->parse_date('01-01-1900', 'european' => 0);
is($dt->ymd(), '1900-01-01');

$dt = DateTime::Format::Pg->parse_date('12-24-0001 BC', 'european' => 0);
is($dt->ymd(), '0000-12-24');

# SQL
#
$dt = DateTime::Format::Pg->parse_date('26/04/2003', 'european' => 1);
is($dt->ymd(), '2003-04-26');

$dt = DateTime::Format::Pg->parse_date('01/01/1900', 'european' => 1);
is($dt->ymd(), '1900-01-01');

$dt = DateTime::Format::Pg->parse_date('24/12/0001 BC', 'european' => 1);
is($dt->ymd(), '0000-12-24');

$dt = DateTime::Format::Pg->parse_date('04/26/2003', 'european' => 0);
is($dt->ymd(), '2003-04-26');

$dt = DateTime::Format::Pg->parse_date('01/01/1900', 'european' => 0);
is($dt->ymd(), '1900-01-01');

$dt = DateTime::Format::Pg->parse_date('12/24/0001 BC', 'european' => 0);
is($dt->ymd(), '0000-12-24');

# German
#
$dt = DateTime::Format::Pg->parse_date('26.04.2003');
is($dt->ymd(), '2003-04-26');

$dt = DateTime::Format::Pg->parse_date('01.01.1900');
is($dt->ymd(), '1900-01-01');

$dt = DateTime::Format::Pg->parse_date('24.12.0001 BC');
is($dt->ymd(), '0000-12-24');