Skip to content

Commit

Permalink
fix: ts_not_null now works for all timezones (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 authored Feb 19, 2024
1 parent 9ccd5db commit 9c549f5
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/dpp/discordevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,18 @@ time_t ts_not_null(const json* j, const char* keyname)
}
crossplatform_strptime(timedate.substr(0, 19).c_str(), "%Y-%m-%dT%T", &timestamp);
timestamp.tm_isdst = 0;
retval = mktime(&timestamp);
#ifndef _WIN32
retval = timegm(&timestamp);
#else
retval = _mkgmtime(&timestamp);
#endif
} else {
crossplatform_strptime(timedate.substr(0, 19).c_str(), "%Y-%m-%d %T", &timestamp);
retval = mktime(&timestamp);
#ifndef _WIN32
retval = timegm(&timestamp);
#else
retval = _mkgmtime(&timestamp);
#endif
}
}
return retval;
Expand All @@ -311,10 +319,18 @@ void set_ts_not_null(const json* j, const char* keyname, time_t &v)
}
crossplatform_strptime(timedate.substr(0, 19).c_str(), "%Y-%m-%dT%T", &timestamp);
timestamp.tm_isdst = 0;
retval = mktime(&timestamp);
#ifndef _WIN32
retval = timegm(&timestamp);
#else
retval = _mkgmtime(&timestamp);
#endif
} else {
crossplatform_strptime(timedate.substr(0, 19).c_str(), "%Y-%m-%d %T", &timestamp);
retval = mktime(&timestamp);
#ifndef _WIN32
retval = timegm(&timestamp);
#else
retval = _mkgmtime(&timestamp);
#endif
}
v = retval;
}
Expand Down

0 comments on commit 9c549f5

Please sign in to comment.