@@ -3,11 +3,8 @@ use clap::{
33 builder:: { PossibleValue , TypedValueParser } ,
44 error:: { ContextKind , ContextValue , ErrorKind } ,
55} ;
6- use std:: {
7- ffi:: OsStr ,
8- fmt,
9- time:: { Duration , SystemTime } ,
10- } ;
6+ use core:: time:: Duration ;
7+ use std:: { ffi:: OsStr , fmt, time:: SystemTime } ;
118
129#[ derive( Debug , Clone , PartialEq , Eq ) ]
1310#[ allow( clippy:: exhaustive_enums) ]
@@ -61,7 +58,7 @@ pub enum TimeFilter {
6158
6259impl TimeFilter {
6360 /**
64- Parses a time string and returns a `TimeFilter`
61+ Parses a time string and returns a `TimeFilter`.
6562
6663 # Arguments
6764
@@ -75,6 +72,24 @@ impl TimeFilter {
7572 - `..` separator: between two times (e.g., "2d..1d" = files modified between 2 days and 1 day ago)
7673 - Supported units: s (seconds), m (minutes), h (hours), d (days), w (weeks), y (years)
7774
75+ # Examples
76+
77+ ```
78+ use fdf::filters::TimeFilter;
79+
80+ // Files modified within the last hour
81+ let filter = TimeFilter::from_string("-1h").unwrap();
82+
83+ // Files modified more than 2 days ago
84+ let filter = TimeFilter::from_string("+2d").unwrap();
85+
86+ // Files modified between 2 days and 1 day ago
87+ let filter = TimeFilter::from_string("2d..1d").unwrap();
88+ ```
89+
90+ # Errors
91+
92+ Returns `ParseTimeError::InvalidFormat` if the string cannot be parsed or is in an invalid format.
7893 */
7994 pub fn from_string ( s : & str ) -> Result < Self , ParseTimeError > {
8095 Self :: parse_args ( s) . ok_or ( ParseTimeError :: InvalidFormat )
0 commit comments