summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author宋文武 <[email protected]>2023-07-22 14:40:31 +0800
committerraveit65 <[email protected]>2023-07-31 12:38:15 +0200
commitdf02377275b1f676d7dfedf0b05c837d3ddc9883 (patch)
tree72f437f158f6952651e677be971e374636e8fce1
parent9b7c8d11cfb4e394b1be780246abf49d8117f19a (diff)
downloadlibmateweather-df02377275b1f676d7dfedf0b05c837d3ddc9883.tar.bz2
libmateweather-df02377275b1f676d7dfedf0b05c837d3ddc9883.tar.xz
Use TZDIR for ZONEINFO_DIR if the variable is set.
-rw-r--r--libmateweather/mateweather-timezone.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libmateweather/mateweather-timezone.c b/libmateweather/mateweather-timezone.c
index 2754728..182c4b0 100644
--- a/libmateweather/mateweather-timezone.c
+++ b/libmateweather/mateweather-timezone.c
@@ -61,7 +61,7 @@ static gboolean
parse_tzdata (const char *tzname, time_t start, time_t end,
int *offset, gboolean *has_dst, int *dst_offset)
{
- char *filename, *contents;
+ char *tzdir, *filename, *contents;
gsize length;
int timecnt, transitions_size, ttinfo_map_size;
int initial_transition = -1, second_transition = -1;
@@ -71,7 +71,10 @@ parse_tzdata (const char *tzname, time_t start, time_t end,
char initial_isdst, second_isdst;
int i;
- filename = g_build_filename (ZONEINFO_DIR, tzname, NULL);
+ tzdir = g_getenv ("TZDIR");
+ if (tzdir == NULL)
+ tzdir = ZONEINFO_DIR;
+ filename = g_build_filename (tzdir, tzname, NULL);
if (!g_file_get_contents (filename, &contents, &length, NULL)) {
g_free (filename);
return FALSE;
@@ -403,4 +406,3 @@ mateweather_timezone_get_dst_offset (MateWeatherTimezone *zone)
g_return_val_if_fail (zone->has_dst, 0);
return zone->dst_offset;
}
-