Skip to content

Commit

Permalink
Disabled DST by setting tm_isdst to -1 so that mktime() won't adjust …
Browse files Browse the repository at this point in the history
…for daylight saving time.

This is especially important for custom DST settings
  • Loading branch information
Troltsch committed Oct 11, 2024
1 parent 361391d commit 94cfe52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tree_schema_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ lysp_check_date(struct lysp_ctx *ctx, const char *date, size_t date_len, const c
}
memcpy(&tm_, &tm, sizeof tm);

/* DST may move the hour back resulting in a different day */
tm_.tm_hour = 1;
/* Disabling DST: Set tm_isdst to -1 so that mktime() won't adjust for daylight saving time. */
tm_.tm_isdst = -1;

mktime(&tm_); /* mktime modifies tm_ if it refers invalid date */
if (tm.tm_mday != tm_.tm_mday) { /* e.g 2018-02-29 -> 2018-03-01 */
Expand Down

0 comments on commit 94cfe52

Please sign in to comment.