mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-25 12:00:31 +00:00
Implement proper time zone support
Cosmopolitan now supports 104 time zones. They're embedded inside any binary that links the localtime() function. Doing so adds about 100kb to the binary size. This change also gets time zones working properly on Windows for the first time. It's not needed to have /etc/localtime exist on Windows, since we can get this information from WIN32. We're also now updated to the latest version of Paul Eggert's TZ library.
This commit is contained in:
parent
d5ebb1fa5b
commit
b0df6c1fce
627 changed files with 3052 additions and 2077 deletions
8
libc/nt/enum/timezoneid.h
Normal file
8
libc/nt/enum/timezoneid.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_
|
||||
|
||||
#define kNtTimeZoneIdUnknown 0
|
||||
#define kNtTimeZoneIdStandard 1
|
||||
#define kNtTimeZoneIdDaylight 2
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_ */
|
20
libc/nt/kernel32/GetDynamicTimeZoneInformation.S
Normal file
20
libc/nt/kernel32/GetDynamicTimeZoneInformation.S
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetDynamicTimeZoneInformation,GetDynamicTimeZoneInformation
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetDynamicTimeZoneInformation:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov %rdi,%rcx
|
||||
sub $32,%rsp
|
||||
call *__imp_GetDynamicTimeZoneInformation(%rip)
|
||||
leave
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
#endif
|
||||
ret
|
||||
.endfn GetDynamicTimeZoneInformation,globl
|
||||
.previous
|
20
libc/nt/kernel32/GetTimeZoneInformation.S
Normal file
20
libc/nt/kernel32/GetTimeZoneInformation.S
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetTimeZoneInformation,GetTimeZoneInformation
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetTimeZoneInformation:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov %rdi,%rcx
|
||||
sub $32,%rsp
|
||||
call *__imp_GetTimeZoneInformation(%rip)
|
||||
leave
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
#endif
|
||||
ret
|
||||
.endfn GetTimeZoneInformation,globl
|
||||
.previous
|
|
@ -168,6 +168,8 @@ imp 'GetSystemTimePreciseAsFileTime' GetSystemTimePreciseAsFileTime kernel3
|
|||
imp 'GetSystemTimes' GetSystemTimes kernel32 3
|
||||
imp 'GetTempPath' GetTempPathW kernel32 2
|
||||
imp 'GetTempPathA' GetTempPathA kernel32 2
|
||||
imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1
|
||||
imp 'GetTimeZoneInformation' GetTimeZoneInformation kernel32 1
|
||||
imp 'GetThreadContext' GetThreadContext kernel32 2
|
||||
imp 'GetThreadDescription' GetThreadDescription kernel32 2
|
||||
imp 'GetThreadIOPendingFlag' GetThreadIOPendingFlag kernel32 2
|
||||
|
|
17
libc/nt/struct/dynamictimezoneinformation.h
Normal file
17
libc/nt/struct/dynamictimezoneinformation.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_
|
||||
#include "libc/nt/struct/systemtime.h"
|
||||
|
||||
struct NtDynamicTimeZoneInformation {
|
||||
int32_t Bias;
|
||||
char16_t StandardName[32];
|
||||
struct NtSystemTime StandardDate;
|
||||
int32_t StandardBias;
|
||||
char16_t DaylightName[32];
|
||||
struct NtSystemTime DaylightDate;
|
||||
int32_t DaylightBias;
|
||||
char16_t TimeZoneKeyName[128];
|
||||
bool32 DynamicDaylightTimeDisabled;
|
||||
};
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_ */
|
15
libc/nt/struct/timezoneinformation.h
Normal file
15
libc/nt/struct/timezoneinformation.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_
|
||||
#include "libc/nt/struct/systemtime.h"
|
||||
|
||||
struct NtTimeZoneInformation {
|
||||
int Bias; /* in minutes e.g. +480 for -8:00 */
|
||||
char16_t StandardName[32]; /* e.g. "Pacific Standard Time" */
|
||||
struct NtSystemTime StandardDate;
|
||||
int StandardBias;
|
||||
char16_t DaylightName[32]; /* e.g. "Pacific Daylight Time" */
|
||||
struct NtSystemTime DaylightDate;
|
||||
int DaylightBias; /* e.g. -60 */
|
||||
};
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_ */
|
37
libc/nt/time.h
Normal file
37
libc/nt/time.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_TIME_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_TIME_H_
|
||||
#include "libc/nt/struct/dynamictimezoneinformation.h"
|
||||
#include "libc/nt/struct/timezoneinformation.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* ░░░░
|
||||
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
|
||||
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
|
||||
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
|
||||
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
|
||||
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
|
||||
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
|
||||
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
|
||||
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
|
||||
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
|
||||
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
|
||||
│ cosmopolitan § new technology » time ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
uint32_t GetTimeZoneInformation(
|
||||
struct NtTimeZoneInformation *out_lpTimeZoneInformation);
|
||||
uint32_t GetDynamicTimeZoneInformation(
|
||||
struct NtDynamicTimeZoneInformation *out_lpTimeZoneInformation);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_TIME_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue