[Tarantool-patches] [PATCH v6 3/5] box, datetime: datetime comparison for indices

Dmitry E. Oboukhov d.oboukhov at corp.mail.ru
Thu Aug 19 17:47:39 MSK 2021


> > The code looks like as broken.
> 
> Not exactly :)
> 
> .new{} is constructor which is not expecting string at the moment. .parse()
> expect strings, or defaul __call handler for the module, which is
> dispatching between parsing, if passed string, and, direct calling
> constructor, if there are no arguments passed or they are object.

If .new and .__call are different, .new have to throw an exception
instead creating object with zero in its timestamp.

I think it would be nice to drop '__call' method and patch 'new' for
work with strings (mainstream) and tables (rare cases)

> diff --git a/src/lib/core/datetime.c b/src/lib/core/datetime.c
> index ebc05e29c..6e2a76da5 100644
> --- a/src/lib/core/datetime.c
> +++ b/src/lib/core/datetime.c
> @@ -93,20 +93,17 @@ datetime_to_string(const struct datetime *date, char

I can't apply the patch:

> patching file src/lib/core/datetime.c
> patch: **** malformed patch at line 4: *buf, int len)

I think it isn't between previous and current versions.

> ------------------------------------------------
> >  2. also the other databases try to avoid to use «Z» symbol in
> >     datetime-format, so I thing we should use «+00:00» instead «Z»
> 
> I don't care which way to output UTC, but here I need more examples (which
> vendor, how and when outputs timezone)...
> 
> Like - here is DATE WITH TIMEZONE column, and here is DATE WITHOUT TIMEZONE.
> And here TIMESTAMP WITHOUT TIMEZONE, and with UTC, and we see...

Example Postgresql

unera=> SET TIME ZONE 'ZULU';
SET
unera=> select '2021-08-19 17:36:14+0300'::TIMESTAMPTZ(0);
      timestamptz       
------------------------
 2021-08-19 14:36:14+00
(1 строка)

unera=> select '2021-08-19 17:36:14Z'::TIMESTAMPTZ(0);
      timestamptz       
------------------------
 2021-08-19 17:36:14+00
(1 строка)

Even if you set current timezone to 'Z' it prints zone as number.
So user can sort these strings as strings and sort will be correct.


> 
> > 
> > Yesterday we approved the following API:
> > T:add{year=XXX, month=YYY, ...}
> > T:sub{year=XXX, month=YYY, ...}
> > T:set{year=XXX, …, tz=’+03:00’}
> > T:strftime(‘%F %D %z’)
> > I want to see a test set for the API.
> 
> FWIW, :add{}/:sub{}/:strftime{} are there, but not :set() as unimplemented
> yet.

Ok, I think we need to have test for each method.
 
> > Datetime object must have methods to return integer and float timestamp:
> > T:epoch()
> > T:timestamp()
> 
> epoch() is integer, and timestamp() is double, correct?
ok

-- 

. ''`.            Dmitry E. Oboukhov <unera at debian.org>
: :’  :                           <unera at tarantool.org>
`. `~’                  work: <d.oboukhov at corp.mail.ru>
  `- 71ED ACFC 6801 0DD9 1AD1  9B86 8D1F 969A 08EE A756


More information about the Tarantool-patches mailing list