Merge pull request #5406 from Doxense/fix-windows-build-with-system-time

Fix windows build with system time
This commit is contained in:
Jingyu Zhou 2021-08-18 14:26:27 -07:00 committed by GitHub
commit 38f9cbd8b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View File

@ -1964,16 +1964,29 @@ void parse(StringRef& val, WaitState& w) {
void parse(StringRef& val, time_t& t) { void parse(StringRef& val, time_t& t) {
struct tm tm = { 0 }; struct tm tm = { 0 };
#ifdef _WIN32
std::istringstream s(val.toString());
s.imbue(std::locale(setlocale(LC_TIME, nullptr)));
s >> std::get_time(&tm, "%FT%T%z");
if (s.fail()) {
throw std::invalid_argument("failed to parse ISO 8601 datetime");
}
long timezone;
if (_get_timezone(&timezone) != 0) {
throw std::runtime_error("failed to convert ISO 8601 datetime");
}
timezone = -timezone;
#else
if (strptime(val.toString().c_str(), "%FT%T%z", &tm) == nullptr) { if (strptime(val.toString().c_str(), "%FT%T%z", &tm) == nullptr) {
throw std::invalid_argument("failed to parse ISO 8601 datetime"); throw std::invalid_argument("failed to parse ISO 8601 datetime");
} }
long timezone = tm.tm_gmtoff; long timezone = tm.tm_gmtoff;
t = timegm(&tm); t = timegm(&tm);
if (t == -1) { if (t == -1) {
throw std::runtime_error("failed to convert ISO 8601 datetime"); throw std::runtime_error("failed to convert ISO 8601 datetime");
} }
t -= timezone; t -= timezone;
#endif
} }
void parse(StringRef& val, NetworkAddress& a) { void parse(StringRef& val, NetworkAddress& a) {

View File

@ -19,6 +19,11 @@ extern "C" void stackSignalHandler(int sig) {
} }
} }
#ifdef _WIN32
#define SIGUSR1 10
#define SIGUSR2 12
#endif
void setupStackSignal() { void setupStackSignal() {
std::signal(SIGUSR1, &stackSignalHandler); std::signal(SIGUSR1, &stackSignalHandler);
} }

View File

@ -150,13 +150,13 @@
</Component> </Component>
<Component Id='FDBCRegistryValue' Guid='{6ED940F3-75C8-4385-97D9-D7D0F211B17D}' Win64='yes'> <Component Id='FDBCRegistryValue' Guid='{6ED940F3-75C8-4385-97D9-D7D0F211B17D}' Win64='yes'>
<RegistryKey Root='HKLM' Key='SOFTWARE\$(var.Manufacturer)\KeyValue\Client' Action='createAndRemoveOnUninstall'> <RegistryKey Root='HKLM' Key='SOFTWARE\$(var.Manufacturer)\KeyValue\Client'>
<RegistryValue Name='Version' Type='string' Value='$(var.Version)' KeyPath='yes' /> <RegistryValue Name='Version' Type='string' Value='$(var.Version)' KeyPath='yes' />
</RegistryKey> </RegistryKey>
</Component> </Component>
<Component Id='FDBSRegistryValue' Guid='{361A9B4A-A06F-4BFB-AFEA-B5F733C8BFDF}' Win64='yes'> <Component Id='FDBSRegistryValue' Guid='{361A9B4A-A06F-4BFB-AFEA-B5F733C8BFDF}' Win64='yes'>
<RegistryKey Root='HKLM' Key='SOFTWARE\$(var.Manufacturer)\KeyValue\Server' Action='createAndRemoveOnUninstall'> <RegistryKey Root='HKLM' Key='SOFTWARE\$(var.Manufacturer)\KeyValue\Server'>
<RegistryValue Name='Version' Type='string' Value='$(var.Version)' KeyPath='yes' /> <RegistryValue Name='Version' Type='string' Value='$(var.Version)' KeyPath='yes' />
</RegistryKey> </RegistryKey>
</Component> </Component>