Bug 12875 – [unittest] std.datetime fails: Not a valid tzdata file.
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-06-08T00:20:00Z
Last change time
2014-06-08T00:31:22Z
Assigned to
nobody
Creator
ibuclaw
Comments
Comment #0 by ibuclaw — 2014-06-08T00:20:51Z
Reduced to a test case:
---
import std.datetime;
import std.exception;
import std.stdio;
void main()
{
static void testPZSuccess(string tzName)
{
scope(failure) writefln("TZName which threw: %s", tzName);
TimeZone.getTimeZone(tzName);
}
auto tzNames = TimeZone.getInstalledTZNames();
foreach(tzName; tzNames)
assertNotThrown!DateTimeException(testPZSuccess(tzName));
}
---
Throws with the following error:
---
TZName which threw: America/Godthab
[email protected](17): assertNotThrown failed: TimeException was thrown: Not a valid tzdata file.
----------------
0x44bbcb _enforceValidTZFile
../../../../libphobos/src/std/datetime.d:29854
0x44bbcb immutable(std.datetime.PosixTimeZone) std.datetime.PosixTimeZone.getTimeZone(immutable(char)[], immutable(char)[])
../../../../libphobos/src/std/datetime.d:29322
0x44c982 immutable(std.datetime.TimeZone) std.datetime.TimeZone.getTimeZone(immutable(char)[])
../../../../libphobos/src/std/datetime.d:27635
[snip backtrace]
---
The line where the assert occurs:
---
_enforceValidTZFile(tzFileVersion == '\0' || tzFileVersion == '2');
---
And indeed when testing the file, it is in version '3' format - so I guess not supported.
---
$ file /usr/share/zoneinfo/America/Godthab
/usr/share/zoneinfo/America/Godthab: timezone data, version 3, 5 gmt time flags, 5 std time flags, no leap seconds, 117 transition times, 5 abbreviation chars
---
Here the distribution-specific version of the package tzdata:
---
tzdata 2014c-0ubuntu0.14.04
---
Comment #1 by ibuclaw — 2014-06-08T00:24:22Z
Even smaller test if you just want to skip to the failing tzdata file.
import std.datetime;
import std.exception;
import std.stdio;
void main()
{
scope(failure) writefln("TZName which threw: America/Godthab");
TimeZone.getTimeZone("America/Godthab");
}
Comment #2 by ibuclaw — 2014-06-08T00:26:04Z
Would also affect the following tzdata files:
Israel
Antarctica/Palmer
Asia/Gaza
Asia/Hebron
Chile/Continental
Chile/EasterIsland
Israel
Pacific/Fiji