Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
No such thing as a small change
 
PerlMonks  

Re: Redundant function calls in constructor?

by tinita (Parson)
on Apr 02, 2012 at 10:30 UTC ( #962994=note: print w/ replies, xml ) Need Help??


in reply to Redundant function calls in constructor?

I could assign the values with 1 call.
You even should. Theoretically, the first call could happen at the end of a day, month or year. Let's say 2012-01-31 23:59:59. and the next one one second later, 2012-02-01 00:00:00. in which case you'll end up with wrong data (DAY=31, MONTH=02, YEAR=2012). oops


Comment on Re: Redundant function calls in constructor?
Re^2: Redundant function calls in constructor?
by nemesdani (Friar) on Apr 02, 2012 at 12:23 UTC
    Indeed. The application is not time-crtical, but why insert a bug when you can avoid it. Thanks!

    I'm too lazy to be proud of being impatient.
      The application is not time-crtical, but why insert a bug when you can avoid it.   [emphasis added]

      <rant>

      The tone of this sentence implies that avoidance of this particular bug is essentially cosmetic and more or less optional.

      It's not just theoretically possible; it will eventually happen that successive calls to  localtime occur on successive days. This will produce impossible dates (e.g., 31 April) or dates that are 'off' by a month or as much as a year (e.g., 31 Dec 2012 vice 31 Dec 2011).

      But if the application can tolerate dates that are impossible or wildly inaccurate, why bother with dates at all?

      </rant>

        The rant is valid - thank you for your thoughts. However
        This program is started manually, generates code templates. In this special case it is highly unlikely that localtime calls will happen at midnight and/or New Year's Eve.
        The dates are only used in commented headers, wasn't my choice :) HOwever it's possible, that sometime somebody will have and idea to read the headers and produce some statistics, so one should take care of it.
        Thank you again. Much can be learned from the rants of the experienced :).

        I'm too lazy to be proud of being impatient.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-04-17 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (441 votes), past polls