Crates.io | nichi |
lib.rs | nichi |
version | 0.5.1 |
source | src |
created_at | 2023-10-19 01:47:36.438542 |
updated_at | 2023-12-04 02:50:35.807554 |
description | Date library |
homepage | |
repository | https://github.com/hinto-janai/nichi |
max_upload_size | |
id | 1007415 |
size | 136,552 |
nichi
Date library.
use nichi::*;
// PartialEq.
let date1 = Date::new(2000, 12, 25);
let date2 = Date::new_typed(
Year(2000),
Month::December,
Day::TwentyFifth,
);
assert_eq!(date1, date2);
use nichi::*;
// Christmas in 2000 was on a Monday.
assert_eq!(Date::new(2000, 12, 25).weekday(), Weekday::Monday);
# use nichi::*;
let date = Date::new(2023, 10, 20);
assert_eq!(date.as_unix(), 1697760000);
assert_eq!(date, Date::from_unix(date.as_unix()));
use nichi::*;
assert_eq!(Day::from_str("1st").unwrap(), Day::First);
assert_eq!(Day::from_str("first").unwrap(), Day::First);
assert_eq!(Day::from_str("FIRST").unwrap(), Day::First);
assert_eq!(Day::from_str("10TH").unwrap(), Day::Tenth);
assert_eq!(Day::from_str("tenth").unwrap(), Day::Tenth);
assert_eq!(Day::from_str("Tenth").unwrap(), Day::Tenth);
assert_eq!(Weekday::from_str("Tuesday").unwrap(), Weekday::Tuesday);
assert_eq!(Weekday::from_str("wed").unwrap(), Weekday::Wednesday);
assert_eq!(Weekday::from_str("WEDNESDAY").unwrap(), Weekday::Wednesday);
assert_eq!(Weekday::from_str("Wednesday").unwrap(), Weekday::Wednesday);
assert_eq!(Weekday::from_str("THURS").unwrap(), Weekday::Thursday);
assert_eq!(Weekday::from_str("thurs").unwrap(), Weekday::Thursday);
assert_eq!(Weekday::from_str("THUR").unwrap(), Weekday::Thursday);
assert_eq!(Weekday::from_str("thursday").unwrap(), Weekday::Thursday);
assert_eq!(Month::from_str("January").unwrap(), Month::January);
assert_eq!(Month::from_str("February").unwrap(), Month::February);
assert_eq!(Month::from_str("FEBRUARY").unwrap(), Month::February);
assert_eq!(Month::from_str("JUN").unwrap(), Month::June);
assert_eq!(Month::from_str("July").unwrap(), Month::July);
assert_eq!(Month::from_str("Jul").unwrap(), Month::July);
assert_eq!(Month::from_str("NOVEMBER").unwrap(), Month::November);
assert_eq!(Month::from_str("nov").unwrap(), Month::November);
assert_eq!(Month::from_str("DEC").unwrap(), Month::December);