[Top][All Lists]

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

Interesting problem in date handling of week 1

From: Henrik Stoerner
Subject: Interesting problem in date handling of week 1
Date: Mon, 6 Jan 2003 14:14:24 +0100

Hello GNU date maintainer,

I came across an interesting "feature" in the "date" utility from sh-utils

I needed a way to get the year and week-number for a date a few days ago.
This produces some interesting results right now, when we are close to Jan

osiris:~ $ date
Mon Jan  6 14:05:20 CET 2003
osiris:~ $ date --date="today -5 days" +"%Y/w%V/"
osiris:~ $ date --date="today -6 days" +"%Y/w%V/"
osiris:~ $ date --date="today -1 week" +"%Y/w%V/"

Note that the year changes from 2003 to 2002 simply by going back a single
day. This is wrong in some sense - Dec 31st 2002 belongs to the first week
of 2003, not the first week of 2002. On the other hand, the year when going
back 6 days from Jan 6th 2003 *is* 2002, so I understand why it behaves the
way it does.

This occurs with the date-program from Mandrake Linux 9 on Intel:

osiris:~ $ date --version
date (sh-utils) 2.0.15
Written by David MacKenzie.

and with a version of GNU date on Solaris 8:

address@hidden:>gnudate --version
date (GNU sh-utils) 2.0
Written by David MacKenzie.


Henrik Størner <address@hidden>

reply via email to

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