in reply to Re^2: Is there an easy way to get the start date of the current week?
in thread Is there an easy way to get the start date of the current week?

Care to point out which hours that would be? Unless there's a timezone that skips 12 hours or more on DST, I don't see there's a problem. Had ramjamman actually suggested to subtract 86400 in each iteration, there would be 6 hours/year where this would be a problem - the hour between midnight and 1 AM on the Monday - Saturday following the Sunday when DST is enabled. (Assuming DST skips an hour, and starts on a Sunday. And assuming the local timezone actually has DST - many parts of the world don't).
  • Comment on Re^3: Is there an easy way to get the start date of the current week?

Replies are listed 'Best First'.
Re^4: Is there an easy way to get the start date of the current week?
by ikegami (Patriarch) on Aug 21, 2010 at 22:55 UTC

    Had ramjamman actually suggested to subtract 86400 in each iteration

    I stand corrected. (Magic numbers == bad)

      (Magic numbers == bad)

      I'm amazed, given your programming experience, that 86,400 isn't as memorable to you as 1024 or 65536. It's certainly has been a number I recall without thinking about, for longer than I care to think about.

      43,200 isn't so familiar. But then, if you see a number that you don't recognise, then it's as well to question "why that number". Sure, I could have use 12*60*60, or a constant HALF_A_DAY_IN_SECONDS, but would anyone have then though about "why half a day"?

      Assumptions == bad. Code that make you question it == good.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.