From 3aca5502dcf158e9916aa8827dd2436c0bdf45ab Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Wed, 18 Mar 2020 22:22:03 -0500 Subject: [PATCH] Allow :dst to be nil to set tm_isdst to be -1. --- src/core/os.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/os.c b/src/core/os.c index 01b21fa2..4e14b6d5 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -674,14 +674,20 @@ static Janet os_date(int32_t argc, Janet *argv) { } static int entry_getdst(Janet env_entry) { + Janet v; if (janet_checktype(env_entry, JANET_TABLE)) { JanetTable *entry = janet_unwrap_table(env_entry); - return janet_truthy(janet_table_get(entry, janet_ckeywordv("dst"))); + v = janet_table_get(entry, janet_ckeywordv("dst")); } else if (janet_checktype(env_entry, JANET_STRUCT)) { const JanetKV *entry = janet_unwrap_struct(env_entry); - return janet_truthy(janet_struct_get(entry, janet_ckeywordv("dst"))); + v = janet_struct_get(entry, janet_ckeywordv("dst")); } else { - return 0; + v = janet_wrap_nil(); + } + if (janet_checktype(v, JANET_NIL)) { + return -1; + } else { + return janet_truthy(v); } }