Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-09-11
13:58 • Ticket [aa082a279c] clock format "time zone not found" with valid zone... artifact: e5fc73e6ab user: oehhar
2026-09-10
22:04 • Closed ticket [aa082a279c]. artifact: f468b2e81f user: sebres
22:01
merge 8.6: fixes 2nd part of [aa082a279c5d3a39]: case covered in clock-70.6, in POSIX Jn rule, leap ... check-in: e81697229f user: sebres tags: core-9-0-branch
21:38
merge bug-aa082a279c-8.6: fixes [aa082a279c5d3a39]: Jn day-of-year TZ rules reported "time zone not ... check-in: b3904d9763 user: sebres tags: core-8-6-branch
2026-09-08
09:13 • Ticket [aa082a279c] clock format "time zone not found" with valid zone... artifact: 52b44c469f user: oehhar
06:12 • Ticket [aa082a279c]: 3 changes artifact: d4672b8283 user: kenneth.kienle
00:31
fixes [aa082a279c5d3a39]: Jn day-of-year TZ rules reported "time zone not found" - pass the date dic... closed check-in: e41572bc33 user: kenneth.kienle tags: bug-aa082a279c-8.6
2026-09-07
23:09 • Ticket [aa082a279c] clock format "time zone not found" with valid zone... artifact: 23fdfadf23 user: kenneth.kienle
2026-09-04
12:00 • Ticket [aa082a279c]: 4 changes artifact: 30f70a55b9 user: oehhar
2026-09-03
20:02 • Add attachment clock-posix-tz-jday-rule.patch to ticket [aa082a279c5d3a... artifact: ebdc7ae25b user: kenneth.kienle
20:01 • Ticket [aa082a279c] clock format "time zone not found" with valid zone... artifact: 22e783dca7 user: kenneth.kienle
2016-06-03
17:13 • Ticket [aa082a279c]: 3 changes artifact: 53cc6f487a user: karl
2016-05-31
15:40 • Ticket [aa082a279c]: 3 changes artifact: 71e7771330 user: dgp
2016-05-27
18:04 • New ticket [aa082a279c]. artifact: 1c0ae34bfb user: karl

clock format "time zone not found" with valid zoneinfo file

Closed / Fixedaa082a279c5d3a39d400fd9e8137ba0544422091Created 11 years agoUpdated 83 days ago
Descriptionplain2016-05-27 18:04:55
The latest FreeBSD zoneinfo file for Asia/Tehran can be used to produce times referencing the IRDT timezone but when trying to use it in Tcl, it's an error.

The problematic file can be downloaded from http://karl.flightaware.com/playpen/zoneinfo/Asia/Tehran
dgp Ticket [aa082a279c]: 3 changes [History diff]2016-05-31 15:40:02
karlplain2016-06-03 17:13:58
I think the main problem is it should pass $date and not $y to IsGregorianLeapYear.  This diff seems to fix the problem, but it sets Gregorian to 1 and thus may malfunction for dates before September of 1752:

--- /usr/local/lib/tcl8.6/clock.tcl	2016-03-01 13:51:46.077512000 +0000
+++ clock.tcl	2016-06-03 14:51:42.050504100 +0000
@@ -3881,14 +3881,14 @@
 
     # Determine the start or end day of DST
 
-    set date [dict create era CE year $y]
+    set date [dict create era CE year $y gregorian 1]
     set doy [dict get $z ${bound}DayOfYear]
     if { $doy ne {} } {
 
 	# Time was specified as a day of the year
 
 	if { [dict get $z ${bound}J] ne {}
-	     && [IsGregorianLeapYear $y]
+	     && [IsGregorianLeapYear $date]
 	     && ( $doy > $FEB_28 ) } {
 	    incr doy
 	}
kenneth.kienlemarkdown2026-09-03 20:01:57

Still present in 8.6.18 for any POSIX TZ rule in the Jn or n day-of-year form, as a TZif footer or a -timezone string:

% clock format 1720000000 -timezone {EST5EDT,J60,J300}
time zone "EST5EDT,J60,J300" not found: missing value to go with key

DeterminePosixDSTTime passes the bare year to IsGregorianLeapYear, which expects a date dict and also reads its gregorian key. main fixed exactly this (the dict is created with gregorian 1 and passed) - the same two lines proposed above in 2016. Attached is the core-8-6-branch backport (4 lines). Verified with a synthetic version-2 TZif file whose footer is EST5EDT,J60,J300 and with IRST-3:30IRDT,J79/24,J263/24, glibc agreeing on every instant; 9.0.4 already passes. No zone in tzdata 2026c writes a J-form footer (0 of 598), which is why the tests do not see it; a user's TZ string does. With the backport this ticket can close. Related: [832d098fdfec8f004cf1c8e8836f7c335da12d54].

oehharwiki2026-09-04 12:00:36

Dear Kenneth, thanks for the update. clock was rewriten by magic Sergey in TCL 9 (due to a bounty by Karl, the original author of the ticket).

The TCL 9 result is:

% clock format 1720000000 -timezone {EST5EDT,J60,J300}
Wed Jul 03 05:46:40 EDT 2024

If you can confirm that this result is correct, the bug may be closed. Remark, that we don't fix any bugs any more in 8.6, except by backporting on a private initiative basis.

Thanks for all, Harald

kenneth.kienleplain2026-09-07 23:09:10
Harald,

Confirmed. "Wed Jul 03 05:46:40 EDT 2024" is correct.

I checked it three ways and they agree: Tcl 9.0.5 built from core-9-0-branch,
glibc (TZ=EST5EDT,J60,J300 date -d @1720000000), and 8.6.18 with the fix Karl
proposed in his 2016 comment on this ticket.

The reasoning, in case it is useful for the record: J60 is 1 March in every
year. Jn counts 1 January as day 1 and never counts 29 February, so 2024 being
a leap year does not move it, and 3 July is well inside DST either way.

So the ticket can be closed as far as I am concerned.

If a backport for 8.6 would be useful, I am happy to prepare one - you mentioned
that 8.6 takes fixes on a private-initiative basis, and the change is small. No
need if it is not wanted.

Thank you for the developer access, and for replying so quickly.

Kenneth
kenneth.kienleplain2026-09-08 06:12:45
Harald,

The backport is on branch bug-aa082a279c-8.6, off core-8-6-branch.

The fix is the one Karl proposed in his 2016 comment on this ticket. Pass $date to IsGregorianLeapYear instead of the bare year, and that is also what trunk does today. The credit is his; I only re-derived and tested it. It came up because I build and test Tcl 8.6 in a custom environment, so the suite runs against system tzdata rather than the bundled copy.

Karl also warned in that comment that setting gregorian to 1 "may malfunction for dates before September of 1752". That is still true, but it is not caused by these two lines. The same skew is already present on the Mm.n.d path in stock, and it comes from the calendar changeover argument passed further down.

One thing worth knowing before taking the branch, making Jn rules work exposes a second, older bug: J59 in a leap year was one day out. FEB_28 is 58, a 0-based day number, but Jn is 1-based, so J59 (28 February) was pushed onto 29 February. Before this backport every Jn rule failed with an error, so nobody could see it. I did not want to make a wrong answer reachable, so the branch corrects that too, in one line, with a test. Trunk has the same bug and nothing here changes trunk.

The branch carries six tests, clock-70.1 to 70.6. Reverting one mechanism at a time, measured:

    the leap-year guard alone       fails clock-70.6 and nothing else
    the date dict argument alone    fails all six

The second is expected rather than weak coverage. Passing the dict is what makes any Jn rule evaluate at all, so every test depends on it. None of the six needs system or bundled tzdata, and the expected values were computed with glibc.

Kenneth
oehharwiki2026-09-08 09:13:50

Great, thanks. Sergey (or others), may you double check the branch and merge if ok?

Thanks for all, Harald

sebreswiki2026-09-10 22:04:01

Merged. Thx!

As for J59 and case covered in clock-70.4, yes I am agree - in POSIX Jn rule, leap days are entirely skipped in the count, and because it is day 59 (J59) and exactly 02:00, the switch to DST happens at this very second, so the clock instantly "springs" forward by one hour in this TZ (to avoid DST hole), transforming 02:00 EST (-0500) into 03:00 EDT (-0400).

PoC in *nix shell:

$ TZ=EST5EDT          date -d @1961564400 '+%Y-%m-%d %H:%M:%S %z %Z'
2032-02-28 02:00:00 -0500 EST
$ TZ=EST5EDT,J59,J300 date -d @1961564400 '+%Y-%m-%d %H:%M:%S %z %Z'
2032-02-28 03:00:00 -0400 EDT
Integrated to 8.6 and 9.0 ([e81697229f3ebad8]).

oehharwiki2026-09-11 13:58:38

What about merging to main ?

Thanks for all, Harald

Log in (anonymous is fine) to add a comment.