[Tarantool-patches] [PATCH 1/n] build, lua: built-in module datetime
Safin Timur
tsafin at tarantool.org
Wed Sep 15 00:53:41 MSK 2021
On 10.09.2021 20:50, Timur Safin wrote:
...
> + local ts = obj.timestamp
> + if ts ~= nil then
> + local sec_int, fraction
> + sec_int, fraction = math_modf(ts)
> + -- if there is one of nsec, usec, msec provided
> + -- then ignore fraction in timestamp
> + -- otherwise - use nsec, usec, or msec
> + if count_usec == 0 then
> + nsec = fraction * 1e9
> + end
> +
> + self.secs = sec_int
> + self.nsec = nsec
> +
> + return self
> + end
> +
Discovered the harder way (via hitting runtime exception) that I've not
renamed .secs access here to .epoch field access.
-------------------------------------------------------------
diff --git a/src/lua/datetime.lua b/src/lua/datetime.lua
index 4c6471bed..540a5a940 100644
--- a/src/lua/datetime.lua
+++ b/src/lua/datetime.lua
@@ -664,7 +664,7 @@ local function datetime_set(self, obj)
nsec = fraction * 1e9
end
- self.secs = sec_int
+ self.epoch = sec_int
self.nsec = nsec
return self
-------------------------------------------------------------
This is an indication that I've not tested date:set{timestamp = N}
access thouroughly, and more tests cases needed. Will update 1st commit
to branch tsafin/gh-5941-datetime-take2-wip soon with the corrected code
and more tests.
Timur
More information about the Tarantool-patches
mailing list