From 409c9888dda6f59a02c24fa6ebb93cf9a75bd921 Mon Sep 17 00:00:00 2001 From: sfromis <47082390+sfromis@users.noreply.github.com> Date: Sun, 9 Oct 2022 16:09:29 +0200 Subject: [PATCH 1/2] Epoch in Berry map for time Uses mktime to calculate the epoch value from the broken-down time structure, could potentially be tuned if deemed too inefficient in case of the caller already having the epoch value nearby. --- tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino index a90a25916..31206442d 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino @@ -265,6 +265,7 @@ extern "C" { be_map_insert_int(vm, "min", t->tm_min); be_map_insert_int(vm, "sec", t->tm_sec); be_map_insert_int(vm, "weekday", t->tm_wday); + be_map_insert_int(vm, "epoch", mktime(t)); if (unparsed) be_map_insert_str(vm, "unparsed", unparsed); be_pop(vm, 1); } From 4a3a52cd3eb4a1ac805d00897af635cf8accf7a9 Mon Sep 17 00:00:00 2001 From: sfromis <47082390+sfromis@users.noreply.github.com> Date: Sun, 9 Oct 2022 16:12:16 +0200 Subject: [PATCH 2/2] Epoch in Berry map for time Inserts input epoch value directly into the output map, for consistently having epoch in this data structure --- lib/libesp32/berry/src/be_timelib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libesp32/berry/src/be_timelib.c b/lib/libesp32/berry/src/be_timelib.c index 7b779aa36..a7938e4b7 100644 --- a/lib/libesp32/berry/src/be_timelib.c +++ b/lib/libesp32/berry/src/be_timelib.c @@ -37,6 +37,7 @@ static int m_dump(bvm *vm) time_insert(vm, "min", t->tm_min); time_insert(vm, "sec", t->tm_sec); time_insert(vm, "weekday", t->tm_wday); + time_insert(vm, "epoch", ts); be_pop(vm, 1); be_return(vm); }