Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Display of DateTime::Duration object in human readable string

by parv (Vicar)
on Oct 13, 2021 at 07:07 UTC ( #11137465=note: print w/replies, xml ) Need Help??


in reply to iterating over time with DateTime to obtain values with Astro::Coords

Get the duration in units of months, days, minutes, seconds from DateTime::Duration object; then convert (to other units or to a string) as you please. See the pod of the module for caveats.

(update) As you are calling subtract_datetime_absolute, you only need to get second (and nanosecond if you care) from the *::Duration object.

I personally did not care for any of the caveats about a day not being strictly 24 hour, etc. when I wanted to estimate finish time of transfer of ~40 TB of data. So, I did ...

# Conversion to day unit. my ( $day, $min, $sec ) = map { $duration->in_units( $_ ) } qw[ days m +inutes seconds ]; $day_duration = $day + ( $min/60 + $sec/3600 ) /24;

Replies are listed 'Best First'.
Re^2: Display of DateTime::Duration object in human readable string
by Aldebaran (Curate) on Oct 15, 2021 at 03:00 UTC
    (update) As you are calling subtract_datetime_absolute, you only need to get second (and nanosecond if you care) from the *::Duration object.

    My script is far from polished, but I wanted to get it out there before this thing goes down.

    Again one faces questions of validity. A typical value for the conjunction of the moon and jupiter is

    2021-10-15T09:26:57

    At Fourmilab's site , this happens 34-39 minutes later, between:

    2021-10-15 10:00:00

    , and:

    2021-10-15 10:05:00

    I tried to work it up in python, but it could not find the ephem module after I had snapd it in, so I don't know how to check it other than waiting for the values in Stellarium. (Thx karlgoethebier)

    Q1) Have we agreed that I'm gonna end up with seconds from DateTime::Duration*, and I might as well roll my own days, hours, minutes, seconds from that? I don't think DateTime can do it because of the vagaries of losing a second in the 70's, for example. (?)

    I will be traveling under this moon tomorrow, and I love to watch it from different perspectives as I cross mountian ranges. It rose and set a couple times relative to me the last time I drove this stretch, like a yoyo....

    Happy skywatching!

      I do not know enough, or care enough to find out currently, about the predicted motions of Moon & Venus. My interest in this thread is due to issues of and with DateTime*.

      Q1) Have we agreed that I'm gonna end up with seconds from DateTime::Duration*, and I might as well roll my own days, hours, minutes, seconds from that?

      Looks so: I suggested to convert human readable string based on *::Duration documentation; you seem to want to do so.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-12-09 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?