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 61D9C6EC40; Thu, 19 Aug 2021 12:43:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 61D9C6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629366200; bh=0gp9zaauwz2Y8NxmqSs9ysEjhTKvPKq9I3lm++MaizU=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ghkqSeGl0oKQ74OOpoF5/Rla9D3Xjw8FBPNIoRWJ34GrRCQyye8UBYvFrGeQ7lfsV bqGytAQ9yZ5wb+zpjrprqAMsrHmXZ7idzXlgNyoZSuBMGD09sXvgBhXlveQJ9SsNj9 erZwtNDjlJ4CTAzWiuaXbRujRqmj7Lxc1O1tuO/o= Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 C5C776EC40 for ; Thu, 19 Aug 2021 12:43:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C5C776EC40 Received: by smtp56.i.mail.ru with esmtpa (envelope-from ) id 1mGeZw-0007yV-On; Thu, 19 Aug 2021 12:43:17 +0300 To: Timur Safin , vdavydov@tarantool.org, tarantool-patches@dev.tarantool.org References: Message-ID: <9ad0ba43-7728-2b8a-005c-8e50af4d3b29@tarantool.org> Date: Thu, 19 Aug 2021 12:43:15 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9ECFD080E047A606F56291F8739A291D6182A05F538085040BCE8047CAE48029011CD0FDB5A350EF288550326F6C66A6E3C0DDE05CCF9B30F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A3DED2DACB82E709C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7F68DA2F3749BB650EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F25B52CC5E9EBC61A4E6D21390FE8DFFAECC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9B5C8C57E37DE458B9E9CE733340B9D5F3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735B58781B77DE60D36C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A53C4C45B620E35DE02753F1CE79B2DDDA084E460DA514E083D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA758B25CD4253D1D611410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3475FE4AA98865E235C846F3A665EAC364E62394F9643722D6C5CF9A9CE69D0A7F5048CA29CC32F3B51D7E09C32AA3244CEE64CF442D2F980CA73A77B2EE7F39664DBEAD0ED6C55A80DCA3B3C10BC03908 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojGSxK+6r6oBF6s9Ezv2Wvfg== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A4461330BB2E572D6BA1B076BFEB8A561177F735632FA06710BD424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v6 1/5] build, lua: built-in module datetime 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: v.shpilevoy@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 19.08.2021 05:56, Timur Safin пишет: ... > diff --git a/src/lib/core/datetime.h b/src/lib/core/datetime.h > new file mode 100644 > index 000000000..71feefded > --- /dev/null > +++ b/src/lib/core/datetime.h > @@ -0,0 +1,86 @@ > +#pragma once > +/* > + * SPDX-License-Identifier: BSD-2-Clause > + * > + * Copyright 2021, Tarantool AUTHORS, please see AUTHORS file. > + */ > + > +#include > +#include > +#include "c-dt/dt.h" > + > +#if defined(__cplusplus) > +extern "C" > +{ > +#endif /* defined(__cplusplus) */ > + > +/** > + * We count dates since so called "Rata Die" date > + * January 1, 0001, Monday (as Day 1). > + * But datetime structure keeps seconds since > + * Unix "Epoch" date: > + * Unix, January 1, 1970, Thursday > + * > + * The difference between Epoch (1970-01-01) > + * and Rata Die (0001-01-01) is 719163 days. > + */ > + > +#ifndef SECS_PER_DAY > +#define SECS_PER_DAY 86400 > +#define DT_EPOCH_1970_OFFSET 719163 > +#endif > + > +#define SECS_EPOCH_1970_OFFSET \ > + ((int64_t)DT_EPOCH_1970_OFFSET * SECS_PER_DAY) > +/** > + * datetime structure keeps number of seconds since > + * Unix Epoch. > + * Time is normalized by UTC, so time-zone offset > + * is informative only. > + */ > +struct datetime { > + /** Seconds since Epoch. */ > + double secs; > + /** Nanoseconds, if any. */ > + uint32_t nsec; > + /** Offset in minutes from UTC. */ > + int32_t offset; > +}; > + > +/** > + * Date/time interval structure > + */ > +struct datetime_interval { > + /** Relative seconds delta. */ > + double secs; > + /** Nanoseconds delta, if any. */ > + uint32_t nsec; > +}; > + Hi! Thanks for working on this! I don't see you use this struct anywhere in the patch. AFAICS interval operations are implemented via add_years(), add_months() and so on. Let's drop the struct then. We may introduce it once it becomes necessary again. Let's also drop the CTID_INTERVAL definition in lua/utils.c LGTM, once you remove the interval. > +/** > + * Convert datetime to string using default format > + * @param date source datetime value > + * @param buf output character buffer > + * @param len size ofoutput buffer > + */ > +int > +datetime_to_string(const struct datetime *date, char *buf, int len); > ... -- Serge Petrenko