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


In reply to Re^9: DateCalc using Date::Manip by huck
in thread DateCalc using Date::Manip by tsdesai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.