File: 01sanity.t

package info (click to toggle)
libdatetime-perl 2%3A1.50-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,504 kB
  • sloc: perl: 2,964; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Test::More;

use DateTime;

{
    my $dt = DateTime->new(
        year       => 1870, month  => 10, day    => 21,
        hour       => 12,   minute => 10, second => 45,
        nanosecond => 123456,
        time_zone  => 'UTC'
    );

    is( $dt->year,       '1870',   'Year accessor, outside of the epoch' );
    is( $dt->month,      '10',     'Month accessor, outside the epoch' );
    is( $dt->day,        '21',     'Day accessor, outside the epoch' );
    is( $dt->hour,       '12',     'Hour accessor, outside the epoch' );
    is( $dt->minute,     '10',     'Minute accessor, outside the epoch' );
    is( $dt->second,     '45',     'Second accessor, outside the epoch' );
    is( $dt->nanosecond, '123456', 'nanosecond accessor, outside the epoch' );

    $dt = DateTime->from_object( object => $dt );
    is( $dt->year,       '1870',   'Year should be identical' );
    is( $dt->month,      '10',     'Month should be identical' );
    is( $dt->day,        '21',     'Day should be identical' );
    is( $dt->hour,       '12',     'Hour should be identical' );
    is( $dt->minute,     '10',     'Minute should be identical' );
    is( $dt->second,     '45',     'Second should be identical' );
    is( $dt->nanosecond, '123456', 'nanosecond should be identical' );
}

{
    my $dt = DateTime->new(
        year      => 1870, month  => 10, day    => 21,
        hour      => 12,   minute => 10, second => 45,
        time_zone => 'UTC'
    );
    is( $dt->minute, '10', 'Minute accessor, outside the epoch' );
    is( $dt->second, '45', 'Second accessor, outside the epoch' );
}

done_testing();