File: 26dt-leapsecond-pm.t

package info (click to toggle)
libdatetime-perl 2%3A1.65-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,920 kB
  • sloc: perl: 2,986; sh: 23; makefile: 3
file content (58 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (2)
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
# no pp test

use strict;
use warnings;

use Test::More;

use DateTime::LeapSecond;

undef $ENV{PERL_DATETIME_DEFAULT_TZ};

is( DateTime::LeapSecond::leap_seconds(100), 0, 'before 1970' );

# at the start of the table:

# 1972-06-30
my $day = 720074;
is(
    DateTime::LeapSecond::leap_seconds($day), 0,
    'before leap-second transition'
);

is( DateTime::LeapSecond::extra_seconds($day) + 0, 1, 'leap day' );

# 1972-07-01
$day = 720075;
is(
    DateTime::LeapSecond::leap_seconds($day), 1,
    'day after leap-second day'
);

is( DateTime::LeapSecond::extra_seconds($day), 0, 'not a leap day' );

# 1972-07-02
$day = 720076;
is( DateTime::LeapSecond::leap_seconds($day), 1, 'after leap-second day' );

# at the end of the table:
# 1998-12-31
$day = 729754;
is( DateTime::LeapSecond::leap_seconds($day), 21, 'before leap-second day' );

# 1999-01-01
$day = 729755;
is( DateTime::LeapSecond::leap_seconds($day), 22, 'leap-second day' );

# 1999-01-02
$day = 729756;
is( DateTime::LeapSecond::leap_seconds($day), 22, 'after leap-second day' );

# some leap second dates:
# 1972  Jul. 1
# 1973  Jan. 1
# ...
# 1997  Jul. 1
# 1999  Jan. 1

done_testing();