BurntSushi commented on PR #7261:
URL: https://github.com/apache/arrow-rs/pull/7261#issuecomment-2712268023

   > AFAICT there isn't actually an issue with the code
   
   It depends on what you're doing, but `humantime` will happily treat `1 
month` as `30.44` days, regardless of which month it is. Similarly for other 
variable length units, like years and days. The [discussion in the Jiff 
docs](https://docs.rs/jiff/latest/jiff/fmt/friendly/index.html) shows examples, 
and specifically how Jiff avoids this pitfall.
   
   With that said, in this PR, the `impl Parse for Duration` would previously 
accept `1month` (translating it to 30.44 24-hour days), but the implementation 
in this PR will reject anything with non-zero units greater than hours. So `1 
day` would be rejected here, for example. In order to parse calendar units, you 
need to use `Span`. And to resolve that to a real duration in time, you need a 
relative datetime. (Which is more annoying and presumably why `humantime` 
decided to implicitly convert calendar units to their "average" value, despite 
it producing unintuitive results.)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to