pola-rs/polars

Extend `strptime` functionality to parse Duration strings

Open

#7.397 geöffnet am 7. März 2023

Auf GitHub ansehen
 (6 Kommentare) (5 Reaktionen) (0 zugewiesene Personen)Rust (2.826 Forks)batch import
acceptedenhancementhelp wanted

Repository-Metriken

Stars
 (38.496 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 3T 18h) (175 gemergte PRs in 30 T)

Beschreibung

Problem description

A format not as common as time stamps but still common enough to potentially warrant a parser are "duration stamps": e.g. what stop watches show.

Examples that currently cannot be parsed with strptime:

  • 80:00 meaning 80 minutes
  • -04:00 minus 4 hours
  • 104:00:00 104 hours

Maybe such a parser already exists? I'm not aware of one. It would benefit from standard solution as edge cases can be hairy (there may be at least 2 digits for hours, but if it's say 104 hours then hours can be 3 digits; minus signs; wrapping; whether to accept multi-wrapping, e.g. 23:483 etc.

In any case, if someone has a good idea, contribute to the time stamp usage guide, see PR: https://github.com/pola-rs/polars-book/pull/275

A StackOverflow question inspired this: https://stackoverflow.com/a/75664067/7483211

The accepted answer fails things like 80:00.000 (first solution) and 104:00.000 (first and second).

Contributor Guide