David Garamond schreef:
> Is there a module/routine to do this? From .NET Framework SDK
> documentation: "Time values are measured in 100-nanosecond units called
> ticks, and a particular date is the number of ticks since 12:00
> midnight, January 1, 1 C.E. in the GregorianCalendar calendar. For
> example, a ticks value of 31241376000000000L represents the date,
> Friday, January 01, 0100 12:00:00 midnight."
One way to do it:
use DateTime::Format::Epoch;
my $dt = DateTime->new( year => 1, month => 1, day => 1 );
my $formatter = DateTime::Format::Epoch->new(
epoch => $dt,
unit => 'nanoseconds',
);
my $dt2 = DateTime->new( year => 100, month => 1, day => 1 );
print int($formatter->format_datetime( $dt2 )/100), "\n";
my $ticks = 31241376000000000;
print $formatter->parse_datetime( $ticks * 100)->datetime, "\n";
The DT::F::Epoch package contains a number of predefined formats. I can
add a .NET format very easily. Then it's as simple as:
use DateTime::Format::Epoch::DotNet;
my $formatter = DateTime::Format::Epoch::DotNet->new();
my $dt2 = DateTime->new( year => 100, month => 1, day => 1 );
print $formatter->format_datetime( $dt2 ), "\n";
Do you know if leap seconds are included in this count? (Or: can you
give an example of a ticks value in the year 2003, for example?)
Eugene