Jump to content

Decimal point scan a timestamp from string


Recommended Posts

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

Link to comment

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.

Link to comment

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

Link to comment

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

Link to comment

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

Link to comment

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

Link to comment

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

Link to comment

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?

Link to comment

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

Link to comment

QUOTE(Eugen Graf @ May 9 2007, 06:58 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

Link to comment

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

Link to comment

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.