[Tarantool-patches] [PATCH v5 2/8] lua: built-in module datetime

Safin Timur tsafin at tarantool.org
Wed Aug 18 16:38:20 MSK 2021



On 17.08.2021 22:16, Vladimir Davydov via Tarantool-patches wrote:
> On Tue, Aug 17, 2021 at 07:52:43PM +0300, Vladimir Davydov wrote:
>> On Mon, Aug 16, 2021 at 02:59:36AM +0300, Timur Safin via
> Tarantool-patches wrote:
>>> +/**
>>> + * Full datetime structure representing moments
>>> + * since Unix Epoch (1970-01-01).
>>> + * Time is kept normalized to UTC, time-zone offset
>>> + * is informative only.
>>> + */
>>> +struct datetime {
>>> +	/** seconds since epoch */
>>> +	double secs;
>>
>> Please add a comment explaining why you use 'double' instead of
>> an integer type.
> 
> Come to think of it, why don't you use two ints here? E.g. one for low
> 32 bits, another for high 32 bits, or one for years, another for seconds
> in the year.
> 

This IMHO is awkward, and would scream of using int64_t. Especially if 
we would need to proceed this bit arithmetics in Lua. May play with that 
idea on the subsequent patches, but do not see any performance reason to 
do at the moment.

Once again - apparently double is perfectly ok from performance point of 
view, and in our date range we want it to work with seconds it's not 
loosing any data. Looks like good enough.

Thanks,
Timur


More information about the Tarantool-patches mailing list