Eugen Graf Posted May 9, 2007 Report Share Posted May 9, 2007 Hello, I have a problem scanning a timestamp from string on a german PC. Look attached snippet. If "use localized decimal point" is set in the environment than I get this error, if not it runs without errors. It's a bug? Eugen Now I replaced Scan From String with String To Float and then convert To Timestamp. No more errors. But where was the problem? Eugen Quote Link to comment
jpdrolet Posted May 9, 2007 Report Share Posted May 9, 2007 The problem is not with the decimal specifier but with the time format itself. The format string %<%H:%M:%S%3u>T expects the timestring "15:55:29000". The correct format string should be %<%H%M%S.%3u>T with the decimal separator in the time format. Quote Link to comment
robijn Posted May 10, 2007 Report Share Posted May 10, 2007 QUOTE(jpdrolet @ May 8 2007, 06:45 PM) The problem is not with the decimal specifier but with the time format itself. The format string %<%H:%M:%S%3u>T expects the timestring "15:55:29000". The correct format string should be %<%H%M%S.%3u>T with the decimal separator in the time format. I don't think so, because the dot is already formatted/scanned by the %u thingy. I think the internal time format/scan functions don't understand/use the %.; that was placed in the format string. So it's a bug if you ask me. Joris Quote Link to comment
Eugen Graf Posted May 10, 2007 Author Report Share Posted May 10, 2007 QUOTE(robijn @ May 9 2007, 05:48 PM) I don't think so, because the dot is already formatted/scanned by the %u thingy. I think the internal time format/scan functions don't understand/use the %.; that was placed in the format string. So it's a bug if you ask me. Joris I think just as you. Eugen Quote Link to comment
Mellroth Posted May 10, 2007 Report Share Posted May 10, 2007 I don't think the original code and the workaround produces the same result. According to the probe in the picture, the input string is "155529.00". The workaround converts the string to a DBL value, i.e. 155529.00, and then to a Timestamp equal to "1904-01-02, 20:07:39.000", i.e. the value contained in the string is interpreted as seconds since "12:00 a.m., Friday, January 1, 1904, Universal Time" The original code, where you used the format string "%.;%<%H:%M:%S%3u>T", indicating that you expect the string to be parsed as 15:55:29.000 which is completely different from the result of the workaround. The solution therefore depends on what kind of time value you have in the input string: If you want it to be interpreted as 15:55:29.000, use the format string "%.;%<%H%M%S%3u>T", i.e. remove the colons (there might still be an issue with the localization). If you want it to be interpreted as seconds, use your workaround or use "%.;%t" as format string and convert to TimeStamp afterwards. Hope this make sense. /J Quote Link to comment
Eugen Graf Posted May 10, 2007 Author Report Share Posted May 10, 2007 QUOTE(JFM @ May 9 2007, 06:26 PM) I don't think the original code and the workaround produces the same result.According to the probe in the picture, the input string is "155529.00". The workaround converts the string to a DBL value, i.e. 155529.00, and then to a Timestamp equal to "1904-01-02, 20:07:39.000", i.e. the value contained in the string is interpreted as seconds since "12:00 a.m., Friday, January 1, 1904, Universal Time" The original code, where you used the format string "%.;%<%H:%M:%S%3u>T", indicating that you expect the string to be parsed as 15:55:29.000 which is completely different from the result of the workaround. The solution therefore depends on what kind of time value you have in the input string: If you want it to be interpreted as 15:55:29.000, use the format string "%.;%<%H%M%S%3u>T", i.e. remove the colons (there might still be an issue with the localization). If you want it to be interpreted as seconds, use your workaround or use "%.;%t" as format string and convert to TimeStamp afterwards. Hope this make sense. /J Thank you, you have right and the problem is not solved yet. And your solution don't realy help. See the attached screenshot. Any more? Eugen Quote Link to comment
Mellroth Posted May 10, 2007 Report Share Posted May 10, 2007 QUOTE(Eugen Graf @ May 9 2007, 06:48 PM) Thank you, you have right and the problem is not solved yet. And your solution don't realy help. See the attached screenshot. Any more?Eugen I'm sorry I didn't realize you were on LV8.01, in LV8.2 this issue seems to be resolved (except in that %3u does not work with comma). How do you want the string "155529.00" to be interpreted, as 15:55:29.00? /J Quote Link to comment
Eugen Graf Posted May 10, 2007 Author Report Share Posted May 10, 2007 P.S. It's really a big problem for me now. Can anybody help? QUOTE(JFM @ May 9 2007, 06:57 PM) I'm sorry I didn't realize you were on LV8.01, in LV8.2 this issue seems to be resolved (except in that %3u does not work with comma).How do you want the string "155529.00" to be interpreted, as 15:55:29.00? /J Yes, it's a UTC time stamp from GPS receiver. 155529.00 should be 15:55:29.00 P.S. NMEA sequence GPGGA P.P.S. I know, I can split the string by hand, than bundle it to cluster and convert it to a timestamp, but should I really do it? Quote Link to comment
Mellroth Posted May 10, 2007 Report Share Posted May 10, 2007 QUOTE(Eugen Graf @ May 9 2007, 06:58 PM) P.P.S. I know, I can split the string by hand, than bundle it to cluster and convert it to a timestamp, but should I really do it? You don't have to split the string by hand, you can: 1. use the format string "%.;%02d%02d%02d%f" to get all values in one scan, then either calculate # of seconds, or use the "Date/Time to seconds". 2. Convert the string to DBL, then divide by 10000, use quotient and remainder etc... then either calculate # of seconds, or use the "Date/Time to seconds". 3. ? /J Quote Link to comment
robijn Posted May 10, 2007 Report Share Posted May 10, 2007 QUOTE(Eugen Graf @ May 9 2007, 06:58 PM) P.S. It's really a big problem for me now. Can anybody help?Yes, it's a UTC time stamp from GPS receiver. 155529.00 should be 15:55:29.00 P.S. NMEA sequence GPGGA You could try my Time scan/format functions (http://robijn.net/labview/''>http://robijn.net/labview/' target="_blank">http://robijn.net/labview/). They still use the DBL time format, but work fine. I have not updated much lately, I do have a "modern timestamp" version laying around but I yet have to finish the Excel conversion function yet. You could use a modulus 100 twice as well. Joris Quote Link to comment
Eugen Graf Posted May 10, 2007 Author Report Share Posted May 10, 2007 QUOTE(robijn @ May 9 2007, 11:20 PM) You could try my Time scan/format functions (http://robijn.net/labview/''>http://robijn.net/labview/' target="_blank">http://robijn.net/labview/). They still use the DBL time format, but work fine. I have not updated much lately, I do have a "modern timestamp" version laying around but I yet have to finish the Excel conversion function yet.You could use a modulus 100 twice as well. Joris Wow, some time ago I so needed the julian <-> gregorian convertion and didn't know that it exists(I implemented is by myself). To my problem: I will try your VI tomorrow. And thank you. Eugen Quote Link to comment
Eugen Graf Posted May 11, 2007 Author Report Share Posted May 11, 2007 Here is my workaround, thank to all. Eugen Quote Link to comment
Mellroth Posted May 11, 2007 Report Share Posted May 11, 2007 QUOTE(Eugen Graf @ May 10 2007, 11:13 AM) Here is my workaround, thank to all.Eugen Looks good Eugen, you can, however, skip the "Get Date/Time in seconds" function, since the "Seconds To Date/Time" defaults to current time. Maybe you should also set the UTC boolean inputs? /J Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.