File: 502_format.t

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

use Test::More qw/no_plan/;

use DateTime;
use DateTime::Format::Epoch::JD;
use DateTime::Format::Epoch::MJD;
use DateTime::Format::Epoch::NTP;
use DateTime::Format::Epoch::TJD;
use DateTime::Format::Epoch::RJD;
use DateTime::Format::Epoch::Lilian;
use DateTime::Format::Epoch::RataDie;

my $dt = DateTime->new( year => 2004, month => 8, day => 28 );

my %dates = (
    JD  =>  2453245.5,
    MJD =>    53245,
    NTP =>    3302640000,
    TJD =>    13245,
    RJD =>    53245.5,
    Lilian => 154086,
    RataDie => 731821 );

while (my ($timescale, $value) = each %dates) {
    #no strict 'refs';
    is( ("DateTime::Format::Epoch::$timescale")->format_datetime($dt),
        $value, $timescale );
    is( ("DateTime::Format::Epoch::$timescale")->new->format_datetime($dt),
        $value, $timescale );

    is( ("DateTime::Format::Epoch::$timescale")->parse_datetime($value)
           ->datetime,
        $dt->datetime, "parse $timescale" );
}