User | Kudos |
---|---|
6 | |
5 | |
2 | |
2 | |
2 |
I was recently developing some teaching material involving "time arithmetic", and (re-)discovered some peculiar anomalies with the LabVIEW TimeStamp Control and Indicator. LabVIEW's TimeStamp is defined as "the number of seconds since midnight, 1 Jan 1904, UTC". It is represented internally as a 128-bit number, with the first 64 bits being the number of seconds, and the second 64 bits being "fractional seconds". If you subtract two TimeStamps, you get the "elapsed time" between them, which (if it is less than a day) is easily displayed by converting the resulting Dbl to a TimeStamp and wiring it to a TimeStamp indicator. You need to set the Indicator to display 24-hour UTC (and no date), otherwise you'll get "local time". In particular, if I wire the constant 0 into a Convert to TimeStamp and display this in EST, I (should) get 19:00:00.
Instead, I get 00:00:00! If I wire 1 (second), I get the expected 19:00:01, and if I wire -1, I get 18:59:59. I can get very-very close to 0 (0.0000000000001), and I'll get 19:00:00, but 0 gives me a "big jump" to 0:00:00. This is something mathematicians call a "discontinuity".
I called NI, spoke to an AE, and he seemed as surprised by this (unexpected, perhaps even undocumented) behavior. He was, however, able to find a report where someone else mentioned this, and the LabVIEW Developers chose to "leave it as it is" (no explanation that he could provide). I've been puzzling over this, and can find only one explanation (for which I have a suggested "fix") --
LabVIEW Variables have a default (or "unwired") value, frequently 0. For a TimeStamp, 0 mean "midnight, 1 Jan 1903", which I can understand will look "silly" as the "default" value of the TimeStamp control. The current unwired appearance of the TimeStamp is a time of 0:00:00 PM, and an unspecified date (MM/DD/YYYY) on my machine. This is also what is displayed when 0 is wired to it. However, this is also the value displayed when either +inf, -inf, or NaN is wired to it. Of course, wiring the Machine epsilon (the smallest non-zero real) produces 7 PM, the Disconcerting Discontinuity.
I maintain that, in the case of a TimeStamp Control or Indicator, a better "unwired" value would be NaN, which will currently give a "legal" display that is meaningful, i.e. a time of 0 (regardless of the time zone) and no specific date. This would allow NI to restore the ability to let all dates and times display on a continuous scale, with the displayed value of -1 showing a second earlier than the displayed value of 0, as expected.
Recommendation -- restore the value 0 as a "legal" TimeStamp value (displaying the equivalent of midnight, 1 Jan 1904 in accordance with the TimeStamp display format) and choose a different value, perhaps NaN, as the "unwired default". I cannot imagine that this would seriously "break" code, as it only affects the displayed value. However, having the display exhibit a "display discontinuity" as the TimeStamp value crosses 0 seems illogical and confusing, particularly for those trying to learn to use TimeStamps.
Bob Schor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any idea that has not received any kudos within a year after posting will be automatically declined.