Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^3: DateCalc using Date::Manip

by SBECK (Hermit)
on Jan 11, 2017 at 16:50 UTC ( #1179408=note: print w/replies, xml ) Need Help??

in reply to Re^2: DateCalc using Date::Manip
in thread DateCalc using Date::Manip

I don't have a 'semi-exact' mode in Date::Manip... but what you're really saying is: convert an exact delta to a semi-approximate one.

This is of course different from coming up with an semi-approximate delta from two dates (which is what I was doing... I should have noticed that it wasn't exactly what the OP was doing, but I got ahead of myself after noticing I couldn't use 'semi' mode in the older DateCalc).

In any case, you can do the following:

use Date::Manip; my $dt1='2016080100:00:00'; my $dt2='2016123100:00:00'; my $exact= DateCalc($dt1,$dt2); my $semi = DateCalc($dt1,$dt2,'semi'); print "Exact : $exact\n"; print "Semi : $semi\n"; my $delta = ParseDateDelta($exact,'semi'); print "Exact->Semi: $delta\n"; print "\n"; use Date::Manip::Date; my $date1 = new Date::Manip::Date; my $date2 = $date1->new_date(); $date1->parse($dt1); $date2->parse($dt2); my $delt_x = $date1->calc($date2); my $delt_s = $date1->calc($date2,'semi'); my $val = $delt_x->value(); print "New Exact : $val\n"; $val = $delt_s->value(); print "New Semi : $val\n"; $delt_x->convert('semi'); $val = $delt_x->value(); print "New Ex->Se: $val\n";

which yields:

Exact : 0:0:0:0:3649:0:0 Semi : 0:0:21:5:0:0:0 Exact->Semi: 0:0:21:5:1:0:0 New Exact : 0:0:0:0:3649:0:0 New Semi : 0:0:21:5:0:0:0 New Ex->Se: 0:0:21:5:1:0:0

So you can see how to convert an exact delta to a semi-approximate one using either the old or new interfaces.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1179408]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-10-30 20:15 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (284 votes). Check out past polls.