#!/usr/bin/perl

use strict;
use Win32::API::Prototype;

my($ftime_str_h, $ftime_str_l) = split(/[\.\$]/, shift(@ARGV));

my($ftime) = pack("ll", hex($ftime_str_l), hex($ftime_str_h));

my($time_l, $time_h) = unpack("ll", $ftime);
printf("0x%08x.0x%08x\n", $time_h, $time_l);

ApiLink('kernel32.dll', 'BOOL FileTimeToSystemTime(FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime)')
	|| die "Cannot locate FileTimeToSystemTime()";

my($stime) = pack("S8",0,0,0,0,0,0,0,0);
if (FileTimeToSystemTime($ftime, $stime)) {
	my(@time) = unpack("S8", $stime);
	printf("%04d-%02d-%02d %02d:%02d:%02d.%03d\n", $time[0], $time[1], $time[3], $time[4], $time[5], $time[6], $time[7]);
} else {
	printf("Error in FileTimeToSystemTime: %s\n", Win32::FormatMessage(Win32::GetLastError()));
}
