1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:07:45 +00:00

LibC: Make tzset() set tzname to { "UTC", "UTC" }

Since tzset() itself pretends to succeed (it just sets timezone = 0 for
now), it seems unwise to leave tzname uninitialized. Since Serenity
already assumes UTC pretty much everywhere time is used, let's continue
that trend here. Quoting POSIX:

    https://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html

    The tzset() function shall use the value of the environment variable
    TZ to set time conversion information used by ctime(), localtime(),
    mktime(), and strftime(). If TZ is absent from the environment,
    implementation-defined default timezone information shall be used.

So we still don't care about TZ at all, but the program doesn't need to
know! :^)

This matches what musl libc ("UTC") and glibc ("GMT") do, see:

- https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c
- https://git.musl-libc.org/cgit/musl/tree/src/time/__tz.c
This commit is contained in:
Linus Groh 2021-01-18 18:09:30 +01:00 committed by Andreas Kling
parent 3c68f557a9
commit 0d58e75910

View file

@ -322,15 +322,19 @@ size_t strftime(char* destination, size_t max_size, const char* format, const st
return fits ? str.length() : 0;
}
long timezone = 0;
long timezone;
long altzone;
char* tzname[2];
int daylight;
constexpr const char* __utc = "UTC";
void tzset()
{
//FIXME: Here we prepend we are in UTC+0.
// FIXME: Here we pretend we are in UTC+0.
timezone = 0;
tzname[0] = const_cast<char*>(__utc);
tzname[1] = const_cast<char*>(__utc);
}
clock_t clock()