chrono icon indicating copy to clipboard operation
chrono copied to clipboard

#560: Unable to parse millisecond unix timestamps

Open jgoday opened this issue 3 years ago • 1 comments

Thanks for contributing to chrono!

  • [X] Have you added yourself and the change to the changelog? (Don't worry about adding the PR number)
  • [X] If this pull request fixes a bug, does it add a test that verifies that we can't reintroduce it?

This PR tries to solve #560. When parsing Timestamps, it allows to check the next item fixed length to avoid Timestamp consuming all the remain digits (see #560 example with nanoseconds "%s%3f"). It groups items in tuples (current and next item) inside parse_internal, using slice windows.

jgoday avatar May 14 '21 21:05 jgoday

Circling back to this. This seems like a reasonable approach to me.

jszwedko avatar Dec 06 '21 16:12 jszwedko

I agree this is worth fixing. Combining %s%3f to parse a millisecond timestamp is clever. On the other hand it feels just a bit too magical.

An alternative is to add new specifiers to allow parsing millisecond, microsecond, and nanosecond timestamps as a single integer. @djc any preferences?

Also @meiamsome raised a good issue about the implementation here. @jgoday This PR is near the end of its second year... Would you still be available to push it forwards?

pitdicker avatar Apr 26 '23 05:04 pitdicker

The approach in this PR seems wordt persuing to me, but in a more general way.

It would be nice to be able to parse 63015 to 6:30:15 with %-H%M%S. I.e. support parsing one variable-length number followed by one or more fixed-length numbers.

pitdicker avatar Apr 26 '23 06:04 pitdicker

Given the lack of response from the original submitter, going to just close this for now. IMO the original issue isn't a high priority.

djc avatar May 26 '23 09:05 djc

An alternative is to add new specifiers to allow parsing millisecond, microsecond, and nanosecond timestamps as a single integer. @djc any preferences?

This is a worthy improvement.

jtmoon79 avatar May 28 '23 02:05 jtmoon79

Worthy how? Have you personally had a use case for this? Given the relative lack of resources I would like to avoid adding features people just think of.

djc avatar May 28 '23 09:05 djc

The lack of support for parsing string millisecond timestamps does come up in https://vector.dev/ occasionally, where we use chrono for date/timestamp parsing. Recent example: https://github.com/vectordotdev/vector/discussions/19577

jszwedko avatar Jan 10 '24 14:01 jszwedko

@jszwedko please open a new issue explaining your use case.

djc avatar Jan 10 '24 15:01 djc

@jszwedko please open a new issue explaining your use case.

I'd actually opened the original issue 🙂 It's here: https://github.com/chronotope/chrono/issues/560

jszwedko avatar Jan 10 '24 17:01 jszwedko

Okay, I'm open to reviewing a new PR that takes into account the feedback on this PR so far.

djc avatar Jan 11 '24 08:01 djc