Files
KirkOS/user/include/mlibc/tests/ansi/tz.c
T
kaguya 9a9b91c940 user: implement mlibc as the libc, finally.
It's finally done..

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
2026-05-02 03:31:49 -04:00

28 lines
652 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
extern int daylight;
extern long timezone;
extern char *tzname[2];
int main() {
tzset();
printf("%s %s %ld %d\n", tzname[0], tzname[1], timezone, daylight);
time_t sometime_in_summer_in_the_north = 1752019200;
struct tm *local = localtime(&sometime_in_summer_in_the_north);
// Print the current timezone offset from UTC in seconds, considering DST
if (local) {
long offset = local->tm_gmtoff;
int hours = offset / 3600;
int minutes = (offset % 3600) / 60;
printf("UTC offset: %0d:%02d\n", hours, abs(minutes));
} else {
printf("localtime returned NULL\n");
}
return 0;
}