strptime clarification please
Eric Blake
eblake@redhat.com
Tue Jun 7 18:07:00 GMT 2011
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20110607/5b2aab2e/attachment.sig>
More information about the Newlib
mailing list