From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id A51936EC56; Thu, 15 Jul 2021 11:23:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A51936EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626337433; bh=rVrDyalDIgAGDANdY6os3MwZ46EuI8UGm+IpIDXwV6E=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Qf/6oD525XpcW4lR3nwFWKON8QXHYPrBqAzBdXfcRjAY4sRJ2OHSgYuuY8tbaK++e nfPZbWLCz0P7+zUGYvYnOrgJFC7q6fbsw+LYseFBbpVHbDJCmrtfl1rRS1qToL/RJG q6LutZJjpVfso3n4y3KpR+ip3ypgF3U+V7tIWNfQ= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 424CF6F3C9 for ; Thu, 15 Jul 2021 11:19:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 424CF6F3C9 Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1m3waC-00070N-5S; Thu, 15 Jul 2021 11:19:00 +0300 To: v.shpilevoy@tarantool.org Date: Thu, 15 Jul 2021 11:18:16 +0300 Message-Id: <6e351091bd499e22b44431a89f632d63e5a8b66e.1626335241.git.tsafin@tarantool.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C38DCC94ADF53B46036ECF04D6E32A6D03182A05F538085040F7CBB2937667DA057BE08CB0130D621A3387E5A4FACE4E51F92E2564F8B1A2C6 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E8764B5BC580342EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376AEB812070489DF38638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D879CFE0DDDC09D02EFC3AD6B8AE2443A6117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEC24E1E72F37C03A04DB3626BA78294CCD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE364E7220B7C5505929735652A29929C6CC4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CE68746B1F2AB10C699A406DBC34C8129DAB35892B6492C379C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF3033054805BDE987699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F38194B2C99DC128E259798FFC7712C2A87E87983F27C5D5D1E853863C51D731406B1789599C6B271D7E09C32AA3244CF70CEE69B688B60B781B01AEE417CDD4FE8DA44ABE2443F783B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXjnYxxC9kpVb7hifE2hVxKO X-Mailru-Sender: B5B6A6EBBD94DAD8DA84A184D75F19DB2E7B7B20C3E75D0F0864CB40810A71FA3529C839C9AF681A1EC9E4A2C82A33BC8C24925A86E657CE0C70AEE3C9A96FBAB3D7EE8ED63280BE112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [RFC PATCH 10/13] lua: tostring formatization in datetime.lua X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Timur Safin via Tarantool-patches Reply-To: Timur Safin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" --- 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); + + // 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