Skip to content
Snippets Groups Projects
user avatar
Timur Safin authored
Introduce a new builtin Tarantool module `datetime.lua` for timestamp
and interval types support.

New third_party module - c-dt
-----------------------------

* Integrated chansen/c-dt parser as 3rd party module to the
  Tarantool cmake build process;
* We use tarantool/c-dt instead of original chansen/c-dt to
  have an easier cmake build integration, as we have added some
  changes, which provide cmake support, and allow to rename symbols
  if necessary (this symbol renaming is similar to that we see
  with xxhash or icu).

New built-in module `datetime`
------------------------------

* created a new Tarantool built-in module `datetime`, which uses
  `struct datetime` data structure for keeping timestamp values;
* Lua module uses a number of `dt_*` functions from `c-dt` library,
  but they were renamed to `tnt_dt_*` at the moment of exporting
  from executable - to avoid possible name clashes with external
  libraries.

* At the moment we libc `strftime` for formatting of datetime
  values according to flags passed, i.e. `date:format('%FT%T%z')`
  will return something like '1970-01-01T00:00:00+0000', but
  `date:format('%A %d, %B %Y')` will return 'Thursday 01, January 1970'

* if there is no format provided then we use default
  `tnt_datetime_to_string()` function, which converts datetime
  to their default ISO-8601 output format, i.e.
  `tostring(date)` will return string like "1970-01-01T00:00:00Z"

* There are a number of simplified interfaces
  - totable() for exporting table with attributes names as provided
    by `os.date('*t')`
  - set() method provides unified interface to set values using
    the set of attributes as defined above in totable()

Example,

```
local dt = datetime.new {
	nsec      = 123456789,

	sec       = 19,
	min       = 29,
	hour      = 18,

	day       = 20,
	month     = 8,
	year      = 2021,

	tzoffset  = 180
}

local t = dt:totable()
--[[
{
	sec = 19,
	min = 29,
	wday = 6,
	day = 20,
	nsec = 123456789,
	isdst = false,
	yday = 232,
	tzoffset = 180,
	month = 8,
	year = 2021,
	hour = 18
}
--]]

dt:format()   -- 2021-08-21T14:53:34.032Z
dt:format('%Y-%m-%dT%H:%M:%S')   -- 2021-08-21T14:53:34

dt:set {
	usec      = 123456,

	sec       = 19,
	min       = 29,
	hour      = 18,

	day       = 20,
	month     = 8,
	year      = 2021,

	tzoffset  = 180,

}
dt:set {
	timestamp = 1629476485.124,

	tzoffset  = 180,
}

```

Coverage is

File                 Hits Missed Coverage
-----------------------------------------
builtin/datetime.lua 299  23     92.86%
-----------------------------------------
Total                299  23     92.86%

Part of #5941

@TarantoolBot document
Title: Introduced a new `datetime` module for timestamp and interval support

Create `datetime` module for timestamp and interval types support.
It allows to create date and timestamp values using either object interface,
or via parsing of string values conforming to iso-8601 standard.
One may manipulate (modify, subtract or add) timestamp and interval values.

Please refer to https://hackmd.io/@Mons/S1Vfc_axK#Datetime-in-Tarantool
for a more detailed description of module API.
43e10ed3
History
How to update libcoro
=====================

cvs up

How to update libev
===================

Remove Tarantool patches (see csv diff -U8).
cvs up
Add patches back.

How to update luajit
====================

Run from project root dir:
git submodule update --reference v2.0.1-fixed -- third_party/luajit

How to update libobjc2
======================

How initial import was done:

svn co http://svn.gna.org/svn/gnustep/libs/libobjc2/trunk/ ./libobjc

find . -name '.svn' | xargs rm -rf
rm Makefile.clang
rm GNUMakefile

How to update it:

- delete GNUmakefile
- delete CMakeLists.txt
- merge our Makefile with the Makefile in
the source tarball
- preserve the zero-warnings patch 43771c84f7f5bf04e426dde30a31303d4699f00d

How to update libeio
====================
Note: we have two important changes to the stock libeio:
- it's possible to change the libeio thread stack size
  with EIO_STACKSIZE constant. In particular, EIO_STACKSIZE
  set to 0 means the default stack size.
  A larger stack size is necessary to make getaddrinfo()
  work.

- replace config.h with tarantool/config.h in eio.c

Otherwise: cvs up

How to update rb.h
======================
Get the header from
git://canonware.com/jemalloc.git
apply rb.patch patch
=======

How to update murmur hash
=========================

wget http://smhasher.googlecode.com/svn/trunk/PMurHash.c -O PMurHash.c
wget http://smhasher.googlecode.com/svn/trunk/PMurHash.h -O PMurHash.h