/* * Identify a suitable default timezone setting based on the environment, * and make it active. * * We first look to the TZ environment variable. If not found or not * recognized by our own code, we see if we can identify the timezone * from the behavior of the system timezone library. When all else fails, * fall back to GMT. */ static const char * select_default_timezone(void) { const char *def_tz; def_tz = getenv("TZ"); if (set_global_timezone(def_tz)) return def_tz; def_tz = identify_system_timezone(); if (set_global_timezone(def_tz)) return def_tz; if (set_global_timezone("GMT")) return "GMT"; ereport(FATAL, (errmsg("could not select a suitable default timezone"), errdetail("It appears that your GMT time zone uses leap seconds. PostgreSQL does not support leap seconds."))); return NULL; /* keep compiler quiet */ }
/* * Identify a suitable default timezone setting based on the environment. * * We first look to the TZ environment variable. If not found or not * recognized by our own code, we see if we can identify the timezone * from the behavior of the system timezone library. When all else fails, * fall back to GMT. */ static pg_tz * select_default_timezone(void) { pg_tz *def_tz; def_tz = get_pg_tz_for_zone(getenv("TZ")); if (def_tz) return def_tz; def_tz = get_pg_tz_for_zone(identify_system_timezone()); if (def_tz) return def_tz; def_tz = get_pg_tz_for_zone("GMT"); if (def_tz) return def_tz; ereport(FATAL, (errmsg("could not select a suitable default time zone"), errdetail("It appears that your GMT time zone uses leap seconds. PostgreSQL does not support leap seconds."))); return NULL; /* keep compiler quiet */ }
/* * Identify a suitable default timezone setting based on the environment. * * The installation share_path must be passed in, as that is the default * location for the timezone database directory. * * We first look to the TZ environment variable. If not found or not * recognized by our own code, we see if we can identify the timezone * from the behavior of the system timezone library. When all else fails, * return NULL, indicating that we should default to GMT. */ const char * select_default_timezone(const char *share_path) { const char *tzname; /* Initialize timezone directory path, if needed */ #ifndef SYSTEMTZDIR snprintf(tzdirpath, sizeof(tzdirpath), "%s/timezone", share_path); #endif /* Check TZ environment variable */ tzname = getenv("TZ"); if (validate_zone(tzname)) return tzname; /* Nope, so try to identify the system timezone */ tzname = identify_system_timezone(); if (validate_zone(tzname)) return tzname; return NULL; }