WHOのCOVID-19のデータ形式が先月の途中から変更されてしまったので,対応に苦慮しているところ。とりあえず,perlで処理するための準備をする。
#!/usr/local/bin/perl
# usage: time.pl 1607100000
# usage: time.pl 2020/12/05 21:30:00
# conversion of UNIX time & local time
use strict;
use warnings;
use Time::Local 'timelocal';
if ( @ARGV == 1 ) {
my \$unix_time = \$ARGV[0];
my (\$sec, \$min, \$hour, \$mday, \$mon, \$year);
(\$sec, \$min, \$hour, \$mday, \$mon, \$year) = gmtime(\$unix_time);
\$year += 1900;
\$mon += 1;
printf("GMT:\t%04d/%02d/%02d %02d:%02d:%02d\n", \$year ,\$mon, \$mday, \$hour, \$min, \$sec);
(\$sec, \$min, \$hour, \$mday, \$mon, \$year) = gmtime(\$unix_time);
\$year += 1900;
\$mon += 1;
\$hour +=1;
printf("CET:\t%04d/%02d/%02d %02d:%02d:%02d\n", \$year ,\$mon, \$mday, \$hour, \$min, \$sec);
(\$sec, \$min, \$hour, \$mday, \$mon, \$year) = localtime(\$unix_time);
\$year += 1900;
\$mon += 1;
printf("LOCAL:\t%04d/%02d/%02d %02d:%02d:%02d\n", \$year ,\$mon, \$mday, \$hour, \$min, \$sec);
} elsif (@ARGV == 2) {
my (\$year, \$month, \$day) = split '/', \$ARGV[0];
my (\$hour, \$min , \$sec) = split ':', \$ARGV[1];
my \$epochtime = timelocal(\$sec, \$min, \$hour, \$day, \$month-1, \$year-1900);
print \$epochtime."\n";
}
0 件のコメント:
コメントを投稿