|
3 | 3 | // For the full copyright and license information, please view the LICENSE |
4 | 4 | // file that was distributed with this source code. |
5 | 5 |
|
6 | | -// spell-checker:ignore (ToDO) kqueue Signum fundu |
| 6 | +// spell-checker:ignore (ToDO) kqueue Signum |
7 | 7 |
|
8 | 8 | use crate::paths::Input; |
9 | 9 | use crate::{Quotable, parse, platform}; |
10 | 10 | use clap::{Arg, ArgAction, ArgMatches, Command, value_parser}; |
11 | | -use fundu::{DurationParser, SaturatingInto}; |
12 | 11 | use same_file::Handle; |
13 | 12 | use std::ffi::OsString; |
14 | 13 | use std::io::IsTerminal; |
15 | 14 | use std::time::Duration; |
16 | 15 | use uucore::error::{UResult, USimpleError, UUsageError}; |
17 | 16 | use uucore::parser::parse_size::{ParseSizeError, parse_size_u64}; |
| 17 | +use uucore::parser::parse_time; |
18 | 18 | use uucore::parser::shortcut_value_parser::ShortcutValueParser; |
19 | 19 | use uucore::{format_usage, help_about, help_usage, show_warning}; |
20 | 20 |
|
@@ -228,22 +228,9 @@ impl Settings { |
228 | 228 | }; |
229 | 229 |
|
230 | 230 | if let Some(source) = matches.get_one::<String>(options::SLEEP_INT) { |
231 | | - // Advantage of `fundu` over `Duration::(try_)from_secs_f64(source.parse().unwrap())`: |
232 | | - // * doesn't panic on errors like `Duration::from_secs_f64` would. |
233 | | - // * no precision loss, rounding errors or other floating point problems. |
234 | | - // * evaluates to `Duration::MAX` if the parsed number would have exceeded |
235 | | - // `DURATION::MAX` or `infinity` was given |
236 | | - // * not applied here but it supports customizable time units and provides better error |
237 | | - // messages |
238 | | - settings.sleep_sec = match DurationParser::without_time_units().parse(source) { |
239 | | - Ok(duration) => SaturatingInto::<Duration>::saturating_into(duration), |
240 | | - Err(_) => { |
241 | | - return Err(UUsageError::new( |
242 | | - 1, |
243 | | - format!("invalid number of seconds: '{source}'"), |
244 | | - )); |
245 | | - } |
246 | | - } |
| 231 | + settings.sleep_sec = parse_time::from_str(source, false).map_err(|_| { |
| 232 | + UUsageError::new(1, format!("invalid number of seconds: '{source}'")) |
| 233 | + })?; |
247 | 234 | } |
248 | 235 |
|
249 | 236 | if let Some(s) = matches.get_one::<String>(options::MAX_UNCHANGED_STATS) { |
|
0 commit comments