Commit 575e100c authored by jan.koester's avatar jan.koester
Browse files

time: Zeitzone aus /etc/localtime.yaml

FenrirOS-Stil: localtime() liest /etc/localtime.yaml (zone: oder feste
Regel), ohne sie noch den alten Namen /etc/time.yaml, dann /etc/localtime.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent fab31bbd
Loading
Loading
Loading
Loading
+9 −7
Changes for include/time.h: 9 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -50,13 +50,15 @@ struct itimerspec {
 *      containing '/' (e.g. "Europe/Berlin") names a real zone loaded
 *      per point 3 below rather than being parsed as a POSIX rule.
 *      A leading ':' is skipped; ":/path" or "/path" is a TZif file.
 *   2. /etc/time.yaml: either a fixed name/offset (+ optional POSIX
 *      DST rule fields), or a `zone:` key naming a real zone per
 *      point 3 (FenrirOS: written by syslite, `syslitectl timezone`).
 *      Without /etc/time.yaml: /etc/localtime (a TZif file or a
 *      symlink into zoneinfo, as other systems have it).
 *      With TZ unset, a changed /etc/time.yaml or /etc/localtime is
 *      loaded again by the next localtime()/mktime(), so running
 *   2. /etc/localtime.yaml (FenrirOS; its old name /etc/time.yaml is
 *      read when it is missing): either a fixed name/offset (+ optional
 *      POSIX DST rule fields), or a `zone:` key naming a real zone per
 *      point 3 (written by syslite: `syslitectl timezone set`).
 *      Without it: /etc/localtime (a TZif file or a symlink into
 *      zoneinfo, as other systems have it -- syslite keeps that symlink
 *      for ICU & co.).
 *      With TZ unset, a changed /etc/localtime.yaml or /etc/localtime
 *      is loaded again by the next localtime()/mktime(), so running
 *      programs follow a new time zone.
 *   3. A real IANA tzdata database: actual /usr/share/zoneinfo/<zone>
 *      TZif files (RFC 8536, v1/v2/v3) are parsed for their explicit
+9 −4
Changes for src/linux/time.cpp: 9 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -168,9 +168,14 @@ struct tz_guard {
    ~tz_guard() { __atomic_store_n(&g_tz_lock, 0, __ATOMIC_RELEASE); }
};

/* FenrirOS: /etc/localtime.yaml ("zone: Europe/Berlin", written by
 * syslite); /etc/time.yaml is its old name, still read when there is no
 * localtime.yaml. */
const char* time_yaml_path() {
    const char* p = secure_getenv("SYSTEMPP_TIME_YAML");
    return p ? p : "/etc/time.yaml";
    if (p) return p;
    if (access("/etc/localtime.yaml", F_OK) == 0) return "/etc/localtime.yaml";
    return "/etc/time.yaml";
}

const char* zoneinfo_dir() {
@@ -178,9 +183,9 @@ const char* zoneinfo_dir() {
    return p ? p : "/usr/share/zoneinfo";
}

/* The zone of programs that don't read /etc/time.yaml (ICU, Java, ...):
/* The zone of programs that don't read /etc/localtime.yaml (ICU, Java, ...):
 * a symlink into zoneinfo or a copied TZif file. Read here too when
 * there is no /etc/time.yaml. */
 * there is no /etc/localtime.yaml (or /etc/time.yaml). */
const char* localtime_path() {
    const char* p = secure_getenv("SYSTEMPP_LOCALTIME");
    return p ? p : "/etc/localtime";
@@ -560,7 +565,7 @@ void load_from_yaml() {
char* g_tz_env = nullptr;

/* What the configuration files looked like when g_tz was loaded from
 * them (TZ unset): a changed /etc/time.yaml or /etc/localtime (a new
 * them (TZ unset): a changed /etc/localtime.yaml or /etc/localtime (a new
 * time zone set while the program runs, e.g. the clock of the desktop)
 * is loaded again by the next localtime(). */
struct tz_stamp {