in reply to calcweek

Not to muck about it, but where would the main differences/benefits be against something like
perl -MDate::Manip -e 'print UnixDate( "next Sunday", "%W"), "\n";'

?

Thanks,

Krambambuli
---
sometimes enjoying Mark Jason Dominus' Higher-Order Perl

Replies are listed 'Best First'.
Re^2: calcweek
by Skeeve (Parson) on Aug 20, 2008 at 16:12 UTC

    I'm not 100% sure but calendar weeks in Europe and US of A differ. ISO 8601 start with Monday while US weeks start on Sunday.

    Also the definition of the first week differ.

    • in US it's the week containing January 1st.
    • in ISO 8601 it's the week having at least 4 days

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re^2: calcweek
by sv87 (Acolyte) on Aug 20, 2008 at 16:05 UTC
    I didn't even know about the existence of Date::Manip, and your solution works as well. I'm a relative noob in Perl. But hey, according to the Perl spirit, TIMTOWTDI (there's more than one way to do it). :-) thanks for your reply. Now I know a way to do it that's a lot shorter. :-)