mirror of
https://github.com/openbsd/src.git
synced 2026-04-24 14:14:37 +00:00
rcs_set_tz: Use timegm() to parse broken-down UTC
We used to use mktime() (which expects local time not UTC) and manually adjust the time zone, but this did not take DST into account. From Tomas Rippl
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rcstime.c,v 1.6 2016/08/26 09:02:54 guenther Exp $ */
|
||||
/* $OpenBSD: rcstime.c,v 1.7 2025/09/15 19:37:35 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
|
||||
* All rights reserved.
|
||||
@@ -42,9 +42,9 @@ rcs_set_tz(char *tz, struct rcs_delta *rdp, struct tm *tb)
|
||||
time_t now;
|
||||
|
||||
if (!strcmp(tz, "LT")) {
|
||||
now = mktime(&rdp->rd_date);
|
||||
/* rd_date is stored in UTC, convert to local time. */
|
||||
now = timegm(&rdp->rd_date);
|
||||
ltb = localtime(&now);
|
||||
ltb->tm_hour += ((int)ltb->tm_gmtoff/3600);
|
||||
memcpy(tb, ltb, sizeof(*tb));
|
||||
} else {
|
||||
pos = 0;
|
||||
|
||||
Reference in New Issue
Block a user