Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test failure for updated Windows TZs #4584

Merged
merged 1 commit into from Jul 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 21 additions & 15 deletions std/datetime.d
Expand Up @@ -122,6 +122,12 @@ version(Windows)
import core.sys.windows.windows;
import core.sys.windows.winsock2;
import std.windows.registry;

// Uncomment and run unittests to print missing Windows TZ translations.
// Please subscribe to Microsoft Daylight Saving Time & Time Zone Blog
// (https://blogs.technet.microsoft.com/dst2007/) if you feel responsible
// for updating the translations.
// version = UpdateWindowsTZTranslations;
}
else version(Posix)
{
Expand Down Expand Up @@ -27270,21 +27276,13 @@ public:
{
import std.array : appender;
import std.algorithm : startsWith, sort;
import std.format : format;

auto windowsNames = WindowsTimeZone.getInstalledTZNames();
auto retval = appender!(string[])();

foreach(winName; windowsNames)
{
auto tzName = windowsTZNameToTZDatabaseName(winName);

version(unittest)
{
import std.string;
assert(tzName !is null, format("TZName which is missing: %s", winName));
}

if(tzName !is null && tzName.startsWith(subName))
retval.put(tzName);
}
Expand Down Expand Up @@ -30660,11 +30658,15 @@ string tzDatabaseNameToWindowsTZName(string tzName) @safe pure nothrow @nogc
}
}

version(Windows) unittest
version(Windows) version(UpdateWindowsTZTranslations) unittest
{
import std.format : format;
import std.stdio : stderr;

foreach(tzName; TimeZone.getInstalledTZNames())
assert(tzDatabaseNameToWindowsTZName(tzName) !is null, format("TZName which failed: %s", tzName));
{
if (tzDatabaseNameToWindowsTZName(tzName) is null)
stderr.writeln("Missing TZName to Windows translation: ", tzName);
}
}


Expand Down Expand Up @@ -30818,11 +30820,15 @@ string windowsTZNameToTZDatabaseName(string tzName) @safe pure nothrow @nogc
}
}

version(Windows) unittest
version(Windows) version(UpdateWindowsTZTranslations) unittest
{
import std.format : format;
foreach(tzName; WindowsTimeZone.getInstalledTZNames())
assert(windowsTZNameToTZDatabaseName(tzName) !is null, format("TZName which failed: %s", tzName));
import std.stdio : stderr;

foreach(winName; WindowsTimeZone.getInstalledTZNames())
{
if (windowsTZNameToTZDatabaseName(winName) is null)
stderr.writeln("Missing Windows to TZName translation: ", winName);
}
}


Expand Down