This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strptime clarification please


On 06/06/2011 01:59 PM, Steven Abner wrote:
> Hi
>    I saw the recent work on strptime and started questioning things.
> Can someone please define for me "week 00" used for? I looks like
>  "set_week_number_mon4" defines as Jan 1st. I can't figure why it exists,
> considering max weeks are 53.

When using date +%U (or %W), the week number 1 represents the first
7-day week starting on Sunday (Monday).  Any days in the partial week
before that point are attributed to week 0 of the current year (and
conversely, days in December are always attributed to week 52 or 53).
Useful with +%Y.

When using date +%V, there is no week 0.  Week number 1 represents the
cutover point where 4 or more days of the week belong to the current
year; days before that are attributed to week 52 or 53 of the previous
year (and conversely, days in December might be attributed to week 1 of
the next year).  Useful with %+G.

For fun, you can try this, to see this in action:

$ for year in `seq 2000 2011` ; do
> date +%a-%U-%W-%V -d "Jan 1 $year"; done


> Sorry ahead of time if dumb question, but a lot of UNIX specs baffle me at times.

It took me several readings to implement strftime correctly; strptime is
just doing that in the reverse direction.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]