help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Week number


From: Harald Hanche-Olsen
Subject: Re: Week number
Date: Wed, 15 Oct 2008 23:28:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix)

+ Xavier Maillard <xma@gnu.org>:

> I compared the results of your function and the result from a
> simple (format-time-string "%W") for the current date and I got
> week 42 for the former and week 41 for the latter. Can you
> explain this ?

There are different ways to count week numbers. You can bet that any
function having -iso- in its name will use ISO week numbering, which
corresponds to %V, not to %W. Here are the relevant bits from the
strftime man page on freebsd.

     %U    is replaced by the week number of the year (Sunday as the first day
           of the week) as a decimal number (00-53).

     %V    is replaced by the week number of the year (Monday as the first day
           of the week) as a decimal number (01-53).  If the week containing
           January 1 has four or more days in the new year, then it is week 1;
           otherwise it is the last week of the previous year, and the next
           week is week 1.

     %W    is replaced by the week number of the year (Monday as the first day
           of the week) as a decimal number (00-53).

(Note also that the proper way to write the week the ISO way is %GW%V,
not %YW%V as you might think.)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell


reply via email to

[Prev in Thread] Current Thread [Next in Thread]