I expect the following test script to print a timestamp with

millisecond precision, but it doesn't. I'm running DateTime

version 1.03 and DateTime::Format::Epoch version 0.13 on 32-bit

Windows Vista with Strawberry Perl version 5.16.2.


What's wrong?


#!perl

use v5.16;
use strict;
use warnings;

use DateTime;
use DateTime::Format::Epoch;
use Math::BigInt;

my $epoch = DateTime->new(
    year       => 1601,
    month      => 1,
    day        => 1,
    hour       => 0,
    minute     => 0,
    second     => 0,
    nanosecond => 0,
);

my $parser = DateTime::Format::Epoch->new(
    epoch => $epoch,
    type  => 'bigint',
    unit  => 1e7, # Hundreds of nanonseconds, Microsoft FILETIME
);

my $timestamp = Math::BigInt->new('0x01_CD_F5_A9_75_38_2F_DF');

# This prints 130030072428507103, which is correct
say $timestamp;

my $dt = $parser->parse_datetime($timestamp);

# This prints 2013-01-18T18:27:22.000, not 2013-01-18T18:27:22.850
say $dt->format_cldr('yyyy-MM-ddTHH:mm:ss.SSS');

# This prints 130030072420000000, not 130030072428507103
say $parser->format_datetime($dt);

exit 0;

__END__
130030072428507103
2013-01-18T18:27:22.000
130030072420000000


Jim Monty

Reply via email to