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

   > Given these are timeouts I suspect few users are configuring anything 
larger than an hour. Are there any differences when parsing such?
   
   That's a good point and a good question. The major difference is definitely 
that parsing into `SignedDuration` will reject any duration with non-zero 
year/month/week/day units. But aside from that, I think it depends on which 
direction of compatibility you're interested in. If it's just a matter of what 
`humantime` supports in terms of parsing, we can take a look at its 
implementation:
   
   ```rust
           let (mut sec, nsec) = match &self.src[start..end] {
               "nanos" | "nsec" | "ns" => (0u64, n),
               "usec" | "us" => (0u64, n.mul(1000)?),
               "millis" | "msec" | "ms" => (0u64, n.mul(1_000_000)?),
               "seconds" | "second" | "secs" | "sec" | "s" => (n, 0),
               "minutes" | "minute" | "min" | "mins" | "m"
               => (n.mul(60)?, 0),
               "hours" | "hour" | "hr" | "hrs" | "h" => (n.mul(3600)?, 0),
               "days" | "day" | "d" => (n.mul(86400)?, 0),
               "weeks" | "week" | "w" => (n.mul(86400*7)?, 0),
               "months" | "month" | "M" => (n.mul(2_630_016)?, 0), // 30.44d
               "years" | "year" | "y" => (n.mul(31_557_600)?, 0), // 365.25d
               _ => {
                   return Err(Error::UnknownUnit {
                       start, end,
                       unit: self.src[start..end].to_string(),
                       value: n,
                   });
               }
           };
   ```
   
   Jiff's "friendly" duration format has a 
[grammar](https://docs.rs/jiff/latest/jiff/fmt/friendly/index.html#grammar), 
and indeed, for hour/minute/second/millisecond/microsecond/nanosecond units, 
Jiff can parse all of the units that `humantime` can parse (plus more, 
including things like `µs`. In general, in terms of things that `humantime` can 
parse but Jiff can't, I believe the only thing is `M` for months. Jiff requires 
at least `mo` or `mos`.
   
   The other direction is different, that is, can `humantime` parse what Jiff 
outputs. I'm not sure if you need that form of compatibility, but if you do, 
Jiff has a special [`HumanTime` 
mode](https://docs.rs/jiff/latest/jiff/fmt/friendly/enum.Designator.html#variant.HumanTime)
 for it.


-- 
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