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

Re^2: Use 'strftime' to calculate a date/time in the Past.

by mmartin (Monk)
on Sep 17, 2012 at 18:25 UTC ( #994070=note: print w/ replies, xml ) Need Help??


in reply to Re: Use 'strftime' to calculate a date/time in the Past.
in thread Use 'strftime' to calculate a date/time in the Past.

Hey daxim, thanks for the reply.

I tried your command but it seems I don't have the Perl Module "DateTime.pm" installed on my machine.
And this command which is a part of a script I'm writing will be ran on a number of different servers,
alot of which are AIX and SLES servers which I would rather not have to install this module on every
server...

Is it not possible to do it with the current way I have the command? Because that original command worked
on all the servers I tested it on.


I was thinking that to use my original command, would I have to convert the "amount of time into the past" into
all seconds?

i.e. If I want 2 days, 12 hours, 57 min, and 36 seconds into the past would I just convert each of those into
seconds then subtract them by "time", like in the "gmtime(...)" part of the command?


Thanks Again,
Matt


Comment on Re^2: Use 'strftime' to calculate a date/time in the Past.
Re^3: Use 'strftime' to calculate a date/time in the Past.
by daxim (Chaplain) on Sep 18, 2012 at 07:32 UTC
    I would rather not have to install this module
    Just do it. You're not really using Perl if you refuse to take advantage of modules. Dependencies are a good thing. You're likely afraid of change and overestimating the effort of installing, but with the right knowledge and tools it's easy. I don't want to go off-topic in this thread, so open a new question if you want further advice.
    Is it not possible to do it with the current way I have the command?
    No, there's only one Perl module distro that accurately calculates date and time, and that's the one I named. POSIX and Time::Piece offer only crude calculation and place the burden on the implementing programmer to get the details right, which is wrong because it always results in inaccuracy.
    would I have to convert the "amount of time into the past" into all seconds … then subtract them
    Sounds like a plan that can't go wrong… except you neglect to account for leap seconds. The magic number 86400 you used earlier is likewise flawed due to daylight saving time changing the length of a day.
        No, there's only one Perl module distro that accurately calculates date and time, and that's the one I named.

      I'm going to have to disagree with you there. Date::Manip will also calculate date and time accurately.

      I agree with your other points.
      Hey Daxim, thanks again for the reply...

      Yea I agree, it was just that I didn't want to go and install this Module on 40-50 different servers
      if I didn't have to. Ya know...?

      But actually, now that I'm thinking about it, I believe I do have that Perl Module... I think I just forgot
      to include the "use DateTime..." directive within the Perl command I was trying with your exmaple...


      Anyways, thanks again for all your help!


      Thanks Again,
      Matt


Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-08-23 06:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls