[Gambas-user] gb3: date/time reporting odd fractional value
Caveat
Gambas at ...1950...
Thu Jun 23 11:02:30 CEST 2011
Sorry Kevin, I don't get it either. I wrote a little converter to take
the millisecond value (stuff after the point) and convert it to hours
minutes seconds, according to the standard algorithm... and I get a time
that doesn't seem to bear much resemblance to the actual time on my
system, nor to GMT, but it does increment per second/per minute as I'd
expect!
Dim rightNow As Float
Dim remain, allSeconds, seconds, minutes, hours As Integer
rightNow = Now
Print CDate(rightNow)
Print "With day: " & rightNow
rightNow = rightNow - CFloat(Int(rightNow))
Print "Just time: " & rightNow
allSeconds = Int(rightNow * 100000000)
Print "Milliseconds: " & allSeconds
allSeconds = Int(allSeconds / 1000)
' For testing a specific example off the web
' See http://www.unitarium.com/blog/tag/algorithm
' Scroll down to example 2, use method 1
'allSeconds = 43870
Print "All Seconds: " & allSeconds
seconds = allSeconds Mod 3600
Print "Seconds less hours: " & seconds
hours = Int(allSeconds / 3600)
Print "Hours: " & hours
remain = seconds Mod 60
Print "Seconds less minutes: " & remain
minutes = Int(seconds / 60)
Print "Minutes: " & minutes
seconds = remain
Print "It is now " & hours & ":" & minutes & ":" & seconds & " GMT"
Confused,
Caveat
On Thu, 2011-06-23 at 01:35 -0700, John Spikowski wrote:
> On Thu, 2011-06-23 at 04:16 -0400, Kevin Fishburne wrote:
> > On 06/23/2011 03:54 AM, John Spikowski wrote:
> > > On Thu, 2011-06-23 at 03:16 -0400, Kevin Fishburne wrote:
> > >
> > >> I'm reading about GMT on Wikipedia now... How would one interpret the
> > >> returned values with respect to GMT?
> > >>
> > > There are 25 integer World Time Zones from -12 through 0 (GMT) to +12.
> > > Each one is 15° of Longitude as measured East and West from the Prime
> > > Meridian of the World at Greenwich, England.
> >
> > Thank you.
> >
> > Why should I have to reference a time zone when sending a float between
> > two computers? The date sent is artificial, so maybe it's affected by
> > localization or something weird like that. Are date functions
> > automatically calculated against the host machine's system clock and
> > time zone?
> >
>
> The time returned by Linux is seconds past midnight of Jan. 1st 1970.
> (based on GMT) Here is a ScriptBasic example to explain.
>
> PRINT "Seconds past Jan. 1st, 1970 at midnight GMT","\n\n"
> PRINT "Local: ",NOW,"\n"
> PRINT " GMT: ",GMTIME,"\n"
>
> jrs at ...1833...:~/sb/test$ scriba Linux_Time
> Seconds past Jan. 1st, 1970 at midnight GMT
>
> Local: 1308792888
> GMT: 1308818088
> jrs at ...1833...:~/sb/test$
>
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list