Re: qdate bug

6 views
Skip to first unread message

Jesse Gumm

unread,
Dec 6, 2021, 8:36:06 PM12/6/21
to nitrogenweb
Hi Jean-Yves,

Sorry for the delay here - this was filtered into spam, and just happened on it searching for something else completely unrelated :)

It's hard to troubleshoot here because I'm not sure what date() and time() are returning.  Are they returning the same thing, but qdate is misinterpreting them?

I personally almost always use os:timestamp() instead of date() and time() because I don't trust those functions while os:timestamp() is timezone-neutral (or rather are always UTC)

-Jesse

On Wed, Dec 1, 2021 at 5:26 PM 12u...@gmail.com <12u...@gmail.com> wrote:
Hi folks,
 
qdate has a weird behavior :
 
under postgresql : SELECT CURRENT_TIMESTAMP(0) :
   current_timestamp    
------------------------
 2021-12-02 00:20:02+01
 
with Nitrogen : Function : TS=qdate:to_string("Y-m-d H:i:s O", ?TZ, {date(), time()})
?PRINT(TS). (with ?TZ == "Europe/Paris")
Nitrogen console :
=INFO REPORT==== 2-Dec-2021::00:19:58.308662 ===
index: Reloaded! (Beam changed.)

=INFO REPORT==== 2-Dec-2021::00:20:17.519826 ===
DEBUG: <0.26233.1>
index:803
"TS"
  "2021-12-02 01:20:17 +0100"
 
Huuu!? One extra hour added to the regular time, why is that??
 
However, launching an independent Erlang interpreter with "-pa ./lib/qdate/ebin" returns the correct timestamp :
156> qdate:to_string("Y-m-d H:i:sO", "Europe/Paris", {date(), time()}).
"2021-12-02 00:20:50+0100"
 
Where does this extra hour comes from?
 
Jean-Yves

--
You received this message because you are subscribed to the Google Groups "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nitrogenweb...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nitrogenweb/cf4c4ec1-8cfe-4e86-ae11-8e93e752816dn%40googlegroups.com.


--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

12u...@gmail.com

unread,
Dec 7, 2021, 6:24:10 AM12/7/21
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi Jesse,

I found a solution, in my function I added a TZ initialization and used another version of the timestamp function:
my_bioutifoul_ts() ->
    qdate:set_timezone("Europe/Paris"),
    , qdate:to_string("Y-m-d H:i:s O", {date(), time()}).

which is working ferpectly :) (may be it was the lack of TZ definition that triggered that, my fault as usual).

Thanks,
Jean-Yves

Jesse Gumm

unread,
Dec 7, 2021, 8:46:46 AM12/7/21
to nitrogenweb
Excellent!

Glad you were able to figure it out!

-Jesse

Reply all
Reply to author
Forward
0 new messages