mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-10 12:04:36 -04:00
fix timezone shennanigans
This commit is contained in:
parent
f5f3873597
commit
1c36854e73
3 changed files with 10 additions and 5 deletions
loader
|
@ -269,9 +269,12 @@ if (NOT GEODE_BUILDING_DOCS)
|
|||
# Regex support
|
||||
CPMAddPackage("gh:google/re2#c9cba76")
|
||||
|
||||
# Cool date library
|
||||
CPMAddPackage("gh:HowardHinnant/date#1ead671")
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${md4c_SOURCE_DIR}/src)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} md4c re2 minizip)
|
||||
target_link_libraries(${PROJECT_NAME} md4c re2 minizip date)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} TulipHook geode-sdk mat-json-impl)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "Server.hpp"
|
||||
#include <Geode/utils/JsonValidation.hpp>
|
||||
#include <Geode/utils/ranges.hpp>
|
||||
#include <chrono>
|
||||
#include <date/date.h>
|
||||
#include <fmt/core.h>
|
||||
#include <loader/ModMetadataImpl.hpp>
|
||||
#include <fmt/chrono.h>
|
||||
|
@ -244,11 +246,10 @@ std::string ServerDateTime::toAgoString() const {
|
|||
|
||||
Result<ServerDateTime> ServerDateTime::parse(std::string const& str) {
|
||||
std::stringstream ss(str);
|
||||
std::tm value;
|
||||
if (ss >> std::get_time(&value, "%Y-%m-%dT%H:%M:%SZ")) {
|
||||
auto time = std::mktime(&value);
|
||||
date::sys_seconds seconds;
|
||||
if (ss >> date::parse("%Y-%m-%dT%H:%M:%S%Z", seconds)) {
|
||||
return Ok(ServerDateTime {
|
||||
.value = Clock::from_time_t(time),
|
||||
.value = seconds
|
||||
});
|
||||
}
|
||||
return Err("Invalid date time format '{}'", str);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <Geode/DefaultInclude.hpp>
|
||||
#include <Geode/utils/web.hpp>
|
||||
#include <Geode/loader/SettingEvent.hpp>
|
||||
#include <chrono>
|
||||
#include <matjson.hpp>
|
||||
#include <vector>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue