Tarantool development patches archive
 help / color / mirror / Atom feed
From: Safin Timur via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/n] build, lua: built-in module datetime
Date: Wed, 15 Sep 2021 00:53:41 +0300	[thread overview]
Message-ID: <f5137501-e958-34ec-8116-a73609135423@tarantool.org> (raw)
In-Reply-To: <5b50cb62e4b786ecb420ee2de5ee4d8f8c59b5d5.1631291287.git.tsafin@tarantool.org>



On 10.09.2021 20:50, Timur Safin wrote:
...
> +    local ts = obj.timestamp
> +    if ts ~= nil then
> +        local sec_int, fraction
> +        sec_int, fraction = math_modf(ts)
> +        -- if there is one of nsec, usec, msec provided
> +        -- then ignore fraction in timestamp
> +        -- otherwise - use nsec, usec, or msec
> +        if count_usec == 0 then
> +            nsec = fraction * 1e9
> +        end
> +
> +        self.secs = sec_int
> +        self.nsec = nsec
> +
> +        return self
> +    end
> +

Discovered the harder way (via hitting runtime exception) that I've not 
renamed .secs access here to .epoch field access.

-------------------------------------------------------------
diff --git a/src/lua/datetime.lua b/src/lua/datetime.lua
index 4c6471bed..540a5a940 100644
--- a/src/lua/datetime.lua
+++ b/src/lua/datetime.lua
@@ -664,7 +664,7 @@ local function datetime_set(self, obj)
              nsec = fraction * 1e9
          end

-        self.secs = sec_int
+        self.epoch = sec_int
          self.nsec = nsec

          return self
-------------------------------------------------------------

This is an indication that I've not tested date:set{timestamp = N} 
access thouroughly, and more tests cases needed. Will update 1st commit 
to branch tsafin/gh-5941-datetime-take2-wip soon with the corrected code 
and more tests.

Timur


  reply	other threads:[~2021-09-14 21:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 17:50 [Tarantool-patches] [PATCH 0/n] Datetime module implementation, stage #1 Timur Safin via Tarantool-patches
2021-09-10 17:50 ` [Tarantool-patches] [PATCH 1/n] build, lua: built-in module datetime Timur Safin via Tarantool-patches
2021-09-14 21:53   ` Safin Timur via Tarantool-patches [this message]
2021-09-14 22:45 ` [Tarantool-patches] [PATCH 0/n] Datetime module implementation, stage #1 Vladislav Shpilevoy 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=f5137501-e958-34ec-8116-a73609135423@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=tsafin@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/n] build, lua: built-in module datetime' \
    /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