File: zones.t

package info (click to toggle)
libdatetime-format-strptime-perl 1.7900-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 6,812 kB
  • sloc: perl: 1,400; sh: 23; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 699 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use Test::More 0.96;
use Test::Fatal;

use DateTime::Format::Strptime;

{
    my $parser = DateTime::Format::Strptime->new(
        pattern  => '%Y %Z',
        on_error => 'croak',
    );

    like(
        exception { $parser->parse_datetime('2015 EST') },
        qr/ambiguous/,
        'parser dies on ambiguous zone abbreviation'
    );
}

{
    my $parser = DateTime::Format::Strptime->new(
        pattern  => '%Y %Z',
        zone_map => { EST => '-0200' },
        on_error => 'croak',
    );

    my $dt = $parser->parse_datetime('2015 EST');
    is(
        $dt->offset, -7200,
        'parser uses zone map provided with constructor'
    );
}

done_testing();