1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-26 08:20:27 +00:00

Allow :dst to be nil to set tm_isdst to be -1.

This commit is contained in:
Calvin Rose 2020-03-18 22:22:03 -05:00
parent 665f4bf248
commit 3aca5502dc

View File

@ -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);
}
}