[Gambas Bug Tracker] Bug #1097: Date.ToUnixTime loses a day

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Gambas Bug Tracker] Bug #1097: Date.ToUnixTime loses a day

bugtracker
http://gambaswiki.org/bugtracker/edit?object=BUG.1097&from=L21haW4-

T. Lee DAVIDSON reported a new bug.

Summary
-------

Date.ToUnixTime loses a day

Type             : Bug
Priority         : Medium
Gambas version   : Unknown
Product          : Unknown


Description
-----------

The output of gb.util's Date.ToUnixTime is a day behind irregardless of local time vs. GMT

Here's a simple proof also showing that Date.FromUnixTime is not affected:

  Dim iEpochSeconds As Integer = 1493168023 ' 2017-Apr-26 00:53:43 GMT

  Print Date.FromUnixTime(iEpochSeconds)
  Print Now
  Print Date.FromUnixTime(Date.ToUnixTime(Now))


System information
------------------

[System]
Gambas=3.9.2
OperatingSystem=Linux
Kernel=4.4.57-18.3-default
Architecture=x86_64
Distribution=SuSE NAME="openSUSE Leap"
VERSION="42.2"
ID=opensuse
ID_LIKE="suse"
VERSION_ID="42.2"
PRETTY_NAME="openSUSE Leap 42.2"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:42.2"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
Desktop=KDE5
Theme=QtCurve
Language=en_US.UTF-8
Memory=3951M

[Libraries]
DBus=libdbus-1.so.3.8.14
OpenGL=libGL.so.1.2.0

[Environment]
(Is environment _really_ needed?)



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

[Gambas Bug Tracker] Bug #1097: Date.ToUnixTime loses a day

bugtracker
http://gambaswiki.org/bugtracker/edit?object=BUG.1097&from=L21haW4-

Comment #1 by Benoît MINISINI:

I see no problem there. Can you show me your output?

Benoît MINISINI changed the state of the bug to: NeedsInfo.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

[Gambas Bug Tracker] Bug #1097: Date.ToUnixTime loses a day

bugtracker
In reply to this post by bugtracker
http://gambaswiki.org/bugtracker/edit?object=BUG.1097&from=L21haW4-

Comment #2 by T. Lee DAVIDSON:

The output I get is:
04/25/2017 20:53:43
04/28/2017 12:07:32
04/27/2017 12:07:32

Lines 1 & 2 are correct at local time (GMT-4)
Line 3 is a day behind.

With the following:
  Dim sEpochSeconds As String

  Shell "date +%s" To sEpochSeconds
  Print Trim(sEpochSeconds)
  Print Date.ToUnixTime(Now)

I get:
1493396203
1493309803

The Date.ToUnixTime(Now) value is exactly 86400 seconds (24 hrs) less.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

[Gambas Bug Tracker] Bug #1097: Date.ToUnixTime loses a day

bugtracker
In reply to this post by bugtracker
http://gambaswiki.org/bugtracker/edit?object=BUG.1097&from=L21haW4-

Comment #3 by Benoît MINISINI:

Can you try revision #8133?



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

[Gambas Bug Tracker] Bug #1097: Date.ToUnixTime loses a day

bugtracker
In reply to this post by bugtracker
http://gambaswiki.org/bugtracker/edit?object=BUG.1097&from=L21haW4-

Comment #4 by T. Lee DAVIDSON:

Revision #8133 apparently has not hit the Packman repo yet. But, I can confirm that:
DateDiff(Date(1970, 1, 1), Now, gb.Second) + System.TimeZone

produces output that matches:
Shell "date +%s"

Thank you, Benoît.

T. Lee DAVIDSON changed the state of the bug to: Fixed.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user