Skip to content
Tcl Source Code View Ticket
Login

View Ticket

clock format - wrong ISO8601 week number

Closed / Fixed500389ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 23 years ago
Descriptionplain2002-01-07 13:30:29
The clock format command prints incorrect weeks
around the beginning of 2002.

In week 01/2002 it printed 53/2001 and now
in the week 02/2001 it prints week 01.

Example:


hesjhe@hesws6:~ $ /kopt/tcltk/bin/tclsh8.3 
% clock seconds
1010410133
% clock format 1010410133 -format %W
01
% clock format 1010410133
Mon Jan 07 15:28:53 EET 2002
% 

The bug seems to be platform and minor release
independent, I can reproduce it with:
-RedHat Linux 7.2, tcl patchlevel 8.3.1
-W2K, ActiveTCL, tcl patchlevel 8.3.4
-SGI Irix 5.3, tcl patchlevel 8.3.4
-HP-UX 10.20, tcl patchlevel 8.3.2
dkf Ticket [500389ffff]: 2 changes [History diff]2002-01-07 20:56:37
pspjuthplain2002-01-07 22:37:15
Logged In: YES 
user_id=98900

It seems the submitter is asking for ISO weeks, which %W does not give.
A glance in compat/strftime.c shows an undocumented %V that gives ISO
weeks. That implementation is slightly buggy though, and the same bug
can be found in strftime on SunOS 5.6.

strftime on Linux 2.4.7 and SunOS 5.8 are ok though.

Maybe %V should be fixed and officially supported?
kennykbplain2002-01-07 22:41:10
Logged In: YES 
user_id=99768

%V is indeed documented in 8.4.
nobodyplain2002-01-07 22:57:03
Logged In: NO 

Hi and thank you for an extremely quick solution to 
my problem! I cannot be amazed enough about how well the
open source development process works...

Anyway, I checked the %V option with the platforms
I have access to. It works in Linux, HPUX10.20 and
W2K but it fails in Irix 5.3. Since my application
runs on Linux my problem is solved, but I think in general
it would be a good idea to support it generally in
a portable way. Unfortunately, I cannot volunteer to do it...
kennykbplain2002-01-07 23:08:05
Logged In: YES 
user_id=99768

If I remember correctly, the 8.4 configuration is changed so that the
native strftime (which is indeed buggy on Irix 5.3) is never used, and
the one from the 'compat/' library is linked instead, but I'm leaving this
bug open until I can check it out.
pspjuthplain2002-01-07 23:13:52
Logged In: YES 
user_id=98900

Indeed it is documented.
This time looking at the latest files I see
that the %V implementation is still buggy
in compat/strftime.c. Maybe that should be a
separate bug report?

Bug Example:
2000-01-01 should give week 52, not 53.

Since at least Linux has a correct strftime I guess
it would be an easy fix for someone with those
sources at hand.
kennykbplain2002-01-12 07:59:22
Logged In: YES 
user_id=99768

On the CVS head of the tcllib project, there is now a 'modules/calendar' directory that includes Tcl functions 
for converting among several calendar representations -- including ISO fiscal year and week.  Please check 
it out!
kennykbplain2004-03-06 00:33:05
Logged In: YES 
user_id=99768

Duplicate of 500285
kennykb Open ticket [500389ffff]. [History diff]2004-03-06 00:33:35
kennykb Closed ticket [500389ffff]. [History diff]2004-03-06 00:34:22
kennykb Open ticket [500389ffff]. [History diff]2004-05-19 03:40:49
kennykb Closed ticket [500389ffff]. [History diff]2004-05-19 04:53:46
Log in (anonymous is fine) to add a comment.