View | Details | Raw Unified | Return to bug 36486
Collapse All | Expand All

(-)a/t/Koha/DateTime/Format/SQL.t (-28 / +27 lines)
Lines 8-17 use Test::More; Link Here
8
8
9
BEGIN { use_ok('Koha::DateTime::Format::SQL'); }
9
BEGIN { use_ok('Koha::DateTime::Format::SQL'); }
10
10
11
my $local_timezone = DateTime::TimeZone->new( name => 'local' );
11
my $local_timezone   = DateTime::TimeZone->new( name => 'local' );
12
my $koha_config_mock = Test::MockModule->new('Koha::Config');
12
my $koha_config_mock = Test::MockModule->new('Koha::Config');
13
my $config = { timezone => '' };
13
my $config           = { timezone => '' };
14
$koha_config_mock->mock('get', sub { $config->{$_[1]} });
14
$koha_config_mock->mock( 'get', sub { $config->{ $_[1] } } );
15
15
16
subtest 'normal datetime, no timezone configured' => sub {
16
subtest 'normal datetime, no timezone configured' => sub {
17
    plan tests => 7;
17
    plan tests => 7;
Lines 21-32 subtest 'normal datetime, no timezone configured' => sub { Link Here
21
21
22
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('2024-01-02 10:11:12');
22
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('2024-01-02 10:11:12');
23
23
24
    is( $dt->year,   2024 );
24
    is( $dt->year,            2024 );
25
    is( $dt->month,  1 );
25
    is( $dt->month,           1 );
26
    is( $dt->day,    2 );
26
    is( $dt->day,             2 );
27
    is( $dt->hour,   10 );
27
    is( $dt->hour,            10 );
28
    is( $dt->minute, 11 );
28
    is( $dt->minute,          11 );
29
    is( $dt->second, 12 );
29
    is( $dt->second,          12 );
30
    is( $dt->time_zone->name, $local_timezone->name );
30
    is( $dt->time_zone->name, $local_timezone->name );
31
};
31
};
32
32
Lines 38-49 subtest 'normal datetime, with timezone configured' => sub { Link Here
38
38
39
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('2024-01-02 10:11:12');
39
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('2024-01-02 10:11:12');
40
40
41
    is( $dt->year,   2024 );
41
    is( $dt->year,            2024 );
42
    is( $dt->month,  1 );
42
    is( $dt->month,           1 );
43
    is( $dt->day,    2 );
43
    is( $dt->day,             2 );
44
    is( $dt->hour,   10 );
44
    is( $dt->hour,            10 );
45
    is( $dt->minute, 11 );
45
    is( $dt->minute,          11 );
46
    is( $dt->second, 12 );
46
    is( $dt->second,          12 );
47
    is( $dt->time_zone->name, 'Pacific/Auckland' );
47
    is( $dt->time_zone->name, 'Pacific/Auckland' );
48
};
48
};
49
49
Lines 55-66 subtest 'infinite datetime, no timezone configured' => sub { Link Here
55
55
56
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('9999-01-02 10:11:12');
56
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('9999-01-02 10:11:12');
57
57
58
    is( $dt->year,   9999 );
58
    is( $dt->year,            9999 );
59
    is( $dt->month,  1 );
59
    is( $dt->month,           1 );
60
    is( $dt->day,    2 );
60
    is( $dt->day,             2 );
61
    is( $dt->hour,   10 );
61
    is( $dt->hour,            10 );
62
    is( $dt->minute, 11 );
62
    is( $dt->minute,          11 );
63
    is( $dt->second, 12 );
63
    is( $dt->second,          12 );
64
    is( $dt->time_zone->name, 'floating' );
64
    is( $dt->time_zone->name, 'floating' );
65
};
65
};
66
66
Lines 72-83 subtest 'normal datetime, with timezone configured' => sub { Link Here
72
72
73
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('9999-01-02 10:11:12');
73
    my $dt = Koha::DateTime::Format::SQL->parse_datetime('9999-01-02 10:11:12');
74
74
75
    is( $dt->year,   9999 );
75
    is( $dt->year,            9999 );
76
    is( $dt->month,  1 );
76
    is( $dt->month,           1 );
77
    is( $dt->day,    2 );
77
    is( $dt->day,             2 );
78
    is( $dt->hour,   10 );
78
    is( $dt->hour,            10 );
79
    is( $dt->minute, 11 );
79
    is( $dt->minute,          11 );
80
    is( $dt->second, 12 );
80
    is( $dt->second,          12 );
81
    is( $dt->time_zone->name, 'floating' );
81
    is( $dt->time_zone->name, 'floating' );
82
};
82
};
83
83
84
- 

Return to bug 36486