From: Timur Safin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [RFC PATCH 10/13] lua: tostring formatization in datetime.lua
Date: Thu, 15 Jul 2021 11:18:16 +0300 [thread overview]
Message-ID: <6e351091bd499e22b44431a89f632d63e5a8b66e.1626335241.git.tsafin@tarantool.org> (raw)
In-Reply-To: <cover.1626335241.git.tsafin@tarantool.org>
---
src/lua/datetime.lua | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/lua/datetime.lua b/src/lua/datetime.lua
index 5cb53c6f2..081e759fd 100644
--- a/src/lua/datetime.lua
+++ b/src/lua/datetime.lua
@@ -53,6 +53,12 @@ ffi.cdef [[
dt_t dt_from_struct_tm (const struct tm *tm);
void dt_to_struct_tm (dt_t dt, struct tm *tm);
+ // mp_datetime.c
+
+ int
+ datetime_to_string(const struct datetime_t * date, char *buf, uint32_t len);
+
+
// <asm-generic/posix_types.h>
typedef long __kernel_long_t;
typedef unsigned long __kernel_ulong_t;
@@ -566,8 +572,13 @@ local function strftime(fmt, o)
return ffi.string(buff)
end
--- strftime may be redirected to datetime:fmt("format")
-local function datetime_fmt()
+local function datetime_tostring(o)
+ assert(ffi.typeof(o) == datetime_t)
+ local sz = 48
+ local buff = ffi.new('char[?]', sz)
+ local len = native.datetime_to_string(o, buff, sz)
+ assert(len < sz)
+ return ffi.string(buff)
end
@@ -583,7 +594,8 @@ return setmetatable(
parse_date = parse_date,
parse_time = parse_time,
parse_zone = parse_zone,
- fmt = datetime_fmt,
+
+ tostring = datetime_tostring,
now = local_now,
-- strptime = strptime;
--
2.29.2
next prev parent reply other threads:[~2021-07-15 8:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 8:18 [Tarantool-patches] [RFC PATCH 00/13] Initial datetime support Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 01/13] build: add Christian Hansen c-dt to the build Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 02/13] lua: built-in module datetime Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 03/13] test: datetime test Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 04/13] test: datetime string formatting Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 05/13] box: add messagepack support for datetime Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 06/13] lua: positive/negative cases in datetime test Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 07/13] lua: asctime and strfime fixed Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 08/13] box, lua: renamed t_datetime_tz structure to datetime_t Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 09/13] lua: calculated attributes for date Timur Safin via Tarantool-patches
2021-07-15 8:18 ` Timur Safin via Tarantool-patches [this message]
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 11/13] test: allow relaxed date format without tz Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 12/13] lua: initial time duration support Timur Safin via Tarantool-patches
2021-07-15 8:18 ` [Tarantool-patches] [RFC PATCH 13/13] lua: complete " Timur Safin via Tarantool-patches
2021-07-15 16:56 ` [Tarantool-patches] [RFC PATCH 00/13] Initial datetime support Oleg Babin via Tarantool-patches
2021-07-15 23:03 ` Timur Safin via Tarantool-patches
2021-07-16 6:58 ` Oleg Babin via Tarantool-patches
2021-07-22 10:01 ` Igor Munkin via Tarantool-patches
2021-07-22 12:54 ` Timur Safin via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e351091bd499e22b44431a89f632d63e5a8b66e.1626335241.git.tsafin@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=tsafin@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [RFC PATCH 10/13] lua: tostring formatization in datetime.lua' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox