From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <tarantool-patches-bounces@dev.tarantool.org>
Received: from [87.239.111.99] (localhost [127.0.0.1])
	by dev.tarantool.org (Postfix) with ESMTP id 020346EC40;
	Thu, 19 Aug 2021 12:47:38 +0300 (MSK)
DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 020346EC40
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev;
	t=1629366458; bh=9NbC7h8dqU2b/50mQOKBb3kGSWkRIDkrOnQj/NpRsO0=;
	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=jKVeSHeYXVTRnP5dZYln4FHB9sVAvaAX4vTE4HccyiMGkLw9j50SEIBs3H0AcpAQA
	 fsES9w+Cnj6aJjq3OQ61yLdDRaYYzG+kO+9kWzSdkq1la2C2UKvUmIxlrzhBdrsdG9
	 Bs/4vOsLQ4DgVzZ5nqT6Zs1Ip10xHTD390bTEbdw=
Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93])
 (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 0130D6EC40
 for <tarantool-patches@dev.tarantool.org>;
 Thu, 19 Aug 2021 12:47:35 +0300 (MSK)
DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0130D6EC40
Received: by smtp33.i.mail.ru with esmtpa (envelope-from
 <tsafin@tarantool.org>)
 id 1mGee5-0000Gz-Py; Thu, 19 Aug 2021 12:47:34 +0300
To: Serge Petrenko <sergepetrenko@tarantool.org>, vdavydov@tarantool.org,
 tarantool-patches@dev.tarantool.org
References: <cover.1629341071.git.tsafin@tarantool.org>
 <dd59371cb49eab89cf229a8c0b6cbbeb002de920.1629341071.git.tsafin@tarantool.org>
 <9ad0ba43-7728-2b8a-005c-8e50af4d3b29@tarantool.org>
Message-ID: <7430d59b-1a38-7a16-fff7-ec8bf3cf324f@tarantool.org>
Date: Thu, 19 Aug 2021 12:47:19 +0300
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <9ad0ba43-7728-2b8a-005c-8e50af4d3b29@tarantool.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-4EC0790: 10
X-7564579A: 646B95376F6C166E
X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9BCE6B93DE0C6C3914462CDB1732D383C182A05F5380850403694E41B00AD44803CEEB193FABAB603F2B33C8D1A7894D354A51F5B9793FF93
X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE712EB008F780777E9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637EA9DEEAA3ECF8E948638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A328B9054776384EC213B5BE59399A60117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DE1B780A39BCC1DD35D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3B355ED1E20F5346A9735652A29929C6CC4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637427B078F297B269AEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A
X-C1DE0DAB: 0D63561A33F958A5884607FF9F65D63A15D0C45755997156FA39DDD0C4873BEDD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA758B25CD4253D1D611410CA545F18667F91A7EA1CDA0B5A7A0
X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34B7CBFF60649FF266A9DAB1A41E983B71B0292E87905C70AB56CF0D59F955ABE4681F8C5C978097D51D7E09C32AA3244C804074580D8886114C7B9B32A13BEBE6D08D48398F32B4A6DCA3B3C10BC03908
X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojGSxK+6r6oBFOSS8iubJABA==
X-Mailru-Sender: 6CA451E36783D721CBEA96CEA26D325D51E661877D4E41AC0EE56406A77281C7B7CBEF92542CD7C82F97C478340294DCC77752E0C033A69E0F0C7111264B8915FF1320A92A5534336C18EFA0BB12DBB0
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 <tarantool-patches.dev.tarantool.org>
List-Unsubscribe: <https://lists.tarantool.org/mailman/options/tarantool-patches>, 
 <mailto:tarantool-patches-request@dev.tarantool.org?subject=unsubscribe>
List-Archive: <https://lists.tarantool.org/pipermail/tarantool-patches/>
List-Post: <mailto:tarantool-patches@dev.tarantool.org>
List-Help: <mailto:tarantool-patches-request@dev.tarantool.org?subject=help>
List-Subscribe: <https://lists.tarantool.org/mailman/listinfo/tarantool-patches>, 
 <mailto:tarantool-patches-request@dev.tarantool.org?subject=subscribe>
From: Safin Timur via Tarantool-patches <tarantool-patches@dev.tarantool.org>
Reply-To: Safin Timur <tsafin@tarantool.org>
Cc: v.shpilevoy@tarantool.org
Errors-To: tarantool-patches-bounces@dev.tarantool.org
Sender: "Tarantool-patches" <tarantool-patches-bounces@dev.tarantool.org>


On 19.08.2021 12:43, Serge Petrenko wrote:
> 
> 
> 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 <stdint.h>
>> +#include <stdbool.h>
>> +#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.

Thanks for the spot - forgot to drop the C part. Here is incremental part.
------------------------------------------------
diff --git a/src/lib/core/datetime.h b/src/lib/core/datetime.h
index fc5717115..ab391a4f0 100644
--- a/src/lib/core/datetime.h
+++ b/src/lib/core/datetime.h
@@ -66,16 +66,6 @@ struct datetime {
  	int32_t offset;
  };

-/**
- * Date/time interval structure
- */
-struct datetime_interval {
-	/** Relative seconds delta. */
-	double secs;
-	/** Nanoseconds delta, if any. */
-	uint32_t nsec;
-};
-
  /**
   * Required size of datetime_to_string string buffer
   */
diff --git a/src/lua/utils.c b/src/lua/utils.c
index 2c89326f3..83e482b3d 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -49,7 +49,6 @@ uint32_t CTID_CHAR_PTR;
  uint32_t CTID_CONST_CHAR_PTR;
  uint32_t CTID_UUID;
  uint32_t CTID_DATETIME = 0;
-uint32_t CTID_INTERVAL = 0;


  void *
@@ -743,14 +742,6 @@ tarantool_lua_utils_init(struct lua_State *L)
  	(void) rc;
  	CTID_DATETIME = luaL_ctypeid(L, "struct datetime");
  	assert(CTID_DATETIME != 0);
-	rc = luaL_cdef(L, "struct datetime_interval {"
-			  "double secs;"
-			  "int32_t nsec;"
-			  "};");
-	assert(rc == 0);
-	(void) rc;
-	CTID_INTERVAL = luaL_ctypeid(L, "struct datetime_interval");
-	assert(CTID_INTERVAL != 0);

  	lua_pushcfunction(L, luaT_newthread_wrapper);
  	luaT_newthread_ref = luaL_ref(L, LUA_REGISTRYINDEX);
------------------------------------------------
> 
>> +/**
>> + * 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);
>>
> ...
> 

Thanks,
Timur