Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of samples #27

Open
Wandalen opened this issue Jun 6, 2022 · 1 comment
Open

Lack of samples #27

Wandalen opened this issue Jun 6, 2022 · 1 comment

Comments

@Wandalen
Copy link

Wandalen commented Jun 6, 2022

Thanks for open source. Any samples?

@schneiderfelipe
Copy link

Do you mean something like tests

humantime/src/duration.rs

Lines 345 to 379 in 12ce6f5

assert_eq!(parse_duration("17nsec"), Ok(Duration::new(0, 17)));
assert_eq!(parse_duration("17nanos"), Ok(Duration::new(0, 17)));
assert_eq!(parse_duration("33ns"), Ok(Duration::new(0, 33)));
assert_eq!(parse_duration("3usec"), Ok(Duration::new(0, 3000)));
assert_eq!(parse_duration("78us"), Ok(Duration::new(0, 78000)));
assert_eq!(parse_duration("31msec"), Ok(Duration::new(0, 31_000_000)));
assert_eq!(parse_duration("31millis"), Ok(Duration::new(0, 31_000_000)));
assert_eq!(parse_duration("6ms"), Ok(Duration::new(0, 6_000_000)));
assert_eq!(parse_duration("3000s"), Ok(Duration::new(3000, 0)));
assert_eq!(parse_duration("300sec"), Ok(Duration::new(300, 0)));
assert_eq!(parse_duration("300secs"), Ok(Duration::new(300, 0)));
assert_eq!(parse_duration("50seconds"), Ok(Duration::new(50, 0)));
assert_eq!(parse_duration("1second"), Ok(Duration::new(1, 0)));
assert_eq!(parse_duration("100m"), Ok(Duration::new(6000, 0)));
assert_eq!(parse_duration("12min"), Ok(Duration::new(720, 0)));
assert_eq!(parse_duration("12mins"), Ok(Duration::new(720, 0)));
assert_eq!(parse_duration("1minute"), Ok(Duration::new(60, 0)));
assert_eq!(parse_duration("7minutes"), Ok(Duration::new(420, 0)));
assert_eq!(parse_duration("2h"), Ok(Duration::new(7200, 0)));
assert_eq!(parse_duration("7hr"), Ok(Duration::new(25200, 0)));
assert_eq!(parse_duration("7hrs"), Ok(Duration::new(25200, 0)));
assert_eq!(parse_duration("1hour"), Ok(Duration::new(3600, 0)));
assert_eq!(parse_duration("24hours"), Ok(Duration::new(86400, 0)));
assert_eq!(parse_duration("1day"), Ok(Duration::new(86400, 0)));
assert_eq!(parse_duration("2days"), Ok(Duration::new(172_800, 0)));
assert_eq!(parse_duration("365d"), Ok(Duration::new(31_536_000, 0)));
assert_eq!(parse_duration("1week"), Ok(Duration::new(604_800, 0)));
assert_eq!(parse_duration("7weeks"), Ok(Duration::new(4_233_600, 0)));
assert_eq!(parse_duration("52w"), Ok(Duration::new(31_449_600, 0)));
assert_eq!(parse_duration("1month"), Ok(Duration::new(2_630_016, 0)));
assert_eq!(parse_duration("3months"), Ok(Duration::new(3*2_630_016, 0)));
assert_eq!(parse_duration("12M"), Ok(Duration::new(31_560_192, 0)));
assert_eq!(parse_duration("1year"), Ok(Duration::new(31_557_600, 0)));
assert_eq!(parse_duration("7years"), Ok(Duration::new(7*31_557_600, 0)));
assert_eq!(parse_duration("17y"), Ok(Duration::new(536_479_200, 0)));

or

humantime/src/duration.rs

Lines 384 to 385 in 12ce6f5

assert_eq!(parse_duration("20 min 17 nsec "), Ok(Duration::new(1200, 17)));
assert_eq!(parse_duration("2h 15m"), Ok(Duration::new(8100, 0)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants