http://www.perlmonks.org?node_id=773636


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

Replies are listed 'Best First'.
Re^2: Subtract Hours
by ikegami (Patriarch) 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.