11-05-2014 11:01 AM
Hello all,
I am currently working on an application that uses web services to populate a web-based UI. One of the outputs is a measurement time that is generated using the LabVIEW method 'Get Date/Time in Seconds'. To make since of this, I convert the value to a double precision float and transmit it to the host (on request). On the host side, I am using Javascript to populate a text box with the current measurement date and time. To do this, I use the followign code
var dateobj = new Date(1904,1,1); /* The variable 'time' should be the seconds since * midnight 1 Jan 1904 of the current measurement. */ var measTime = dateobj.setSeconds(time);
When I do this, what I find is that the time is actually one month off. I can correct this by changing the date in the creation of my 'dateobj' to 1 Dec 1903. Has anyone seen this before, possibly in another language? It is not beyond the realm of reason that I am doing something incorrectly, but I can't seem to get at what right now.
Thanks, Matt
Solved! Go to Solution.
11-06-2014 06:35 PM
Just a guess. It might be related to the fact that 1904 is well before the beginning of time in the linux/unix world.
Mike...
11-06-2014 08:50 PM
It's well before time started on all computers. He's likely using that date in reference to this: http://zone.ni.com/reference/en-XX/help/371361H-01/glang/get_date_time_in_seconds/
There's an easy way to determine if that is the issue. You can feed a shorter time just to see if it reads correctly rather than a more recent time. I don't work with Java enough to know if the methods you're calling are related to a defined class or one you've built. I'd imagine they have a Date API for you already. If so, I'd expect it could handle those kinds of calculations. Have you looked at their API to see if you're making a correct call?
11-06-2014 08:51 PM
11-06-2014 10:40 PM
Not that I'm offering anything new here bu,t I wonder if it could be somewhat related to a known issue where Crash reports would post a month in the future
Darn it CA- I can't find the bug thread or CAR! and I know that "crash report in the future" had both!
11-06-2014 10:44 PM
Hmmmm...that's intriguing.... I need to do some more thorough experimenting to see if I can reproduce this behavior and if there is some point at which it all flips and problem goes away. I am pretty sure that like Teststand, time is referenced to 1970 rather than 1904. I will look into this and try to provide some more details. I was hoping that someone would pop up and say that they had done this before and had no problems; but, I may be a bit optimistic...
11-06-2014 10:58 PM
@mtat76 wrote:
Hmmmm...that's intriguing.... I need to do some more thorough experimenting to see if I can reproduce this behavior and if there is some point at which it all flips and problem goes away. I am pretty sure that like Teststand, time is referenced to 1970 rather than 1904. I will look into this and try to provide some more details. I was hoping that someone would pop up and say that they had done this before and had no problems; but, I may be a bit optimistic...
Epoch for LabVIEW IS the non-existant second before midnight on Jan 1 1904, Leap secods are un-accounted for to the best of my knowlegde. and since 1904 WAS a leap year the Lotus" phantom 1900 Feb 29 does not pertain at all.
The "one month off issue" bares investigation. I Know Altenbach reported that happened with NI Error Reporting Service logs but, my Google skills fail me and I never did read a "First cause" analisys of the resolution. (The CAR is closed: Read that as "Maybe someone at NI found a viable workaround")
11-06-2014 11:15 PM
Which CAR was it? I'll try my google skills. Maybe I'll get lucky?
11-06-2014 11:16 PM - edited 11-06-2014 11:17 PM
OK...this is pretty lame, but turns out to be a js issue and not a LV issue. Month's are 0 based! Sooooo... Jan == 0 in js world. Ugh..case closed. For those interested, here is an example:
11-06-2014 11:18 PM
Interesting. That makes you wonder why choosing the 13th month didn't throw an error