- May 22, 2022
-
-
Aleksandr Lyapunov authored
By a mistake it was marked as API_EXPORT but was forgotten to be added to exports. Closes #7125 NO_DOC=bugfix
-
- May 20, 2022
-
-
Timur Safin authored
Properly calculate `isdst` field in datetime Lua object and for attribute returned by `:totable()` function. NO_DOC=next commit
-
Maxim Kokryashkin authored
LuaJIT submodule is bumped to introduce the following changes: * sysprof: change C configuration API * sysprof: enrich symtab on a new trace or a proto * sysprof: fix SYSPROF_HANDLER_STACK_DEPTH * sysprof: make internal API functions static * sysprof: add LUAJIT_DISABLE_SYSPROF to Makefile * symtab: check the _GNU_SOURCE definition Within this changeset Tarantool-specific backtrace handler is introduced and set to be used by sysprof machinery. Besides, all new public Lua C API introduced within this changeset is added to extra/exports. Follows up #781 NO_DOC=LuaJIT submodule bump NO_TEST=LuaJIT submodule bump NO_CHANGELOG=LuaJIT submodule bump
-
Mergen Imeev authored
This patch introduces operator [] that allows to get elements from MAP and ARRAY values. Closes #4762 Closes #4763 Part of #6251 @TarantoolBot document Title: Operator [] in SQL Operator `[]` allows to get an element of MAP and ARRAY values. Examples: ``` tarantool> box.execute([[SELECT [1, 2, 3, 4, 5][3];]]) --- - metadata: - name: COLUMN_1 type: any rows: - [3] ... tarantool> box.execute([[SELECT {'a' : 123, 7: 'asd'}['a'];]]) --- - metadata: - name: COLUMN_1 type: any rows: - [123] ... ``` The returned values is of type ANY. If the operator is applied to a value that is not a MAP or ARRAY or is NULL, an error is thrown. Example: ``` tarantool> box.execute([[SELECT 1[1];]]) --- - null - Selecting is only possible from map and array values ... ``` However, if there are two or more operators next to each other, the second or following operators do not throw an error, but instead return NULL. Example: ``` tarantool> box.execute([[select [1][1][2][3][4];]]) --- - metadata: - name: COLUMN_1 type: any rows: - [null] ... ```
-
- May 11, 2022
-
-
Timur Safin authored
Since recently we partially support timezone names (i.e. as abbreviations) so we may modify tz attribute support for datetime constructors or :set() operations. Closes #7076 Relates to #7007 @TarantoolBot document Title: datetime tz attribute Now `tz` attribute is properly handled in datetime value constructors or `:set{}` method modifiers. ``` tarantool> T = date.new{year = 1980, tz = 'MSK'} --- ... tarantool> T.tzoffset --- - 180 ... tarantool> T.tz --- - MSK ... tarantool> T = date.new{year = 1980, tzoffset = 180} --- ... tarantool> T.tzindex --- - 0 ... tarantool> T.tz --- - ... tarantool> T.tzoffset --- - 180 ... tarantool> T:set{tz = 'MSK'} --- ... tarantool> T.tz --- - MSK ... ```
-
- Apr 29, 2022
-
-
Vladimir Davydov authored
Box read operations (select, min, max, random, pairs) may call a Lua function via Lua C API if space upgrade (EE feature) is in progress. This is forbidden if the original function was called via FFI: https://github.com/tarantool/luajit/commit/4f4fd9ebeb10d53c8e67f45170938f052818e64e Let's add helper functions to disable FFI for box read operations. We will use them in EE code. NO_DOC=internal NO_TEST=internal NO_CHANGELOG=internal
-
- Apr 28, 2022
-
-
Yaroslav Lobankov authored
Fix the following error: {"badRequest": {"message": "The requested availability zone is not available", "code": 400}} NO_DOC=testing stuff NO_TEST=testing stuff NO_CHANGELOG=testing stuff
-
- Apr 25, 2022
-
-
Maxim Kokryashkin authored
LuaJIT submodule is bumped to introduce the following changes: * GC64: disable sysprof support * build: make -DLUAJIT_DISABLE_SYSPROF work * test: disable sysprof C API tests with backtrace * tools: introduce parsers for sysprof * sysprof: introduce Lua API * memprof: add profile common section * core: introduce lua and platform profiler * memprof: move symtab to a separate module * core: separate the profiling timer from lj_profile * vm: save topframe info into global_State Within this changeset a parser for binary data dumped via the sampling profiler to Tarantool binary. It is a set of the following Lua modules: * sysprof/parse.lua: decode the sampling profiler event stream * sysprof/collapse.lua: collapse stacks obtained while profiling * sysprof.lua: Lua script and module to display data Besides, all new public Lua C API introduced within this changeset is added to extra/exports. Closes #781 NO_DOC=LuaJIT submodule bump NO_TEST=LuaJIT submodule bump
-
Mergen Imeev authored
This patch introduces basic INTERVAL support in SQL. After this patch, it will be allowed to select INTERVAL values from spaces, insert them into spaces, and use them in functions. CAST() from INTERVAL to STRING and ANY is also supported. Part of #6773 NO_DOC=Will be added later. NO_CHANGELOG=Will be added later.
-
- Apr 22, 2022
-
-
Mergen Imeev authored
Part of #6773 NO_DOC=INTERVAL has already been introduced earlier. NO_CHANGELOG=It will be added in another commit.
-
Timur Safin authored
Split single sec field in the datetime_interval into multiple subfields, i.e. week, day, hour, min, sec. Make sure that whatever we enter in the constructor we get similarly visualized as textual representation Lua implementation of datetime_totable has been converted to C, which allows to use it for datetime values decomposing in datetimes subtraction. It uses per component subtraction for calculating of a resultant interval. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring
-
Timur Safin authored
Created C implementation for the rest of datetime/interval operations and call them via FFI. We need it for later Olson integration. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
Timur Safin authored
Convert Lua implementation of datetime_increment_by to C from their Lua variant. Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
Timur Safin authored
Part of #6923 NO_DOC=refactoring NO_CHANGELOG=refactoring NO_TEST=refactoring, tests left intact
-
- Apr 13, 2022
-
-
Nikita Pettik authored
Simply add Lua wrappers for recently introduced prbuf. Introduce new buffer (in addition to ibuf) - prbuf. "pr" stands for "partitioned ring-". It save all metadata in the same memory chunk provided for storage, so it can be completely restored from the 'raw' memory. API: ``` -- mem is a chunk of raw (char *) memory, of size mem_size. -- It is used for data storage. Note that available space is of less -- size due to prbuf metadata overhead. -- Returns handle to prbuf. -- require('buffer').prbuf_create(mem, mem_size) -- mem is a chunk of memory, which contains already created prbuf. -- It implies that once prbuf_create() was called with the same memory. -- If mem does not contain valid buffer - raise an appropriate error. require('buffer').prbuf_open(mem) -- Returns continuous chunk of memory with given size. May return nil -- in case if requested chunk is too large. Note that after copying -- object to returned chunk, it should be committed with prbuf:commit(); -- otherwise :prepare() may return the same chunk twice. prbuf:prepare(size) -- Commits the last prepared chunk. Undefined behaviour in case of -- committing the same chunk twice. prbuf:commit() -- Create and return prbuf_iterator. Does not fail. Created iterator -- points to nowhere - it should be adjusted with :next() call to -- the first entry. prbuf:iterator_create() -- Advance iterator position. Returns prbuf_entry or nil in case -- iterator has reached the end. Entry consists of two members: -- size and ptr. The last one is an array of characters of given size. iterator:next() ``` Usage examples: ``` local ibuf = buffer.ibuf() local prbuf_size = 100 local memory = ibuf:alloc(prbuf_size) local prbuf = buffer.prbuf_create(memory, prbuf_size) local sample_size = 4 local raw = prbuf:prepare(4) if raw == nil then -- allocation size is too large, try smaller. end raw[0] = ... ... raw[3] = ... prbuf:commit() local prbuf_recovered = buffer.prbuf_open(memory) local iter = prbuf_recovered:iterator_create() local entry = iter:next() assert(tonumber(entry.size) == 4) -- Check values stored in the buffer. assert(entry.ptr[0] == ...) entry = iter:next() -- Our buffer has only one entry. assert(entry == nil) ``` NO_DOC=<Feature for internal usage> NO_CHANGELOG=<Feature for internal usage>
-
Pavel Balaev authored
Currently `tarantoolctl rocks --help` generate such help message: NAME /usr/bin/tarantoolctl - LuaRocks main command-line interface SYNOPSIS /usr/bin/tarantoolctl [<flags...>] [VAR=VALUE]... This is wrong. This patch makes the output look like this: NAME /usr/bin/tarantoolctl rocks - LuaRocks main command-line interface SYNOPSIS /usr/bin/tarantoolctl rocks [<flags...>] [VAR=VALUE]... NO_DOC=bugfix
-
- Apr 11, 2022
-
-
Andrey Saranchin authored
An opportunity to call garbage collector of memtx transaction manager manually allows to understand which garbage cannot be freed. This knowledge can help us to improve garbage collector. Also this opportunity makes it easier to test memtx mvcc memory monitoring. Part of #6150 NO_DOC=internal feature NO_CHANGELOG=internal feature NO_TEST=internal feature
-
- Apr 04, 2022
-
-
Aleksandr Lyapunov authored
Now memtx TX manager tries to determine the best isolation level by itself. There could be two options: * READ_COMMITTED, when the transaction see changes of other tx that are committed but not yet confirmed (written to WAL) * READ_CONFIRMED, when the transaction see only confirmed changes. Introduce a simple way to specify the isolation level explicitly: box.begin{tx_isolation = 'default'} - the same as box.begin(). box.begin{tx_isolation = 'read-committed'} - READ_COMMITTED. box.begin{tx_isolation = 'read-confirmed'} - READ_CONFIRMED. box.begin{tx_isolation = 'best-effort'} - old automatic way. Intrduce a bit more complex but potentially faster way to set isolation level, like that: my_level = box.tnx_isolation_level.READ_COMMITTED .. box.begin{tx_isolation = my_level} For simplicity of implementation also support symmetric values as 'READ_COMMITTED' and box.tnx_isolation_level['read-committed']. Introduce a new box.cfg option - default_tx_isolation, that is used as a default when a transaction is started. The option is dynamic and possible values are the same as in box.begin, except 'default' which is meaningless. In addition to string value the corresponding numeric values can be used in both box.begin and box.cfg. Part of #6930 NO_DOC=see later commits NO_CHANGELOG=see later commits
-
Timur Safin authored
* Default parse - new c-dt version used which handles extended years range while parse relaxed iso8601 gformat strings; - family of functions like dt_from_ymd_checked functions added to the new c-dt version, now used by conversion code to properly handle validation of a 32-bit boundary values; - datetime_parse_full() modified to properly handle huge years values; - added tests for extended years range. * strptime-like parse - properly handle longer than 4 years values, negative values, and handle zulu suffix, which may be generated by Tarantool stringization routines; Part of #6731 NO_DOC=internal NO_CHANGELOG=internal
-
Timur Safin authored
To parse date/time strings using format string we use `strptime()` implementation from FreeBSD, which is modified to use our `struct datetime` data structure. List of supported format has been extended to include `%f` which is flag used whenever you need to process nanoseconds part of datetime value. ``` tarantool> T = date.parse('Thu Jan 1 03:00:00 1970', {format = '%c'}) tarantool> T - 1970-01-01T03:00:00Z tarantool> T = date.parse('12/31/2020', {format = '%m/%d/%y'}) tarantool> T - 2020-12-31T00:00:00Z tarantool> T = date.parse('1970-01-01T03:00:00.125000000+0300', {format = '%FT%T.%f%z'}) tarantool> T - 1970-01-01T03:00:00.125+0300 ``` Part of #6731 NO_DOC=internal NO_CHANGELOG=internal
-
Timur Safin authored
Datetime module provides parse function to create datetime object given input string. `datetime.parse` function expect 1 required argument - which is input string, and set of optional parameters passed as table in 2nd argument. Allowed attributes in this optional table are: * `format` - should be either 'iso8601', 'rfc3339' or `strptime`-like format string. [strptime format will be added as part of next commit]; * `tzoffset` - to redefine offset of input string value, if there is no timezone provided. * `tz` - human-readable, Olson database, timezone identifier, e.g. 'Europe/Moscow'. Not yet implemented in this commit. ``` tarantool> T = date.parse('1970-01-01T00:00:00Z') tarantool> T - 1970-01-01T00:00:00Z tarantool> T = date.parse('1970-01-01T00:00:00', {format = 'iso8601', tzoffset = 180}) tarantool> T - 1970-01-01T00:00:00+0300 tarantool> T = date.parse('2017-12-27T18:45:32.999999-05:00', {format = 'rfc3339'}) tarantool> T - 2017-12-27T18:45:32.999999-0500 ``` Implemented as per RFC https://hackmd.io/@Mons/S1Vfc_axK#%D0%AD%D1%82%D0%B0%D0%BF-3-%D0%9F%D0%B0%D1%80%D1%81%D0%B8%D0%BD%D0%B3-%D0%B4%D0%B0%D1%82-%D0%BF%D0%BE-%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D1%83 Part of #6731 NO_DOC=internal NO_CHANGELOG=internal
-
- Mar 14, 2022
-
-
Mergen Imeev authored
This patch introduces basic DATETIME support in SQL. After this patch, it will be allowed to select DATETIME values from spaces, insert them into spaces, and use them in functions. CAST() from DATETIME to STRING, SCALAR and ANY is also supported. Part of #6773 NO_DOC=Doc-request will be added in another commit. NO_CHANGELOG=Changelog will be added in another commit.
-
- Dec 20, 2021
-
-
Timur Safin authored
Serialize `struct datetime` as newly introduced MP_EXT type. It saves 1 required integer field and 3 optional fields: - epoch is required field; - but nsec, tzoffset and tzindex are optional; * supported json, yaml serialization formats, lua output mode; Please refer to the https://hackmd.io/@Mons/S1Vfc_axK#%D0%A3%D0%BF%D0%B0%D0%BA%D0%BE%D0%B2%D0%BA%D0%B0-%D0%B2-msgpack for a description of a messagepack serialization schema for datetime values. Follow-up to #5941 Part of #5946
-
Timur Safin authored
Add interval arithmetics as date:add{} and date:sub{}, or overloaded '+' and '-' operators (__add/_sub metamethods). There is no special processing for timezone specific daylight saving time changes, which impacts result of arithmetics. This will be completed after Olsen database support added. If one needs to control a way arithmetic proceeded for days of months then there is optional argument to `:add()` or `:sub()`, which defines how we round day in month after arithmetic operation: - 'last' - mode when day snaps to the end of month, if happens: -- 29.02.2004 -> 31.03.2004 dt:add{month = 1, adjust = "last" } - 'none' only truncation toward the end of month performed (**default mode**): -- 29.02.* -> 29.03.* dt:add{month = 1, adjust = "none" } - 'excess' - overflow mode, without any snap or truncation to the end of month, straight addition of days in month, stopping over month boundaries if there is less number of days. dt = new{year = 2004, month = 1, day = 31} dt:add{month = 1, adjust = 'excess'} -> 02.03.2004 -- i.e. there were 29 days in February 2004, 2 excessive days from original date 31 make result 2nd March 2004 Intervals objects, created via `datetime.interval.new()` call and objects of the same attributes are equivalent for interval arithmetics and exchangeable. i.e. dt + date.interval.new{year = 1, month = 2} is the same as dt + {year = 1, month = 2} Follow-up to #5941
-
- Dec 17, 2021
-
-
Vladimir Davydov authored
Currently, we use the same luarocks hardcoded config for static build as for regular build. As a result, LUA_BINDIR, LUA_INCDIR, SYSCONFDIR, and PREFIX point to locations inside the build directory, which doesn't make any sense. Let's introduce a special hardcoded config which will set those directories to locations relative to the binary location: - LUA_BINDIR: directory where the binary is located (bindir) - PREFIX: <dir> if bindir is <dir>/bin, otherwise bindir. - LUA_INCDIR: PREFIX/include/tarantool - SYSCONFDIR: PREFIX/etc/tarantool/rocks Also, let's add the PREFIX/rocks to the rocks path if present. This is needed for Tarantool SDK bundle to work as expected. In particular the check for <dir>/bin is needed, because SDK installs binaries in bundle root, not in /bin.
-
Vladimir Davydov authored
The options are not used anymore since update to 3.1.1, see third_party/luarocks/src/luarocks/core/cfg.lua. They should have been removed by commit 4222c1f6 ("rocks: update luarocks to 3.1.1")
-
Vladimir Davydov authored
It contains Lua code. Format it appropriately. No functional changes.
-
- Dec 13, 2021
-
-
mechanik20051988 authored
Previously, URI can be passed as a string, which contains one URI or several URIs separated by commas. Now URIs can be passed in different ways: as before, as a table which contains URI and it's parameters in "param" table, as a table which contains URI strings and URI tables. Also there are different ways to specify properties for URI: in a string which contains URI, after '?' delimiter, in a table which contains URI in "params" table, in "default_params" table if it is default parameters for all URIs. For this purposes new method `parse_many` was implemented in tarantool `uri` library. Also `parse` method was updated to make possible the same as new `parse_many` method but only for single URI. ```lua uri = require('uri') -- Single URI, passed as before uri.parse_many("/tmp/unix.sock") -- Single URI, with query paramters uri.parse_many("/tmp/unix.sock?q1=v1&q2=v2") -- Several URIs with parameters in one string, separated by commas uri.parse_many("/tmp/unix.sock_1?q=v, /tmp/unix.sock_2?q=v") -- Single URI passed in table, with additional parameters, passed -- in "params" table. This parameters overwrite parameters from -- URI string (q1 = "v2" in example below). uri.parse_many({"/tmp/unix.sock?q1=v1", params = {q1 = "v2"}}) -- For parse it's also works now uri.parse({"/tmp/unix.sock?q1=v1", params = {q1 = "v2"}}) -- Several URIs passed in table with default parameters, passed -- in "default_params" table, which are used for parameters, which -- not specified for URI (q3 parameter with "v3" value corresponds -- to all URIs, and used if there is no such parameter in URI). uri.parse_many({ "/tmp/unix.sock_1?q1=v1", { uri = "/tmp/unix.sock_2", params = { q2 = "v2" } }, default_params = { q3 = "v3" } }) ```
-
mechanik20051988 authored
Implement ability to parse a string, which contains several URIs separated by commas. Each URI can contain different query parameters after '?'. All created URIs saved in new implemented struct `uri_set`. Part of #5928
-
mechanik20051988 authored
In the future, it is planned to extend the URI structure to allow its passing with different options and in different formats (see next commit `uri: implement ability to parse URI query paramters` for example). For these purposes, it is planned to use functions that modify the source string, for example `strtok_r`, so we need to rework the URI structure to create copies of the string for each of the URI components. Part of #5928
-
- Dec 10, 2021
-
-
Vladimir Davydov authored
Without it `tarantoolctl rocks` would require luarocks to be installed on the system, which isn't always possible.
-
- Dec 09, 2021
-
-
Sergey Ostanevich authored
Use of PROJECT_ prefix gives ability to build the project as a submodule of other projects.
-
- Dec 01, 2021
-
-
Pavel Balaev authored
In FreeBSD sed is not support \s as whitespace characters definition. However, since FreeBSD-13 sed behaivour changed from ignore to error: sed complains about trailing backslash (\). We should use whitespace definition from POSIX standart. More info: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253893 CLoses #6637 Signed-off-by:
Pavel Balaev <balaev@tarantool.org>
-
- Nov 24, 2021
-
-
Mergen Imeev authored
This patch introduces MAP to SQL. After this patch, all SQL operations and built-in functions should work correctly with MAP values. However, there is currently no way to create MAP values using only SQL tools. Part of #4763 @TarantoolBot document Title: Field type MAP in SQL Properties of type MAP in SQL: 1) a value of type MAP can be implicitly and explicitly cast only to ANY; 2) only a value of type ANY with primitive type MAP can be explicitly cast to MAP; 3) a value of any other type cannot be implicitly cast to MAP; 4) a value of type MAP cannot participate in arithmetic, bitwise, comparison, and concatination operations.
-
Mergen Imeev authored
This patch introduces ARRAY to SQL. After this patch, all SQL operations and built-in functions should work correctly with ARRAY values. However, there is currently no way to create ARRAY values using only SQL tools. Part of #4762 @TarantoolBot document Title: Field type ARRAY in SQL Properties of type ARRAY in SQL: 1) a value of type ARRAY can be implicitly and explicitly cast only to ANY; 2) only a value of type ANY with primitive type ARRAY can be explicitly cast to ARRAY; 3) a value of any other type cannot be implicitly cast to ARRAY; 4) a value of type ARRAY cannot participate in arithmetic, bitwise, comparison, and concatination operations.
-
- Nov 16, 2021
-
-
Vladislav Shpilevoy authored
In Lua struct error used RTTI to return members of the error depending on its type. If a field was added to error's payload, it wasn't visible. The patch makes Lua use error_payload instead of RTTI. Now if the payload gets a new field, it becomes automatically visible in Lua without need to introduce a new method for it. Part of #5568 Part of #4610 Part of #4907
-
- Nov 11, 2021
-
-
Mergen Imeev authored
Closes #3174 @TarantoolBot document Title: Field type ANY in SQL Properties of type ANY in SQL: 1) typeof() with an argument of type ANY returns "any"; 2) any value of any type can be implicitly and explicitly cast to the ANY type; 3) a value of type ANY cannot be implicitly cast to any other type; 4) a value of type ANY cannot participate in arithmetic, bitwise, comparison, and concationation operations.
-
- Nov 02, 2021
-
-
Alexander Turenko authored
Jepsen testing starts one or several virtual machines and runs tarantool instances on them. The first (first important for us here) command on the virtual machine is `apt-get <...> update`: we should download packages list to allow Jepsen to install necessary dependencies. However we can access the virtual machine (using ssh) before it is fully initialized by the cloud-init script. In particular, the cloud-init script replaces apt's mirror list file (`/etc/apt/sources.list`). Normally we should call `apt-get <...> update` after the package list update, but here cloud-init races with the update command. In the bad case the commands are executed in the opposite order: * Terraform calls `apt-get <...> update`. * cloud-init replaces `/etc/apt/sources.list`. Now an attempt to install a package using apt-get will give the 'unable to locate package' error, because we have no packages list for the 'new' mirrors. The problem is nicely described in [1]. See also the linked issue for details. [1]: https://github.com/hashicorp/packer/issues/41#issuecomment-21288589 Fixes https://github.com/tarantool/jepsen.tarantool/issues/87
-
- Oct 25, 2021
-
-
mechanik20051988 authored
Client code errors or manual mistakes can create transactions that are never closed. Such transaction will work as a memory leak. Implement timeout for transactions after which they are rolled back. Part of #6177 @TarantoolBot document Title: ability to set timeout for transactions was implemented Previously transactions are never closed until commit or rollback. Timeout for transactions was implemented after which they are rolled back. For these purpose, in `box.begin` the optional table parameter was added. For example if user want to start transaction with timeout 3s, he should use `box.begin({timeout = 3})`. Also was implement new configuration option `box.cfg.txn_timeout` which determines timeout for transactions, for which the timeout was not explicitly set. By default this option is set to infinity (TIMEOUT_INFINITY = 365 * 100 * 86400). Also in C API was added new function to set timeout for transaction - 'box_txn_set_timeout'.
-
- Oct 14, 2021
-
-
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.
-