static void _test_next(int line, const char *input, const char *new_tz, usec_t after, usec_t expect) {
_cleanup_(calendar_spec_freep) CalendarSpec *c = NULL;
usec_t u;
- char *old_tz;
int r;
- old_tz = getenv("TZ");
- if (old_tz)
- old_tz = strdupa_safe(old_tz);
+ SAVE_TIMEZONE;
if (!isempty(new_tz) && !strchr(new_tz, ','))
new_tz = strjoina(":", new_tz);
assert_se(r >= 0 && u == expect);
else
assert_se(r == -ENOENT);
-
- assert_se(set_unset_env("TZ", old_tz, true) == 0);
- tzset();
}
#define test_next(input, new_tz, after, expect) _test_next(__LINE__, input,new_tz,after,expect)
static int print_status_info(const StatusInfo *i) {
_cleanup_(table_unrefp) Table *table = NULL;
- const char *old_tz = NULL, *tz, *tz_colon;
+ const char *tz_colon;
char a[LINE_MAX];
TableCell *cell;
struct tm tm;
(void) table_set_ellipsize_percent(table, cell, 100);
/* Save the old $TZ */
- tz = getenv("TZ");
- if (tz)
- old_tz = strdupa_safe(tz);
+ SAVE_TIMEZONE;
/* Set the new $TZ */
tz_colon = strjoina(":", isempty(i->timezone) ? "UTC" : i->timezone);
if (r < 0)
return table_log_add_error(r);
- /* Restore the $TZ */
- r = set_unset_env("TZ", old_tz, true);
- if (r < 0)
- log_warning_errno(r, "Failed to set TZ environment variable, ignoring: %m");
- else
- tzset();
-
r = table_add_many(table,
TABLE_FIELD, "System clock synchronized",
TABLE_BOOLEAN, i->ntp_synced,