[*] I'm going to be autistic and say "everybody" is (read: industry midwits are) wrong about dates
(amend comments)
This commit is contained in:
parent
ea241d86f3
commit
522def0a85
@ -11,42 +11,88 @@ namespace Aurora::Time
|
||||
{
|
||||
struct tm
|
||||
{
|
||||
int tm_sec {};
|
||||
int tm_min {};
|
||||
int tm_hour {};
|
||||
int tm_mday {1};
|
||||
int tm_mon {};
|
||||
int tm_year {70};
|
||||
int tm_wday {};
|
||||
int tm_yday {};
|
||||
int tm_isdst {-1};
|
||||
int year {}; // The absolute gregorian-calendar year
|
||||
int mon {}; // Months since January
|
||||
|
||||
int mday {}; // Days since last month
|
||||
AuOptional<int> wday {}; // Days since Monday [usually ignored]
|
||||
AuOptional<int> yday {}; // Days since January [usually ignored]
|
||||
|
||||
int hour {}; // Hours since yesterday
|
||||
int min {}; // Minutes since the hour
|
||||
int sec {}; // Seconds since the minute
|
||||
AuOptionalEx<bool> isdst {};
|
||||
|
||||
template<typename Dest_t>
|
||||
void CopyTo(Dest_t &out) const
|
||||
{
|
||||
out.tm_sec = tm_sec;
|
||||
out.tm_min = tm_min;
|
||||
out.tm_hour = tm_hour;
|
||||
out.tm_mday = tm_mday;
|
||||
out.tm_mon = tm_mon;
|
||||
out.tm_year = tm_year;
|
||||
out.tm_wday = tm_wday;
|
||||
out.tm_yday = tm_yday;
|
||||
out.tm_isdst = tm_isdst;
|
||||
out.tm_sec = sec;
|
||||
out.tm_min = min;
|
||||
out.tm_hour = hour;
|
||||
out.tm_mday = mday + 1;
|
||||
out.tm_mon = mon;
|
||||
|
||||
#if 0
|
||||
if (year < 1900)
|
||||
{
|
||||
out.tm_year = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
out.tm_year = year - 1900;
|
||||
}
|
||||
|
||||
if (wday == 6)
|
||||
{
|
||||
out.tm_wday = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
out.tm_wday = wday.value() + 1;
|
||||
}
|
||||
|
||||
out.tm_yday = yday.value();
|
||||
|
||||
if (!isdst.HasValue())
|
||||
{
|
||||
out.tm_isdst = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
out.tm_isdst = isdst.value();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename In_t>
|
||||
void CopyFrom(const In_t &in)
|
||||
{
|
||||
tm_sec = in.tm_sec;
|
||||
tm_min = in.tm_min;
|
||||
tm_hour = in.tm_hour;
|
||||
tm_mday = in.tm_mday;
|
||||
tm_mon = in.tm_mon;
|
||||
tm_year = in.tm_year;
|
||||
tm_wday = in.tm_wday;
|
||||
tm_yday = in.tm_yday;
|
||||
tm_isdst = in.tm_isdst;
|
||||
sec = in.tm_sec;
|
||||
min = in.tm_min;
|
||||
hour = in.tm_hour;
|
||||
mday = in.tm_mday - 1;
|
||||
mon = in.tm_mon;
|
||||
year = in.tm_year + 1900;
|
||||
|
||||
if (in.tm_wday == 0)
|
||||
{
|
||||
wday = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
wday = in.tm_wday - 1;
|
||||
}
|
||||
|
||||
yday = in.tm_yday;
|
||||
isdst = in.tm_isdst; // (dont normalize -1. it's a quirk of most modern CRTs we can exploit to easily solve the [user-input + how do i guess DST] issue)
|
||||
// (stupid c programs shouldn't be exploiting this anyway. assume all std::tm, ::tm, and similar types calling into us follow boolean logic)
|
||||
}
|
||||
|
||||
// Note (*): We don't give a single solitary fuck about what ISO 8601 says nor the intentions of braindead boomers who thought there were 61 seconds to an hour...
|
||||
// Sunday is not a Weekday; it's apart of the Week-END. No English speaker will disagree with this once we get past the obvious gaslighting attempts from NGOs and indoctrination institutions.
|
||||
// In my estimation, it's every English speeker ever born after the Stuarts (17xxs+) versus a handful of CIA boys and the International Organization for Standardization
|
||||
// In my tradition of upholding da norf, we're sticking by the 19th century industrialized understanding of time.
|
||||
// tm_wday is the day offset since Monday, not days since last week.
|
||||
// tm_mday is the day offset since the beginning of the month, not the calendar number - that's to say we deviate from other impls by asserting these members are all offsets, not whatever some CIA fuckbuddies at ANSI said it is.
|
||||
};
|
||||
}
|
@ -169,7 +169,7 @@ namespace Aurora::Time
|
||||
|
||||
AUKN_SYM tm NormalizeCivilTimezone(const Time::tm &time, ETimezoneShift shift)
|
||||
{
|
||||
if ((time.tm_isdst == 0) && (shift == ETimezoneShift::eUTC))
|
||||
if ((time.isdst.ValueOr(-1) == 0) && (shift == ETimezoneShift::eUTC))
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user