Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Subtract Hours

by si_lence (Deacon)
on Jun 22, 2009 at 14:00 UTC ( #773636=note: print w/ replies, xml ) Need Help??


in reply to Subtract Hours

You have to know if the first time is earlier than the second one. You could either ask for the date as well or assume that the first time entered is the earlier one and then handle your second case differently.

Without the date you will always have to make some assumptions about your input - it could be more than 24 hours between the two times ...

cheers

si_lence


Comment on Re: Subtract Hours
Re^2: Subtract Hours
by ikegami (Pope) on Jun 22, 2009 at 14:33 UTC

    Without the date you will always have to make some assumptions about your input

    Such as the lack to timezone change. For example, there can be 3 4, or 5 hours between 11pm and 3am depending on the date.

      ikegami,
      I really don't think Anonymous Monk is trying to do anything complicated. See Monthly hours report. I think this is just a matter of finding out how many hours between the first time entered and the second assuming you are always moving the clock forward (and not working for > 24 hrs consecutively). DST could still bite you but if you are writing your own code to manage your hours and haven't bothered to use a module - I say you get what you ask for.

      Cheers - L~R

        I really don't think Anonymous Monk is trying to do anything complicated.

        I agree, which is why I didn't write the code to handle it. It was a "in case you didn't think about it and it matters" comment.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-12-26 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (164 votes), past polls