I gave up after beating the hell out of it.
3648 presents a new problem too, it points out that the old machine thought it used daylight time, and the new one doesnt.
use Date::Manip;
acycle("2016080100:00:00",'2016123100:00:00'); # it knows im in
+a daylight zone and comensates
acycle("2016080100:00:00GMT",'2016123100:00:00GMT');
acycle("2016080100:00:00CDT",'2016123100:00:00CST');
acycle("2016080100:00:00CST",'2016123100:00:00CST'); # i cant explain
+ this one
acycle("2016-08-01T00:00:00CST",'2016-12-31T00:00:00CST'); # i cant e
+xplain this one
acycle("2016-08-01T00:00:00-0500",'2016-12-31T00:00:00-0500'); # but
+this is ok
exit;
sub acycle {
my $dt1=shift;
my $dt2=shift;
my $fe=DateCalc($dt1,$dt2,0);
my $fse=semi_exact($fe);
printf "dt1:%25s (%25s) \ndt2:%25s (%25s) \n -> %s \n
+"
,$dt1,UnixDate($dt1,'%Y-%m-%d-%H:%M:%S%Z')
,$dt2,UnixDate($dt2,'%Y-%m-%d-%H:%M:%S%Z')
,$fse;
#print 'dt1:'.$dt1.'('.&UnixDate($dt1,'%Y-%m-%d-%H:%M:%S%Z').')'
# .' dt2:'.$dt2.'('.&UnixDate($dt2,'%Y-%m-%d-%H:%M:%S%Z').')'
# .' ->'.$fse."\n";
} # acycle
sub semi_exact {
my $delve=shift;
my @parts=split(':',$delve);
my $h0=$parts[4]+$parts[3]*24+$parts[2]*7*24;
my $w=sprintf('%d',$h0/(7*24));
$h0=$h0-$w*7*24;
if ($w<0) {$h0=$h0*-1;}
my $d=sprintf('%d',$h0/24);
$h0=$h0-$d*24;
my $delvse="0:0:$w:$d:$h0:$parts[5]:$parts[6]";
return $delvse;
} # semi-exact
outputs
dt1: 2016080100:00:00 ( 2016-08-01-00:00:00CDT)
dt2: 2016123100:00:00 ( 2016-12-31-00:00:00CST)
-> 0:0:21:5:1:0:0
dt1: 2016080100:00:00GMT ( 2016-08-01-00:00:00GMT)
dt2: 2016123100:00:00GMT ( 2016-12-31-00:00:00GMT)
-> 0:0:21:5:0:0:0
dt1: 2016080100:00:00CDT ( 2016-08-01-00:00:00CDT)
dt2: 2016123100:00:00CST ( 2016-12-31-00:00:00CST)
-> 0:0:21:5:1:0:0
dt1: 2016080100:00:00CST ( 2016-08-01-00:00:00CST)
dt2: 2016123100:00:00CST ( 2016-12-31-00:00:00CST)
-> 0:0:21:5:14:0:0
dt1: 2016-08-01T00:00:00CST ( 2016-08-01-00:00:00CST)
dt2: 2016-12-31T00:00:00CST ( 2016-12-31-00:00:00CST)
-> 0:0:21:5:14:0:0
dt1: 2016-08-01T00:00:00-0500 ( 2016-08-01-00:00:00CDT)
dt2: 2016-12-31T00:00:00-0500 ( 2016-12-31-00:00:00EASST)
-> 0:0:21:5:0:0:0
I wish i could explain about the CST/CST oddity, it shows up when both ISO too
|