I was just browsing the new Xojo.Core.Date, and looking at Nanoseconds. I’m considering a logging application that might want to log in increments finer than seconds.
What time is the Nanoseconds value measuring from? Is it from 1 January 1970, GMT - like TotalSeconds?
Nanoseconds is defined as an integer, wouldn’t that overflow pretty quickly with the default 32 bit integer type?
[quote=176334:@John McKernon]I was just browsing the new Xojo.Core.Date, and looking at Nanoseconds. I’m considering a logging application that might want to log in increments finer than seconds.
What time is the Nanoseconds value measuring from? Is it from 1 January 1970, GMT - like TotalSeconds?
Nanoseconds is defined as an integer, wouldn’t that overflow pretty quickly with the default 32 bit integer type?
Is it actually returning a UInt64?[/quote]
As far as I understand, it counts nanoseconds from the last full second, and when it reaches one billion, one second is added, and it starts over at zero nanosecond.
That said, I never needed such a small fraction of time. Maybe microseconds sometimes to measure execution time. For smaller than a second, I often use Ticks.
The LR describes Nanoseconds as “The nanoseconds of the time.”. To me it means for instance Seven hours, 28 minutes, 10 seconds and 12589 nanoseconds. That said, that should not be so difficult to verify with a program.
I placed a multiple Timer1 1000 Ms on a window, and added a dada Xojo.Core.Date property to it.
Button :
[code]Sub Action()
static compte as integer
dada = xojo.core.date.now
system.debuglog str(dada.Nanosecond)
compte = compte+1
if compte = 10 then me.enabled = false
End Sub
[/code]
The result is steadily about the same value with a bit of variations, like
62600000
62200000
62300000
and so on.
At first glance, it does look very much like elapsed nanoseconds from the full secon.