mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 08:33:12 -05:00
gmtime, localtime, mktime, strftime and asctime took and returned the host std::tm. The guest's FreeBSD tm has tm_gmtoff and tm_zone after the nine calendar fields, so on Windows, where std::tm is 36 bytes, a title reading those fields read past the thread-local result, and gmtime_s left them unwritten. Windows gmtime_s also accepts only 1969-12-31 12:00 to 3001-01-19 21:59 UTC, where the guest libc converts any time. Convert through a GuestTm with the guest layout on both hosts. Compute the UTC fields from the day count, so every time whose year fits an int converts, and on Windows take the local offset and zone name from the CRT. gmtime reports the zone as UTC like the guest libc. localtime and mktime keep the CRT's range on Windows; recorded in TechnicalDebt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
21 lines
414 B
C++
21 lines
414 B
C++
#pragma once
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
struct GuestTm {
|
|
int tm_sec;
|
|
int tm_min;
|
|
int tm_hour;
|
|
int tm_mday;
|
|
int tm_mon;
|
|
int tm_year;
|
|
int tm_wday;
|
|
int tm_yday;
|
|
int tm_isdst;
|
|
std::int64_t tm_gmtoff;
|
|
const char* tm_zone;
|
|
};
|
|
static_assert(offsetof(GuestTm, tm_gmtoff) == 40);
|
|
static_assert(offsetof(GuestTm, tm_zone) == 48);
|
|
static_assert(sizeof(GuestTm) == 56);
|