File: 202_format.t

package info (click to toggle)
libdatetime-format-epoch-perl 0.16-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 256 kB
  • sloc: perl: 386; makefile: 2
file content (29 lines) | stat: -r--r--r-- 1,067 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
use strict;
BEGIN { $^W = 1 }

use Test::More tests => 19;
use DateTime;
use DateTime::Format::Epoch::MacOS;

my $f = DateTime::Format::Epoch::MacOS->new();

isa_ok($f, 'DateTime::Format::Epoch::MacOS' );

my $dt = DateTime->new( year  => 1904, month => 1, day   => 1 );
is($f->format_datetime($dt), 0, 'Epoch = 0');
is(DateTime::Format::Epoch::MacOS->format_datetime($dt), 0, 'Epoch = 0');

$dt->set( hour => 1 );
is($f->format_datetime($dt), 3600, 'Epoch + 1hour');
is(DateTime::Format::Epoch::MacOS->format_datetime($dt), 3600, 'Epoch + 1hour');

$dt->set( day => 2, hour => 0 );
is($f->format_datetime($dt), 24*3600, 'Epoch + 1day');
is(DateTime::Format::Epoch::MacOS->format_datetime($dt), 24*3600, 'Epoch + 1day');

for my $tz (qw[ UTC floating America/Chicago Europe/Amsterdam
                Australia/Melbourne +1200 ]) {
    $dt = DateTime->new( year => 2003, month => 7, day => 1 );
    is($f->format_datetime($dt), 3139862400, "tz: $tz");
    is(DateTime::Format::Epoch::MacOS->format_datetime($dt), 3139862400, "tz: $tz");
}