packaging one directory
|
1 |
use Test::More; |
2 |
use strict; |
|
3 |
use warnings; |
|
4 |
|
|
5 |
BEGIN { |
|
6 |
eval { require Time::Piece; 1 } |
|
7 |
or plan skip_all => 'Time::Piece required'; |
|
8 |
|
|
9 |
eval { Time::Piece->VERSION >= 1.15 } |
|
10 |
or plan skip_all => 'Time::Piece >= 1.15 requred'; |
|
11 |
|
|
12 |
plan 'no_plan'; |
|
13 |
use_ok('DBIx::Custom'); |
|
14 |
} |
|
15 |
|
|
16 |
# Function for test name |
|
17 |
my $test; |
|
18 |
sub test { |
|
19 |
$test = shift; |
|
20 |
} |
|
21 |
|
|
22 |
# Varialbe for tests |
|
23 |
|
|
24 |
my $format; |
|
25 |
my $data; |
|
26 |
my $timepiece; |
|
27 |
my $dbi; |
|
28 |
|
|
29 |
use DBIx::Custom::Basic; |
|
30 |
|
|
31 |
|
|
32 |
test 'SQL99 format'; |
|
33 |
$dbi = DBIx::Custom::Basic->new; |
|
34 |
$data = '2009-01-02 03:04:05'; |
|
35 |
$format = $dbi->formats->{'SQL99_datetime'}; |
|
36 |
$timepiece = Time::Piece->strptime($data, $format); |
|
37 |
is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date"); |
|
38 |
is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time"); |
|
39 |
|
|
40 |
$data = '2009-01-02'; |
|
41 |
$format = $dbi->formats->{'SQL99_date'}; |
|
42 |
$timepiece = Time::Piece->strptime($data, $format); |
|
43 |
is($timepiece->strftime('%F'), '2009-01-02', "$test : date"); |
|
44 |
|
|
45 |
$data = '03:04:05'; |
|
46 |
$format = $dbi->formats->{'SQL99_time'}; |
|
47 |
$timepiece = Time::Piece->strptime($data, $format); |
|
48 |
is($timepiece->strftime('%T'), '03:04:05', "$test : time"); |
|
49 |
|
|
50 |
|
|
51 |
test 'ISO-8601 format'; |
|
52 |
$data = '2009-01-02T03:04:05'; |
|
53 |
$format = $dbi->formats->{'ISO-8601_datetime'}; |
|
54 |
$timepiece = Time::Piece->strptime($data, $format); |
|
55 |
is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date"); |
|
56 |
is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time"); |
|
57 |
|
|
58 |
$data = '2009-01-02'; |
|
59 |
$format = $dbi->formats->{'ISO-8601_date'}; |
|
60 |
$timepiece = Time::Piece->strptime($data, $format); |
|
61 |
is($timepiece->strftime('%F'), '2009-01-02', "$test : date"); |
|
62 |
|
|
63 |
$data = '03:04:05'; |
|
64 |
$format = $dbi->formats->{'ISO-8601_time'}; |
|
65 |
$timepiece = Time::Piece->strptime($data, $format); |
|
66 |
is($timepiece->strftime('%T'), '03:04:05', "$test : time"); |
|
67 |
|