From f6d5e7ec7c0e0501edf520a54c07d2ca91123a39 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 17 Jan 2025 02:07:10 +0900 Subject: [PATCH 01/69] chore(deps): Update dependencies --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee07014..f5b8233 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitflags" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "byteorder" From 3cfaf30fabdd94944c5af0b592f2fdbaf066d3cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:26:33 +0000 Subject: [PATCH 02/69] chore(deps): Bump serde_json from 1.0.135 to 1.0.137 (#283) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.135 to 1.0.137. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.135...v1.0.137) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5b8233..892b2b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,9 +454,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 28be054..187aa2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ anyhow = "1.0.95" clap = { version = "4.3.24", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" -serde_json = "1.0.135" +serde_json = "1.0.137" serde_test = "1.0.177" test-strategy = "0.3.1" time = { version = "0.3.37", features = ["parsing"] } From 847d01c06c56678d734a94bd47410060d85d5c65 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 22 Jan 2025 03:14:47 +0900 Subject: [PATCH 03/69] chore: Change order of `features` --- Cargo.toml | 4 ++-- README.md | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 187aa2d..62d83d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,11 +71,11 @@ time = { version = "0.3.37", features = ["parsing"] } [features] default = ["std"] chrono = ["dep:chrono"] +large-dates = ["time/large-dates"] rand = ["dep:rand"] serde = ["dep:serde"] -std = ["chrono?/std", "rand?/std", "time/std"] -large-dates = ["time/large-dates"] serde-human-readable = ["serde", "time/serde-human-readable"] +std = ["chrono?/std", "rand?/std", "time/std"] [lints.clippy] cargo = "warn" diff --git a/README.md b/README.md index 93f63d0..1ae7e72 100644 --- a/README.md +++ b/README.md @@ -36,19 +36,14 @@ nt-time = "0.10.6" ### Crate features -#### `std` +#### `chrono` -Enables features that depend on the standard library. This is enabled by -default. +Enables the [`chrono`] crate. #### `large-dates` Enables the `large-dates` feature of the [`time`] crate. -#### `chrono` - -Enables the [`chrono`] crate. - #### `rand` Enables the [`rand`] crate. @@ -62,6 +57,11 @@ Enables the [`serde`] crate. Allows Serde representations to use a human-readable format. This implicitly enables the `serde` feature. +#### `std` + +Enables features that depend on the standard library. This is enabled by +default. + ### `no_std` support This supports `no_std` mode. Disables the `default` feature to enable this. From 857ae6b904673d8e2561cf93d997e43c7665b555 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Thu, 23 Jan 2025 01:51:37 +0900 Subject: [PATCH 04/69] chore: Update `dos_date_time.rs` --- src/file_time/dos_date_time.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/file_time/dos_date_time.rs b/src/file_time/dos_date_time.rs index 92c0bf9..d6030eb 100644 --- a/src/file_time/dos_date_time.rs +++ b/src/file_time/dos_date_time.rs @@ -141,23 +141,18 @@ impl FileTime { match dt.year() { ..=1979 => Err(DosDateTimeRangeErrorKind::Negative.into()), 2108.. => Err(DosDateTimeRangeErrorKind::Overflow.into()), - _ => { - let (date, time) = (dt.date(), dt.time()); - + year => { let (year, month, day) = ( - date.year() - 1980, - i32::from(u8::from(date.month())), - i32::from(date.day()), + u16::try_from(year - 1980).expect("year should be in the range of `u16`"), + u16::from(u8::from(dt.month())), + u16::from(dt.day()), ); - let dos_date = ((year << 9) + (month << 5) + day) - .try_into() - .expect("the MS-DOS date should be in the range of `u16`"); + let date = (year << 9) | (month << 5) | day; - let (hour, minute, second) = (time.hour(), time.minute(), time.second() / 2); - let dos_time = - (u16::from(hour) << 11) + (u16::from(minute) << 5) + u16::from(second); + let (hour, minute, second) = (dt.hour(), dt.minute(), dt.second() / 2); + let time = (u16::from(hour) << 11) | (u16::from(minute) << 5) | u16::from(second); - let resolution = ((time + let resolution = ((dt.time() - Time::from_hms(hour, minute, second * 2) .expect("the MS-DOS time should be in the range of `Time`")) .whole_milliseconds() @@ -166,7 +161,7 @@ impl FileTime { .expect("resolution should be in the range of `u8`"); debug_assert!(resolution <= 199); - Ok((dos_date, dos_time, resolution, offset)) + Ok((date, time, resolution, offset)) } } } @@ -289,7 +284,7 @@ impl FileTime { } let (year, month, day) = ( - ((date >> 9) + 1980).into(), + (1980 + (date >> 9)).into(), u8::try_from((date >> 5) & 0x0f) .expect("month should be in the range of `u8`") .try_into()?, From a2364d1673d14ceb9220794675388c427e755b4b Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 24 Jan 2025 11:30:44 +0900 Subject: [PATCH 05/69] test: Update doctests . --- src/error.rs | 29 ++++------- src/file_time.rs | 14 +++--- src/file_time/convert.rs | 60 +++++++++++------------ src/file_time/dos_date_time.rs | 77 ++++++++++++----------------- src/file_time/unix_time.rs | 89 ++++++++++++++-------------------- src/lib.rs | 29 ++++++----- 6 files changed, 128 insertions(+), 170 deletions(-) diff --git a/src/error.rs b/src/error.rs index fdeaed7..24968e0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -29,17 +29,11 @@ impl DosDateTimeRangeError { /// ``` /// # use nt_time::{error::DosDateTimeRangeErrorKind, FileTime}; /// # - /// assert_eq!( - /// FileTime::NT_TIME_EPOCH - /// .to_dos_date_time(None) - /// .unwrap_err() - /// .kind(), - /// DosDateTimeRangeErrorKind::Negative - /// ); - /// assert_eq!( - /// FileTime::MAX.to_dos_date_time(None).unwrap_err().kind(), - /// DosDateTimeRangeErrorKind::Overflow - /// ); + /// let err = FileTime::NT_TIME_EPOCH.to_dos_date_time(None).unwrap_err(); + /// assert_eq!(err.kind(), DosDateTimeRangeErrorKind::Negative); + /// + /// let err = FileTime::MAX.to_dos_date_time(None).unwrap_err(); + /// assert_eq!(err.kind(), DosDateTimeRangeErrorKind::Overflow); /// ``` #[must_use] #[inline] @@ -114,14 +108,11 @@ impl FileTimeRangeError { /// ``` /// # use nt_time::{error::FileTimeRangeErrorKind, FileTime}; /// # - /// assert_eq!( - /// FileTime::from_unix_time_secs(i64::MIN).unwrap_err().kind(), - /// FileTimeRangeErrorKind::Negative - /// ); - /// assert_eq!( - /// FileTime::from_unix_time_secs(i64::MAX).unwrap_err().kind(), - /// FileTimeRangeErrorKind::Overflow - /// ); + /// let err = FileTime::from_unix_time_secs(i64::MIN).unwrap_err(); + /// assert_eq!(err.kind(), FileTimeRangeErrorKind::Negative); + /// + /// let err = FileTime::from_unix_time_secs(i64::MAX).unwrap_err(); + /// assert_eq!(err.kind(), FileTimeRangeErrorKind::Overflow); /// ``` #[must_use] #[inline] diff --git a/src/file_time.rs b/src/file_time.rs index 990f539..bcc0058 100644 --- a/src/file_time.rs +++ b/src/file_time.rs @@ -424,18 +424,18 @@ impl FromStr for FileTime { /// # /// # use nt_time::FileTime; /// # - /// assert_eq!(FileTime::from_str("0").unwrap(), FileTime::NT_TIME_EPOCH); + /// assert_eq!(FileTime::from_str("0"), Ok(FileTime::NT_TIME_EPOCH)); /// assert_eq!( - /// FileTime::from_str("116444736000000000").unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::from_str("116444736000000000"), + /// Ok(FileTime::UNIX_EPOCH) /// ); /// assert_eq!( - /// FileTime::from_str("+9223372036854775807").unwrap(), - /// FileTime::SIGNED_MAX + /// FileTime::from_str("+9223372036854775807"), + /// Ok(FileTime::SIGNED_MAX) /// ); /// assert_eq!( - /// FileTime::from_str("+18446744073709551615").unwrap(), - /// FileTime::MAX + /// FileTime::from_str("+18446744073709551615"), + /// Ok(FileTime::MAX) /// ); /// /// assert!(FileTime::from_str("").is_err()); diff --git a/src/file_time/convert.rs b/src/file_time/convert.rs index 0428897..983c21c 100644 --- a/src/file_time/convert.rs +++ b/src/file_time/convert.rs @@ -51,12 +51,12 @@ impl TryFrom for i64 { /// ``` /// # use nt_time::FileTime; /// # - /// assert_eq!(i64::try_from(FileTime::NT_TIME_EPOCH).unwrap(), 0); + /// assert_eq!(i64::try_from(FileTime::NT_TIME_EPOCH), Ok(0)); /// assert_eq!( - /// i64::try_from(FileTime::UNIX_EPOCH).unwrap(), - /// 116_444_736_000_000_000 + /// i64::try_from(FileTime::UNIX_EPOCH), + /// Ok(116_444_736_000_000_000) /// ); - /// assert_eq!(i64::try_from(FileTime::SIGNED_MAX).unwrap(), i64::MAX); + /// assert_eq!(i64::try_from(FileTime::SIGNED_MAX), Ok(i64::MAX)); /// /// assert!(i64::try_from(FileTime::MAX).is_err()); /// ``` @@ -128,12 +128,12 @@ impl TryFrom for OffsetDateTime { /// # }; /// # /// assert_eq!( - /// OffsetDateTime::try_from(FileTime::NT_TIME_EPOCH).unwrap(), - /// datetime!(1601-01-01 00:00 UTC) + /// OffsetDateTime::try_from(FileTime::NT_TIME_EPOCH), + /// Ok(datetime!(1601-01-01 00:00 UTC)) /// ); /// assert_eq!( - /// OffsetDateTime::try_from(FileTime::UNIX_EPOCH).unwrap(), - /// OffsetDateTime::UNIX_EPOCH + /// OffsetDateTime::try_from(FileTime::UNIX_EPOCH), + /// Ok(OffsetDateTime::UNIX_EPOCH) /// ); /// ``` /// @@ -160,16 +160,16 @@ impl TryFrom for OffsetDateTime { /// # }; /// # /// assert_eq!( - /// OffsetDateTime::try_from(FileTime::new(2_650_467_744_000_000_000)).unwrap(), - /// datetime!(+10000-01-01 00:00 UTC) + /// OffsetDateTime::try_from(FileTime::new(2_650_467_744_000_000_000)), + /// Ok(datetime!(+10000-01-01 00:00 UTC)) /// ); /// assert_eq!( - /// OffsetDateTime::try_from(FileTime::SIGNED_MAX).unwrap(), - /// datetime!(+30828-09-14 02:48:05.477_580_700 UTC) + /// OffsetDateTime::try_from(FileTime::SIGNED_MAX), + /// Ok(datetime!(+30828-09-14 02:48:05.477_580_700 UTC)) /// ); /// assert_eq!( - /// OffsetDateTime::try_from(FileTime::MAX).unwrap(), - /// datetime!(+60056-05-28 05:36:10.955_161_500 UTC) + /// OffsetDateTime::try_from(FileTime::MAX), + /// Ok(datetime!(+60056-05-28 05:36:10.955_161_500 UTC)) /// ); /// # } /// ``` @@ -251,12 +251,12 @@ impl TryFrom for FileTime { /// ``` /// # use nt_time::FileTime; /// # - /// assert_eq!(FileTime::try_from(0_i64).unwrap(), FileTime::NT_TIME_EPOCH); + /// assert_eq!(FileTime::try_from(0_i64), Ok(FileTime::NT_TIME_EPOCH)); /// assert_eq!( - /// FileTime::try_from(116_444_736_000_000_000_i64).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::try_from(116_444_736_000_000_000_i64), + /// Ok(FileTime::UNIX_EPOCH) /// ); - /// assert_eq!(FileTime::try_from(i64::MAX).unwrap(), FileTime::SIGNED_MAX); + /// assert_eq!(FileTime::try_from(i64::MAX), Ok(FileTime::SIGNED_MAX)); /// /// assert!(FileTime::try_from(i64::MIN).is_err()); /// ``` @@ -290,12 +290,12 @@ impl TryFrom for FileTime { /// # use nt_time::FileTime; /// # /// assert_eq!( - /// FileTime::try_from(SystemTime::UNIX_EPOCH - Duration::from_secs(11_644_473_600)).unwrap(), - /// FileTime::NT_TIME_EPOCH + /// FileTime::try_from(SystemTime::UNIX_EPOCH - Duration::from_secs(11_644_473_600)), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); /// assert_eq!( - /// FileTime::try_from(SystemTime::UNIX_EPOCH).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::try_from(SystemTime::UNIX_EPOCH), + /// Ok(FileTime::UNIX_EPOCH) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. @@ -341,12 +341,12 @@ impl TryFrom for FileTime { /// # }; /// # /// assert_eq!( - /// FileTime::try_from(datetime!(1601-01-01 00:00 UTC)).unwrap(), - /// FileTime::NT_TIME_EPOCH + /// FileTime::try_from(datetime!(1601-01-01 00:00 UTC)), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); /// assert_eq!( - /// FileTime::try_from(OffsetDateTime::UNIX_EPOCH).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::try_from(OffsetDateTime::UNIX_EPOCH), + /// Ok(FileTime::UNIX_EPOCH) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. @@ -398,12 +398,12 @@ impl TryFrom> for FileTime { /// # }; /// # /// assert_eq!( - /// FileTime::try_from("1601-01-01 00:00:00 UTC".parse::>().unwrap()).unwrap(), - /// FileTime::NT_TIME_EPOCH + /// FileTime::try_from("1601-01-01 00:00:00 UTC".parse::>().unwrap()), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); /// assert_eq!( - /// FileTime::try_from(DateTime::::UNIX_EPOCH).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::try_from(DateTime::::UNIX_EPOCH), + /// Ok(FileTime::UNIX_EPOCH) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. diff --git a/src/file_time/dos_date_time.rs b/src/file_time/dos_date_time.rs index d6030eb..8a28d5a 100644 --- a/src/file_time/dos_date_time.rs +++ b/src/file_time/dos_date_time.rs @@ -55,17 +55,13 @@ impl FileTime { /// # /// // `1980-01-01 00:00:00 UTC`. /// assert_eq!( - /// FileTime::new(119_600_064_000_000_000) - /// .to_dos_date_time(None) - /// .unwrap(), - /// (0x0021, u16::MIN, u8::MIN, None) + /// FileTime::new(119_600_064_000_000_000).to_dos_date_time(None), + /// Ok((0x0021, u16::MIN, u8::MIN, None)) /// ); /// // `2107-12-31 23:59:59 UTC`. /// assert_eq!( - /// FileTime::new(159_992_927_990_000_000) - /// .to_dos_date_time(None) - /// .unwrap(), - /// (0xff9f, 0xbf7d, 100, None) + /// FileTime::new(159_992_927_990_000_000).to_dos_date_time(None), + /// Ok((0xff9f, 0xbf7d, 100, None)) /// ); /// /// // Before `1980-01-01 00:00:00 UTC`. @@ -79,10 +75,8 @@ impl FileTime { /// /// // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:25:00 -08:00`. /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000) - /// .to_dos_date_time(Some(offset!(-08:00))) - /// .unwrap(), - /// (0x2d7a, 0x9b20, u8::MIN, Some(offset!(-08:00))) + /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:00))), + /// Ok((0x2d7a, 0x9b20, u8::MIN, Some(offset!(-08:00)))) /// ); /// ``` /// @@ -94,25 +88,19 @@ impl FileTime { /// # /// // `2002-11-27 03:25:00 UTC`. /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000) - /// .to_dos_date_time(Some(offset!(-08:01))) - /// .unwrap(), - /// (0x2d7b, 0x1b20, u8::MIN, None) + /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:01))), + /// Ok((0x2d7b, 0x1b20, u8::MIN, None)) /// ); /// // `2002-11-27 03:25:00 UTC`. /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000) - /// .to_dos_date_time(Some(offset!(-08:14))) - /// .unwrap(), - /// (0x2d7b, 0x1b20, u8::MIN, None) + /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:14))), + /// Ok((0x2d7b, 0x1b20, u8::MIN, None)) /// ); /// /// // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:10:00 -08:15`. /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000) - /// .to_dos_date_time(Some(offset!(-08:15))) - /// .unwrap(), - /// (0x2d7a, 0x9940, u8::MIN, Some(offset!(-08:15))) + /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:15))), + /// Ok((0x2d7a, 0x9940, u8::MIN, Some(offset!(-08:15)))) /// ); /// ``` /// @@ -202,19 +190,19 @@ impl FileTime { /// # /// // `1980-01-01 00:00:00 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0x0021, u16::MIN, None, None).unwrap(), - /// FileTime::new(119_600_064_000_000_000) + /// FileTime::from_dos_date_time(0x0021, u16::MIN, None, None), + /// Ok(FileTime::new(119_600_064_000_000_000)) /// ); /// // `2107-12-31 23:59:59 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0xff9f, 0xbf7d, Some(100), None).unwrap(), - /// FileTime::new(159_992_927_990_000_000) + /// FileTime::from_dos_date_time(0xff9f, 0xbf7d, Some(100), None), + /// Ok(FileTime::new(159_992_927_990_000_000)) /// ); /// /// // From `2002-11-26 19:25:00 -08:00` to `2002-11-27 03:25:00 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:00))).unwrap(), - /// FileTime::new(126_828_411_000_000_000) + /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:00))), + /// Ok(FileTime::new(126_828_411_000_000_000)) /// ); /// /// // The Day field is 0. @@ -231,19 +219,19 @@ impl FileTime { /// # /// // From `2002-11-26 19:25:00 -08:01` to `2002-11-26 19:25:00 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:01))).unwrap(), - /// FileTime::new(126_828_123_000_000_000) + /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:01))), + /// Ok(FileTime::new(126_828_123_000_000_000)) /// ); /// // From `2002-11-26 19:25:00 -08:14` to `2002-11-26 19:25:00 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:14))).unwrap(), - /// FileTime::new(126_828_123_000_000_000) + /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:14))), + /// Ok(FileTime::new(126_828_123_000_000_000)) /// ); /// /// // From `2002-11-26 19:25:00 -08:15` to `2002-11-27 03:40:00 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:15))).unwrap(), - /// FileTime::new(126_828_420_000_000_000) + /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:15))), + /// Ok(FileTime::new(126_828_420_000_000_000)) /// ); /// ``` /// @@ -252,7 +240,7 @@ impl FileTime { /// ```should_panic /// # use nt_time::FileTime; /// # - /// let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, Some(200), None).unwrap(); + /// let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, Some(200), None); /// ``` /// /// [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time @@ -571,18 +559,14 @@ mod tests { #[should_panic] fn to_dos_date_time_with_invalid_positive_offset() { // From `1980-01-01 00:00:00 UTC` to `1980-01-01 16:00:00 +16:00`. - let _ = FileTime::new(119_600_064_000_000_000) - .to_dos_date_time(Some(offset!(+16:00))) - .unwrap(); + let _ = FileTime::new(119_600_064_000_000_000).to_dos_date_time(Some(offset!(+16:00))); } #[test] #[should_panic] fn to_dos_date_time_with_invalid_negative_offset() { // From `2107-12-31 23:59:58 UTC` to `2107-12-31 07:44:58 -16:15`. - let _ = FileTime::new(159_992_927_980_000_000) - .to_dos_date_time(Some(offset!(-16:15))) - .unwrap(); + let _ = FileTime::new(159_992_927_980_000_000).to_dos_date_time(Some(offset!(-16:15))); } #[test] @@ -745,21 +729,20 @@ mod tests { #[test] #[should_panic] fn from_dos_date_time_with_invalid_resolution() { - let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, Some(200), None).unwrap(); + let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, Some(200), None); } #[test] #[should_panic] fn from_dos_date_time_with_invalid_positive_offset() { // From `2107-12-31 23:59:58 +16:00` to `2107-12-31 07:59:58 UTC`. - let _ = FileTime::from_dos_date_time(0xff9f, 0xbf7d, None, Some(offset!(+16:00))).unwrap(); + let _ = FileTime::from_dos_date_time(0xff9f, 0xbf7d, None, Some(offset!(+16:00))); } #[test] #[should_panic] fn from_dos_date_time_with_invalid_negative_offset() { // From `1980-01-01 00:00:00 -16:15` to `1980-01-01 16:15:00 UTC`. - let _ = - FileTime::from_dos_date_time(0x0021, u16::MIN, None, Some(offset!(-16:15))).unwrap(); + let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, None, Some(offset!(-16:15))); } } diff --git a/src/file_time/unix_time.rs b/src/file_time/unix_time.rs index 0c9c8b6..81d90fb 100644 --- a/src/file_time/unix_time.rs +++ b/src/file_time/unix_time.rs @@ -194,26 +194,23 @@ impl FileTime { /// # use nt_time::FileTime; /// # /// assert_eq!( - /// FileTime::from_unix_time(-11_644_473_600, 0).unwrap(), - /// FileTime::NT_TIME_EPOCH + /// FileTime::from_unix_time(-11_644_473_600, 0), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); + /// assert_eq!(FileTime::from_unix_time(0, 0), Ok(FileTime::UNIX_EPOCH)); /// assert_eq!( - /// FileTime::from_unix_time(0, 0).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::from_unix_time(910_692_730_085, 477_580_700), + /// Ok(FileTime::SIGNED_MAX) /// ); /// assert_eq!( - /// FileTime::from_unix_time(910_692_730_085, 477_580_700).unwrap(), - /// FileTime::SIGNED_MAX - /// ); - /// assert_eq!( - /// FileTime::from_unix_time(1_833_029_933_770, 955_161_500).unwrap(), - /// FileTime::MAX + /// FileTime::from_unix_time(1_833_029_933_770, 955_161_500), + /// Ok(FileTime::MAX) /// ); /// /// // The number of nanoseconds is greater than 1 billion. /// assert_eq!( - /// FileTime::from_unix_time(0, 1_000_000_000).unwrap(), - /// FileTime::from_unix_time(1, 0).unwrap() + /// FileTime::from_unix_time(0, 1_000_000_000), + /// FileTime::from_unix_time(1, 0) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. @@ -246,20 +243,17 @@ impl FileTime { /// # use nt_time::FileTime; /// # /// assert_eq!( - /// FileTime::from_unix_time_secs(-11_644_473_600).unwrap(), - /// FileTime::NT_TIME_EPOCH + /// FileTime::from_unix_time_secs(-11_644_473_600), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); + /// assert_eq!(FileTime::from_unix_time_secs(0), Ok(FileTime::UNIX_EPOCH)); /// assert_eq!( - /// FileTime::from_unix_time_secs(0).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::from_unix_time_secs(910_692_730_085), + /// Ok(FileTime::SIGNED_MAX - Duration::from_nanos(477_580_700)) /// ); /// assert_eq!( - /// FileTime::from_unix_time_secs(910_692_730_085).unwrap(), - /// FileTime::SIGNED_MAX - Duration::from_nanos(477_580_700) - /// ); - /// assert_eq!( - /// FileTime::from_unix_time_secs(1_833_029_933_770).unwrap(), - /// FileTime::MAX - Duration::from_nanos(955_161_500) + /// FileTime::from_unix_time_secs(1_833_029_933_770), + /// Ok(FileTime::MAX - Duration::from_nanos(955_161_500)) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. @@ -295,20 +289,17 @@ impl FileTime { /// # use nt_time::FileTime; /// # /// assert_eq!( - /// FileTime::from_unix_time_millis(-11_644_473_600_000).unwrap(), - /// FileTime::NT_TIME_EPOCH - /// ); - /// assert_eq!( - /// FileTime::from_unix_time_millis(0).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::from_unix_time_millis(-11_644_473_600_000), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); + /// assert_eq!(FileTime::from_unix_time_millis(0), Ok(FileTime::UNIX_EPOCH)); /// assert_eq!( - /// FileTime::from_unix_time_millis(910_692_730_085_477).unwrap(), - /// FileTime::SIGNED_MAX - Duration::from_nanos(580_700) + /// FileTime::from_unix_time_millis(910_692_730_085_477), + /// Ok(FileTime::SIGNED_MAX - Duration::from_nanos(580_700)) /// ); /// assert_eq!( - /// FileTime::from_unix_time_millis(1_833_029_933_770_955).unwrap(), - /// FileTime::MAX - Duration::from_nanos(161_500) + /// FileTime::from_unix_time_millis(1_833_029_933_770_955), + /// Ok(FileTime::MAX - Duration::from_nanos(161_500)) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. @@ -338,20 +329,17 @@ impl FileTime { /// # use nt_time::FileTime; /// # /// assert_eq!( - /// FileTime::from_unix_time_micros(-11_644_473_600_000_000).unwrap(), - /// FileTime::NT_TIME_EPOCH - /// ); - /// assert_eq!( - /// FileTime::from_unix_time_micros(0).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::from_unix_time_micros(-11_644_473_600_000_000), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); + /// assert_eq!(FileTime::from_unix_time_micros(0), Ok(FileTime::UNIX_EPOCH)); /// assert_eq!( - /// FileTime::from_unix_time_micros(910_692_730_085_477_580).unwrap(), - /// FileTime::SIGNED_MAX - Duration::from_nanos(700) + /// FileTime::from_unix_time_micros(910_692_730_085_477_580), + /// Ok(FileTime::SIGNED_MAX - Duration::from_nanos(700)) /// ); /// assert_eq!( - /// FileTime::from_unix_time_micros(1_833_029_933_770_955_161).unwrap(), - /// FileTime::MAX - Duration::from_nanos(500) + /// FileTime::from_unix_time_micros(1_833_029_933_770_955_161), + /// Ok(FileTime::MAX - Duration::from_nanos(500)) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. @@ -379,20 +367,17 @@ impl FileTime { /// # use nt_time::FileTime; /// # /// assert_eq!( - /// FileTime::from_unix_time_nanos(-11_644_473_600_000_000_000).unwrap(), - /// FileTime::NT_TIME_EPOCH - /// ); - /// assert_eq!( - /// FileTime::from_unix_time_nanos(0).unwrap(), - /// FileTime::UNIX_EPOCH + /// FileTime::from_unix_time_nanos(-11_644_473_600_000_000_000), + /// Ok(FileTime::NT_TIME_EPOCH) /// ); + /// assert_eq!(FileTime::from_unix_time_nanos(0), Ok(FileTime::UNIX_EPOCH)); /// assert_eq!( - /// FileTime::from_unix_time_nanos(910_692_730_085_477_580_700).unwrap(), - /// FileTime::SIGNED_MAX + /// FileTime::from_unix_time_nanos(910_692_730_085_477_580_700), + /// Ok(FileTime::SIGNED_MAX) /// ); /// assert_eq!( - /// FileTime::from_unix_time_nanos(1_833_029_933_770_955_161_500).unwrap(), - /// FileTime::MAX + /// FileTime::from_unix_time_nanos(1_833_029_933_770_955_161_500), + /// Ok(FileTime::MAX) /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. diff --git a/src/lib.rs b/src/lib.rs index 3a2cb9f..281b30f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,19 +33,16 @@ //! //! let ft = FileTime::NT_TIME_EPOCH; //! assert_eq!( -//! OffsetDateTime::try_from(ft).unwrap(), -//! datetime!(1601-01-01 00:00 UTC) +//! OffsetDateTime::try_from(ft), +//! Ok(datetime!(1601-01-01 00:00 UTC)) //! ); //! //! let ft = ft + Duration::from_secs(11_644_473_600); -//! assert_eq!( -//! OffsetDateTime::try_from(ft).unwrap(), -//! OffsetDateTime::UNIX_EPOCH -//! ); +//! assert_eq!(OffsetDateTime::try_from(ft), Ok(OffsetDateTime::UNIX_EPOCH)); //! assert_eq!(ft.to_raw(), 116_444_736_000_000_000); //! //! // The practical largest file time. -//! assert_eq!(FileTime::try_from(i64::MAX).unwrap(), FileTime::SIGNED_MAX); +//! assert_eq!(FileTime::try_from(i64::MAX), Ok(FileTime::SIGNED_MAX)); //! // The theoretical largest file time. //! assert_eq!(FileTime::new(u64::MAX), FileTime::MAX); //! ``` @@ -66,8 +63,8 @@ //! // `1970-01-01 00:00:00 UTC`. //! let ut = i64::default(); //! assert_eq!( -//! OffsetDateTime::from_unix_timestamp(ut).unwrap(), -//! OffsetDateTime::UNIX_EPOCH +//! OffsetDateTime::from_unix_timestamp(ut), +//! Ok(OffsetDateTime::UNIX_EPOCH) //! ); //! //! let ft = FileTime::from_unix_time_secs(ut).unwrap(); @@ -75,8 +72,11 @@ //! //! // `1980-01-01 00:00:00 UTC`. //! let ft = ft + Duration::from_secs(315_532_800); -//! let dos_dt = ft.to_dos_date_time(Some(UtcOffset::UTC)).unwrap(); -//! assert_eq!(dos_dt, (0x0021, u16::MIN, u8::MIN, Some(UtcOffset::UTC))); +//! let dos_dt = ft.to_dos_date_time(Some(UtcOffset::UTC)); +//! assert_eq!( +//! dos_dt, +//! Ok((0x0021, u16::MIN, u8::MIN, Some(UtcOffset::UTC))) +//! ); //! ``` //! //! ## Formatting and printing the file time @@ -91,10 +91,9 @@ //! //! let ft = FileTime::NT_TIME_EPOCH; //! assert_eq!(format!("{ft}"), "0"); -//! assert_eq!( -//! format!("{}", OffsetDateTime::try_from(ft).unwrap()), -//! "1601-01-01 0:00:00.0 +00:00:00" -//! ); +//! +//! let dt = OffsetDateTime::try_from(ft).unwrap(); +//! assert_eq!(format!("{dt}"), "1601-01-01 0:00:00.0 +00:00:00"); //! ``` //! //! [Windows file time]: https://docs.microsoft.com/en-us/windows/win32/sysinfo/file-times From 886a66fd3e82c3b6276e2ba0e799b38c342d7a38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:01:06 +0000 Subject: [PATCH 06/69] chore(deps): Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 (#287) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.2.0 to 2.3.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v2.2.0...v2.3.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot_auto_merge.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot_auto_merge.yaml b/.github/workflows/dependabot_auto_merge.yaml index 1efd5ae..716bdb9 100644 --- a/.github/workflows/dependabot_auto_merge.yaml +++ b/.github/workflows/dependabot_auto_merge.yaml @@ -18,7 +18,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v2.2.0 + uses: dependabot/fetch-metadata@v2.3.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Approve a PR From f069a6319bc70c34ed49e99bebe4a2d59136abf5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 09:37:02 +0000 Subject: [PATCH 07/69] chore(deps): Bump serde_json from 1.0.137 to 1.0.138 (#288) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.137 to 1.0.138. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.137...v1.0.138) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 892b2b8..561e5ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,9 +454,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.137" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 62d83d7..267aeb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ anyhow = "1.0.95" clap = { version = "4.3.24", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" -serde_json = "1.0.137" +serde_json = "1.0.138" serde_test = "1.0.177" test-strategy = "0.3.1" time = { version = "0.3.37", features = ["parsing"] } From 88172f61a6edd9ec4a438ecea612690d3cba89b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 06:01:32 +0900 Subject: [PATCH 08/69] chore(deps): Bump rand from 0.8.5 to 0.9.0 (#289) --- Cargo.lock | 140 ++++++++++++++++++++++++++++++++---------- Cargo.toml | 9 +-- src/file_time/rand.rs | 8 +-- 3 files changed, 115 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 561e5ec..d950d6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,7 +192,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", ] [[package]] @@ -209,13 +221,13 @@ checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "is-terminal" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -257,7 +269,7 @@ dependencies = [ "clap", "proptest", "proptest-derive", - "rand", + "rand 0.9.0", "serde", "serde_json", "serde_test", @@ -298,7 +310,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -321,8 +333,8 @@ dependencies = [ "bitflags", "lazy_static", "num-traits", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "rand_xorshift", "regex-syntax", "rusty-fork", @@ -363,8 +375,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.0", + "zerocopy 0.8.14", ] [[package]] @@ -374,7 +397,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.0", ] [[package]] @@ -383,7 +416,17 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", +] + +[[package]] +name = "rand_core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +dependencies = [ + "getrandom 0.3.1", + "zerocopy 0.8.14", ] [[package]] @@ -392,7 +435,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -403,9 +446,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags", "errno", @@ -428,9 +471,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "serde" @@ -504,9 +547,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -515,13 +558,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.15.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -578,9 +621,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "utf8parse" @@ -590,9 +633,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] @@ -604,21 +647,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "windows-sys" -version = "0.48.0" +name = "wasi" +version = "0.13.3+wasi-0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" dependencies = [ - "windows-targets 0.48.5", + "wit-bindgen-rt", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -751,6 +794,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -758,7 +810,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" +dependencies = [ + "zerocopy-derive 0.8.14", ] [[package]] @@ -771,3 +832,14 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zerocopy-derive" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 267aeb6..7965b52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.39", default-features = false, optional = true } -rand = { version = "0.8.5", default-features = false, optional = true } +rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.217", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.37", default-features = false, features = ["macros"] } @@ -78,9 +78,10 @@ serde-human-readable = ["serde", "time/serde-human-readable"] std = ["chrono?/std", "rand?/std", "time/std"] [lints.clippy] -cargo = "warn" -nursery = "warn" -pedantic = "warn" +cargo = { level = "warn", priority = -1 } +multiple_crate_versions = "allow" +nursery = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } [lints.rust] missing_debug_implementations = "deny" diff --git a/src/file_time/rand.rs b/src/file_time/rand.rs index 6ba0310..ef6f52f 100644 --- a/src/file_time/rand.rs +++ b/src/file_time/rand.rs @@ -5,16 +5,16 @@ //! Implementations of [`rand`] for [`FileTime`]. use rand::{ - distributions::{Distribution, Standard}, + distr::{Distribution, StandardUniform}, Rng, }; use super::FileTime; -impl Distribution for Standard { +impl Distribution for StandardUniform { #[inline] fn sample(&self, rng: &mut R) -> FileTime { - FileTime::new(rng.gen()) + FileTime::new(rng.random()) } } @@ -27,7 +27,7 @@ mod tests { #[test] fn sample() { let mut rng = StepRng::new(0, 1); - let buf: [FileTime; 4] = rng.gen(); + let buf: [FileTime; 4] = rng.random(); assert_eq!( buf, [ From 5c2ef8e7c3f3d707b2dad6bf215ef5eeac686e88 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 14 Feb 2025 18:21:40 +0900 Subject: [PATCH 09/69] chore: Update `parse.rs` (#291) --- examples/parse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/parse.rs b/examples/parse.rs index c983530..95ac2bd 100644 --- a/examples/parse.rs +++ b/examples/parse.rs @@ -38,7 +38,7 @@ struct Opt { } #[derive(Clone, Debug, Default, ValueEnum)] -pub enum Format { +enum Format { /// Underlying 64-bit unsigned integer value. #[default] Raw, From 60702812f2268e55c28992c96da4cc52e7a24a44 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 21 Feb 2025 00:53:47 +0900 Subject: [PATCH 10/69] docs: Update README --- .bumpversion.toml | 3 --- Cargo.toml | 2 -- README.md | 7 +++---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index d8c8877..5d24cd2 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -5,8 +5,5 @@ [tool.bumpversion] current_version = "0.10.6" -[[tool.bumpversion.files]] -filename = "README.md" - [[tool.bumpversion.files]] filename = "src/lib.rs" diff --git a/Cargo.toml b/Cargo.toml index 7965b52..2943a24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,6 @@ include = ["/LICENSES", "/README.md", "/src"] [package.metadata.docs.rs] all-features = true -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [[example]] name = "dos2ft" path = "examples/dos2ft.rs" diff --git a/README.md b/README.md index 1ae7e72..5c56daa 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,10 @@ underlying integer value. This is the largest file time accepted by the ## Usage -Add this to your `Cargo.toml`: +Run the following command in your project directory: -```toml -[dependencies] -nt-time = "0.10.6" +```sh +cargo add nt-time ``` ### Crate features From eee81a66d90430425253b43a96b5fcbb87829460 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 21 Feb 2025 03:45:28 +0900 Subject: [PATCH 11/69] chore: Update `rand.rs` (#293) --- benches/rand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benches/rand.rs b/benches/rand.rs index c079a09..93263c8 100644 --- a/benches/rand.rs +++ b/benches/rand.rs @@ -16,5 +16,5 @@ use test::Bencher; #[bench] fn sample(b: &mut Bencher) { let mut rng = StepRng::new(0, 1); - b.iter(|| rng.gen::()); + b.iter(|| rng.random::()); } From 0db82d553b90864a2aaacff4992de7c987a61c45 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 21 Feb 2025 17:04:42 +0900 Subject: [PATCH 12/69] chore: Migrate to Rust 2024 --- .github/workflows/CI.yaml | 4 +- CHANGELOG.adoc | 7 + Cargo.lock | 211 ++++++------------ Cargo.toml | 14 +- README.md | 2 +- benches/cmp.rs | 2 +- benches/convert.rs | 2 +- benches/ops.rs | 2 +- benches/rand.rs | 2 +- clippy.toml | 2 +- examples/dos2ft.rs | 2 +- examples/format.rs | 2 +- examples/ft2dos.rs | 2 +- examples/parse.rs | 4 +- rustfmt.toml | 3 +- src/error.rs | 41 ++-- src/file_time.rs | 23 +- src/file_time/consts.rs | 12 +- src/file_time/convert.rs | 83 ++++--- src/file_time/dos_date_time.rs | 26 ++- src/file_time/ops.rs | 2 +- src/file_time/rand.rs | 2 +- src/file_time/serde.rs | 10 +- src/file_time/unix_time.rs | 2 +- src/lib.rs | 6 +- src/serde_with/iso_8601.rs | 6 +- src/serde_with/iso_8601/option.rs | 8 +- src/serde_with/rfc_2822.rs | 6 +- src/serde_with/rfc_2822/option.rs | 8 +- src/serde_with/rfc_3339.rs | 6 +- src/serde_with/rfc_3339/option.rs | 8 +- src/serde_with/unix_time.rs | 6 +- src/serde_with/unix_time/microseconds.rs | 6 +- .../unix_time/microseconds/option.rs | 6 +- src/serde_with/unix_time/milliseconds.rs | 6 +- .../unix_time/milliseconds/option.rs | 6 +- src/serde_with/unix_time/nanoseconds.rs | 4 +- .../unix_time/nanoseconds/option.rs | 4 +- src/serde_with/unix_time/option.rs | 6 +- 39 files changed, 240 insertions(+), 314 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 0afe8fd..a936fa7 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -37,7 +37,7 @@ jobs: os: windows-2022 target: x86_64-pc-windows-msvc - toolchain-alias: msrv - toolchain: 1.67.1 + toolchain: 1.85.0 - toolchain-alias: stable toolchain: stable steps: @@ -90,7 +90,7 @@ jobs: os: windows-2022 target: x86_64-pc-windows-msvc - toolchain-alias: msrv - toolchain: 1.67.1 + toolchain: 1.85.0 - toolchain-alias: stable toolchain: stable steps: diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a332e06..de2acc3 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,13 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. +== {compare-url}/v0.10.6\...HEAD[Unreleased] + +=== Changed + +* Change MSRV to 1.85.0 ({pull-request-url}/294[#294]) +* Make `Error` trait available in `no_std` mode ({pull-request-url}/294[#294]) + == {compare-url}/v0.10.5\...v0.10.6[0.10.6] - 2025-01-14 === Changed diff --git a/Cargo.lock b/Cargo.lock index d950d6d..26ad7dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,19 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", + "is_terminal_polyfill", "utf8parse", ] @@ -38,24 +38,25 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "once_cell", + "windows-sys", ] [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" [[package]] name = "autocfg" @@ -107,20 +108,19 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.24" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" +checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.24" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" +checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" dependencies = [ "anstream", "anstyle", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck", "proc-macro2", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" @@ -169,7 +169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -204,31 +204,20 @@ dependencies = [ "cfg-if", "libc", "wasi 0.13.3+wasi-0.2.2", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] -name = "hermit-abi" -version = "0.4.0" +name = "is_terminal_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" - -[[package]] -name = "is-terminal" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.59.0", -] +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" @@ -294,9 +283,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "powerfmt" @@ -386,8 +375,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.0", - "zerocopy 0.8.14", + "rand_core 0.9.1", + "zerocopy 0.8.20", ] [[package]] @@ -407,7 +396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.0", + "rand_core 0.9.1", ] [[package]] @@ -421,12 +410,12 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.14", + "zerocopy 0.8.20", ] [[package]] @@ -454,7 +443,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -477,18 +466,18 @@ checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -497,9 +486,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" dependencies = [ "itoa", "memchr", @@ -518,15 +507,15 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "structmeta" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ad9e09554f0456d67a69c1584c9798ba733a5b50349a6c0d0948710523922d" +checksum = "2e1575d8d40908d70f6fd05537266b90ae71b15dbbe7a8b7dffa2b759306d329" dependencies = [ "proc-macro2", "quote", @@ -536,9 +525,9 @@ dependencies = [ [[package]] name = "structmeta-derive" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" +checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" dependencies = [ "proc-macro2", "quote", @@ -558,23 +547,23 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.16.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", "getrandom 0.3.1", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "test-strategy" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8361c808554228ad09bfed70f5c823caf8a3450b6881cc3a38eb57e8c08c1d9" +checksum = "2bf41af45e3f54cc184831d629d41d5b2bda8297e29c81add7ae4f362ed5e01b" dependencies = [ "proc-macro2", "quote", @@ -621,9 +610,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" [[package]] name = "utf8parse" @@ -655,37 +644,13 @@ dependencies = [ "wit-bindgen-rt", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -694,46 +659,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -746,48 +693,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -815,11 +738,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.14" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" +checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c" dependencies = [ - "zerocopy-derive 0.8.14", + "zerocopy-derive 0.8.20", ] [[package]] @@ -835,9 +758,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.14" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" +checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 2943a24..df8c543 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,8 @@ name = "nt-time" version = "0.10.6" authors = ["Shun Sakai "] -edition = "2021" -rust-version = "1.67.1" +edition = "2024" +rust-version = "1.85.0" description = "A Windows file time library" documentation = "https://docs.rs/nt-time" readme = "README.md" @@ -53,17 +53,17 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.39", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } -serde = { version = "1.0.217", default-features = false, features = ["derive"], optional = true } +serde = { version = "1.0.218", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.37", default-features = false, features = ["macros"] } [dev-dependencies] -anyhow = "1.0.95" -clap = { version = "4.3.24", features = ["derive"] } +anyhow = "1.0.96" +clap = { version = "4.5.30", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" -serde_json = "1.0.138" +serde_json = "1.0.139" serde_test = "1.0.177" -test-strategy = "0.3.1" +test-strategy = "0.4.0" time = { version = "0.3.37", features = ["parsing"] } [features] diff --git a/README.md b/README.md index 5c56daa..ae8f6b1 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ See the [documentation][docs-url] for more details. ## Minimum supported Rust version -The minimum supported Rust version (MSRV) of this library is v1.67.1. +The minimum supported Rust version (MSRV) of this library is v1.85.0. ## Source code diff --git a/benches/cmp.rs b/benches/cmp.rs index 8e42713..a065067 100644 --- a/benches/cmp.rs +++ b/benches/cmp.rs @@ -7,8 +7,8 @@ extern crate test; use nt_time::{ - time::{macros::datetime, OffsetDateTime}, FileTime, + time::{OffsetDateTime, macros::datetime}, }; use test::Bencher; diff --git a/benches/convert.rs b/benches/convert.rs index 7b35de4..92bed5b 100644 --- a/benches/convert.rs +++ b/benches/convert.rs @@ -6,7 +6,7 @@ extern crate test; -use nt_time::{time::OffsetDateTime, FileTime}; +use nt_time::{FileTime, time::OffsetDateTime}; use test::Bencher; #[bench] diff --git a/benches/ops.rs b/benches/ops.rs index 55fe8dd..eadf7b3 100644 --- a/benches/ops.rs +++ b/benches/ops.rs @@ -6,7 +6,7 @@ extern crate test; -use nt_time::{time::macros::datetime, FileTime}; +use nt_time::{FileTime, time::macros::datetime}; use test::Bencher; #[bench] diff --git a/benches/rand.rs b/benches/rand.rs index 93263c8..f571904 100644 --- a/benches/rand.rs +++ b/benches/rand.rs @@ -8,8 +8,8 @@ extern crate test; use nt_time::{ - rand::{rngs::mock::StepRng, Rng}, FileTime, + rand::{Rng, rngs::mock::StepRng}, }; use test::Bencher; diff --git a/clippy.toml b/clippy.toml index 956257c..f9d15ad 100644 --- a/clippy.toml +++ b/clippy.toml @@ -2,4 +2,4 @@ # # SPDX-License-Identifier: Apache-2.0 OR MIT -msrv = "1.67.1" +msrv = "1.85.0" diff --git a/examples/dos2ft.rs b/examples/dos2ft.rs index deac3ff..a509424 100644 --- a/examples/dos2ft.rs +++ b/examples/dos2ft.rs @@ -6,7 +6,7 @@ use anyhow::Context; use clap::Parser; -use nt_time::{time::UtcOffset, FileTime}; +use nt_time::{FileTime, time::UtcOffset}; #[derive(Debug, Parser)] #[command(version, about)] diff --git a/examples/format.rs b/examples/format.rs index 4c925bc..60f5d67 100644 --- a/examples/format.rs +++ b/examples/format.rs @@ -6,7 +6,7 @@ use anyhow::Context; use clap::Parser; -use nt_time::{time::OffsetDateTime, FileTime}; +use nt_time::{FileTime, time::OffsetDateTime}; #[derive(Debug, Parser)] #[command(version, about)] diff --git a/examples/ft2dos.rs b/examples/ft2dos.rs index 13e1685..3472fe4 100644 --- a/examples/ft2dos.rs +++ b/examples/ft2dos.rs @@ -6,7 +6,7 @@ use anyhow::Context; use clap::Parser; -use nt_time::{time::UtcOffset, FileTime}; +use nt_time::{FileTime, time::UtcOffset}; #[derive(Debug, Parser)] #[command(version, about)] diff --git a/examples/parse.rs b/examples/parse.rs index 95ac2bd..2a4b926 100644 --- a/examples/parse.rs +++ b/examples/parse.rs @@ -7,12 +7,12 @@ use anyhow::Context; use clap::{Parser, ValueEnum}; use nt_time::{ + FileTime, time::{ + OffsetDateTime, error::Parse, format_description::well_known::{Iso8601, Rfc2822, Rfc3339}, - OffsetDateTime, }, - FileTime, }; #[derive(Debug, Parser)] diff --git a/rustfmt.toml b/rustfmt.toml index f55a8b6..628fa22 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,9 +2,10 @@ # # SPDX-License-Identifier: Apache-2.0 OR MIT -edition = "2021" +edition = "2024" format_code_in_doc_comments = true format_macro_matchers = true group_imports = "StdExternalCrate" imports_granularity = "Crate" +style_edition = "2024" wrap_comments = true diff --git a/src/error.rs b/src/error.rs index 24968e0..d94238c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,6 +5,7 @@ //! Error types for this crate. use core::{ + error::Error, fmt, num::{IntErrorKind, ParseIntError}, }; @@ -27,7 +28,7 @@ impl DosDateTimeRangeError { /// # Examples /// /// ``` - /// # use nt_time::{error::DosDateTimeRangeErrorKind, FileTime}; + /// # use nt_time::{FileTime, error::DosDateTimeRangeErrorKind}; /// # /// let err = FileTime::NT_TIME_EPOCH.to_dos_date_time(None).unwrap_err(); /// assert_eq!(err.kind(), DosDateTimeRangeErrorKind::Negative); @@ -49,8 +50,7 @@ impl fmt::Display for DosDateTimeRangeError { } } -#[cfg(feature = "std")] -impl std::error::Error for DosDateTimeRangeError {} +impl Error for DosDateTimeRangeError {} impl From for DosDateTimeRangeError { #[inline] @@ -106,7 +106,7 @@ impl FileTimeRangeError { /// # Examples /// /// ``` - /// # use nt_time::{error::FileTimeRangeErrorKind, FileTime}; + /// # use nt_time::{FileTime, error::FileTimeRangeErrorKind}; /// # /// let err = FileTime::from_unix_time_secs(i64::MIN).unwrap_err(); /// assert_eq!(err.kind(), FileTimeRangeErrorKind::Negative); @@ -128,8 +128,7 @@ impl fmt::Display for FileTimeRangeError { } } -#[cfg(feature = "std")] -impl std::error::Error for FileTimeRangeError {} +impl Error for FileTimeRangeError {} impl From for FileTimeRangeError { #[inline] @@ -197,10 +196,9 @@ impl fmt::Display for ParseFileTimeError { } } -#[cfg(feature = "std")] -impl std::error::Error for ParseFileTimeError { +impl Error for ParseFileTimeError { #[inline] - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + fn source(&self) -> Option<&(dyn Error + 'static)> { Some(&self.0) } } @@ -312,11 +310,8 @@ mod tests { ); } - #[cfg(feature = "std")] #[test] fn source_dos_date_time_range_error() { - use std::error::Error; - assert!( DosDateTimeRangeError::new(DosDateTimeRangeErrorKind::Negative) .source() @@ -513,17 +508,18 @@ mod tests { ); } - #[cfg(feature = "std")] #[test] fn source_file_time_range_error() { - use std::error::Error; - - assert!(FileTimeRangeError::new(FileTimeRangeErrorKind::Negative) - .source() - .is_none()); - assert!(FileTimeRangeError::new(FileTimeRangeErrorKind::Overflow) - .source() - .is_none()); + assert!( + FileTimeRangeError::new(FileTimeRangeErrorKind::Negative) + .source() + .is_none() + ); + assert!( + FileTimeRangeError::new(FileTimeRangeErrorKind::Overflow) + .source() + .is_none() + ); } #[test] @@ -699,11 +695,8 @@ mod tests { ); } - #[cfg(feature = "std")] #[test] fn source_parse_file_time_error() { - use std::error::Error; - assert_eq!( ParseFileTimeError::new(u64::from_str("").unwrap_err()) .source() diff --git a/src/file_time.rs b/src/file_time.rs index bcc0058..c108d62 100644 --- a/src/file_time.rs +++ b/src/file_time.rs @@ -455,6 +455,11 @@ impl FromStr for FileTime { #[cfg(test)] mod tests { + use core::{ + error::Error, + num::{IntErrorKind, ParseIntError}, + }; + use super::*; #[test] @@ -830,14 +835,8 @@ mod tests { prop_assert_eq!(FileTime::from_str(&s).unwrap(), FileTime::new(ft)); } - #[cfg(feature = "std")] #[test] fn from_str_when_empty() { - use std::{ - error::Error, - num::{IntErrorKind, ParseIntError}, - }; - assert_eq!( FileTime::from_str("") .unwrap_err() @@ -850,14 +849,8 @@ mod tests { ); } - #[cfg(feature = "std")] #[test] fn from_str_with_invalid_digit() { - use std::{ - error::Error, - num::{IntErrorKind, ParseIntError}, - }; - assert_eq!( FileTime::from_str("a") .unwrap_err() @@ -930,14 +923,8 @@ mod tests { prop_assert!(FileTime::from_str(&s).is_err()); } - #[cfg(feature = "std")] #[test] fn from_str_when_positive_overflow() { - use std::{ - error::Error, - num::{IntErrorKind, ParseIntError}, - }; - assert_eq!( FileTime::from_str("18446744073709551616") .unwrap_err() diff --git a/src/file_time/consts.rs b/src/file_time/consts.rs index 1cd42c1..4c71d94 100644 --- a/src/file_time/consts.rs +++ b/src/file_time/consts.rs @@ -4,7 +4,7 @@ //! Constants for [`FileTime`]. -use super::{FileTime, FILE_TIMES_PER_SEC}; +use super::{FILE_TIMES_PER_SEC, FileTime}; impl FileTime { /// The [NT time epoch]. @@ -16,7 +16,7 @@ impl FileTime { /// # Examples /// /// ``` - /// # use nt_time::{time::macros::datetime, FileTime}; + /// # use nt_time::{FileTime, time::macros::datetime}; /// # /// assert_eq!(FileTime::NT_TIME_EPOCH, datetime!(1601-01-01 00:00 UTC)); /// ``` @@ -32,7 +32,7 @@ impl FileTime { /// # Examples /// /// ``` - /// # use nt_time::{time::OffsetDateTime, FileTime}; + /// # use nt_time::{FileTime, time::OffsetDateTime}; /// # /// assert_eq!(FileTime::UNIX_EPOCH, OffsetDateTime::UNIX_EPOCH); /// ``` @@ -68,7 +68,7 @@ impl FileTime { /// ``` /// # #[cfg(feature = "large-dates")] /// # { - /// # use nt_time::{time::macros::datetime, FileTime}; + /// # use nt_time::{FileTime, time::macros::datetime}; /// # /// assert_eq!( /// FileTime::SIGNED_MAX, @@ -106,7 +106,7 @@ impl FileTime { /// ``` /// # #[cfg(feature = "large-dates")] /// # { - /// # use nt_time::{time::macros::datetime, FileTime}; + /// # use nt_time::{FileTime, time::macros::datetime}; /// # /// assert_eq!( /// FileTime::MAX, @@ -125,7 +125,7 @@ impl FileTime { #[cfg(test)] mod tests { - use time::{macros::datetime, OffsetDateTime}; + use time::{OffsetDateTime, macros::datetime}; use super::*; diff --git a/src/file_time/convert.rs b/src/file_time/convert.rs index 983c21c..1e5a42e 100644 --- a/src/file_time/convert.rs +++ b/src/file_time/convert.rs @@ -6,7 +6,7 @@ use core::num::TryFromIntError; -use time::{error::ComponentRange, OffsetDateTime}; +use time::{OffsetDateTime, error::ComponentRange}; use super::FileTime; use crate::error::{FileTimeRangeError, FileTimeRangeErrorKind}; @@ -123,8 +123,8 @@ impl TryFrom for OffsetDateTime { /// /// ``` /// # use nt_time::{ - /// # time::{macros::datetime, OffsetDateTime}, /// # FileTime, + /// # time::{OffsetDateTime, macros::datetime}, /// # }; /// # /// assert_eq!( @@ -143,7 +143,7 @@ impl TryFrom for OffsetDateTime { /// ``` /// # #[cfg(not(feature = "large-dates"))] /// # { - /// # use nt_time::{time::OffsetDateTime, FileTime}; + /// # use nt_time::{FileTime, time::OffsetDateTime}; /// # /// assert!(OffsetDateTime::try_from(FileTime::new(2_650_467_744_000_000_000)).is_err()); /// # } @@ -155,8 +155,8 @@ impl TryFrom for OffsetDateTime { /// # #[cfg(feature = "large-dates")] /// # { /// # use nt_time::{ - /// # time::{macros::datetime, OffsetDateTime}, /// # FileTime, + /// # time::{OffsetDateTime, macros::datetime}, /// # }; /// # /// assert_eq!( @@ -187,8 +187,8 @@ impl From for chrono::DateTime { /// /// ``` /// # use nt_time::{ - /// # chrono::{DateTime, Utc}, /// # FileTime, + /// # chrono::{DateTime, Utc}, /// # }; /// # /// assert_eq!( @@ -299,16 +299,18 @@ impl TryFrom for FileTime { /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. - /// assert!(FileTime::try_from( - /// SystemTime::UNIX_EPOCH - Duration::from_nanos(11_644_473_600_000_000_100) - /// ) - /// .is_err()); + /// assert!( + /// FileTime::try_from( + /// SystemTime::UNIX_EPOCH - Duration::from_nanos(11_644_473_600_000_000_100) + /// ) + /// .is_err() + /// ); /// // After `+60056-05-28 05:36:10.955161500 UTC`. /// #[cfg(not(windows))] - /// assert!(FileTime::try_from( - /// SystemTime::UNIX_EPOCH + Duration::new(1_833_029_933_770, 955_161_600) - /// ) - /// .is_err()); + /// assert!( + /// FileTime::try_from(SystemTime::UNIX_EPOCH + Duration::new(1_833_029_933_770, 955_161_600)) + /// .is_err() + /// ); /// ``` #[inline] fn try_from(st: std::time::SystemTime) -> Result { @@ -336,8 +338,8 @@ impl TryFrom for FileTime { /// /// ``` /// # use nt_time::{ - /// # time::{macros::datetime, Duration, OffsetDateTime}, /// # FileTime, + /// # time::{Duration, OffsetDateTime, macros::datetime}, /// # }; /// # /// assert_eq!( @@ -363,14 +365,16 @@ impl TryFrom for FileTime { /// # #[cfg(feature = "large-dates")] /// # { /// # use nt_time::{ - /// # time::{macros::datetime, Duration}, /// # FileTime, + /// # time::{Duration, macros::datetime}, /// # }; /// # - /// assert!(FileTime::try_from( - /// datetime!(+60056-05-28 05:36:10.955_161_500 UTC) + Duration::nanoseconds(100) - /// ) - /// .is_err()); + /// assert!( + /// FileTime::try_from( + /// datetime!(+60056-05-28 05:36:10.955_161_500 UTC) + Duration::nanoseconds(100) + /// ) + /// .is_err() + /// ); /// # } /// ``` #[inline] @@ -393,8 +397,8 @@ impl TryFrom> for FileTime { /// /// ``` /// # use nt_time::{ - /// # chrono::{DateTime, TimeDelta, Utc}, /// # FileTime, + /// # chrono::{DateTime, TimeDelta, Utc}, /// # }; /// # /// assert_eq!( @@ -407,18 +411,23 @@ impl TryFrom> for FileTime { /// ); /// /// // Before `1601-01-01 00:00:00 UTC`. - /// assert!(FileTime::try_from( - /// "1601-01-01 00:00:00 UTC".parse::>().unwrap() - TimeDelta::nanoseconds(100) - /// ) - /// .is_err()); + /// assert!( + /// FileTime::try_from( + /// "1601-01-01 00:00:00 UTC".parse::>().unwrap() + /// - TimeDelta::nanoseconds(100) + /// ) + /// .is_err() + /// ); /// // After `+60056-05-28 05:36:10.955161500 UTC`. - /// assert!(FileTime::try_from( - /// "+60056-05-28 05:36:10.955161500 UTC" - /// .parse::>() - /// .unwrap() - /// + TimeDelta::nanoseconds(100) - /// ) - /// .is_err()); + /// assert!( + /// FileTime::try_from( + /// "+60056-05-28 05:36:10.955161500 UTC" + /// .parse::>() + /// .unwrap() + /// + TimeDelta::nanoseconds(100) + /// ) + /// .is_err() + /// ); /// ``` #[inline] fn try_from(dt: chrono::DateTime) -> Result { @@ -727,9 +736,11 @@ mod tests { use std::time::{Duration, SystemTime}; if cfg!(windows) { - assert!(SystemTime::UNIX_EPOCH - .checked_add(Duration::new(910_692_730_085, 477_580_800)) - .is_none()); + assert!( + SystemTime::UNIX_EPOCH + .checked_add(Duration::new(910_692_730_085, 477_580_800)) + .is_none() + ); } else { assert_eq!( FileTime::try_from( @@ -743,7 +754,7 @@ mod tests { #[test] fn try_from_offset_date_time_to_file_time_before_nt_time_epoch() { - use time::{macros::datetime, Duration}; + use time::{Duration, macros::datetime}; assert_eq!( FileTime::try_from(datetime!(1601-01-01 00:00 UTC) - Duration::nanoseconds(100)) @@ -792,7 +803,7 @@ mod tests { #[cfg(feature = "large-dates")] #[test] fn try_from_offset_date_time_to_file_time_with_too_big_date_time() { - use time::{macros::datetime, Duration}; + use time::{Duration, macros::datetime}; assert_eq!( FileTime::try_from( diff --git a/src/file_time/dos_date_time.rs b/src/file_time/dos_date_time.rs index 8a28d5a..1a10ba3 100644 --- a/src/file_time/dos_date_time.rs +++ b/src/file_time/dos_date_time.rs @@ -7,7 +7,7 @@ //! //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -use time::{error::ComponentRange, macros::offset, Date, OffsetDateTime, Time, UtcOffset}; +use time::{Date, OffsetDateTime, Time, UtcOffset, error::ComponentRange, macros::offset}; use super::FileTime; use crate::error::{DosDateTimeRangeError, DosDateTimeRangeErrorKind}; @@ -51,7 +51,7 @@ impl FileTime { /// # Examples /// /// ``` - /// # use nt_time::{time::macros::offset, FileTime}; + /// # use nt_time::{FileTime, time::macros::offset}; /// # /// // `1980-01-01 00:00:00 UTC`. /// assert_eq!( @@ -65,13 +65,17 @@ impl FileTime { /// ); /// /// // Before `1980-01-01 00:00:00 UTC`. - /// assert!(FileTime::new(119_600_063_990_000_000) - /// .to_dos_date_time(None) - /// .is_err()); + /// assert!( + /// FileTime::new(119_600_063_990_000_000) + /// .to_dos_date_time(None) + /// .is_err() + /// ); /// // After `2107-12-31 23:59:59.990000000 UTC`. - /// assert!(FileTime::new(159_992_928_000_000_000) - /// .to_dos_date_time(None) - /// .is_err()); + /// assert!( + /// FileTime::new(159_992_928_000_000_000) + /// .to_dos_date_time(None) + /// .is_err() + /// ); /// /// // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:25:00 -08:00`. /// assert_eq!( @@ -84,7 +88,7 @@ impl FileTime { /// the UTC date and time: /// /// ``` - /// # use nt_time::{time::macros::offset, FileTime}; + /// # use nt_time::{FileTime, time::macros::offset}; /// # /// // `2002-11-27 03:25:00 UTC`. /// assert_eq!( @@ -186,7 +190,7 @@ impl FileTime { /// # Examples /// /// ``` - /// # use nt_time::{time::macros::offset, FileTime}; + /// # use nt_time::{FileTime, time::macros::offset}; /// # /// // `1980-01-01 00:00:00 UTC`. /// assert_eq!( @@ -215,7 +219,7 @@ impl FileTime { /// the provided date and time is in UTC: /// /// ``` - /// # use nt_time::{time::macros::offset, FileTime}; + /// # use nt_time::{FileTime, time::macros::offset}; /// # /// // From `2002-11-26 19:25:00 -08:01` to `2002-11-26 19:25:00 UTC`. /// assert_eq!( diff --git a/src/file_time/ops.rs b/src/file_time/ops.rs index 2a5d3a0..5837201 100644 --- a/src/file_time/ops.rs +++ b/src/file_time/ops.rs @@ -8,7 +8,7 @@ use core::ops::{Add, AddAssign, Sub, SubAssign}; use time::OffsetDateTime; -use super::{FileTime, FILE_TIMES_PER_SEC}; +use super::{FILE_TIMES_PER_SEC, FileTime}; impl FileTime { /// Computes `self + rhs`, returning [`None`] if overflow occurred. The part diff --git a/src/file_time/rand.rs b/src/file_time/rand.rs index ef6f52f..e2c56a5 100644 --- a/src/file_time/rand.rs +++ b/src/file_time/rand.rs @@ -5,8 +5,8 @@ //! Implementations of [`rand`] for [`FileTime`]. use rand::{ - distr::{Distribution, StandardUniform}, Rng, + distr::{Distribution, StandardUniform}, }; use super::FileTime; diff --git a/src/file_time/serde.rs b/src/file_time/serde.rs index 0a9db8f..90bda7b 100644 --- a/src/file_time/serde.rs +++ b/src/file_time/serde.rs @@ -8,7 +8,7 @@ use core::fmt; -use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor}; use super::FileTime; @@ -132,7 +132,7 @@ mod tests { #[test] fn serde() { - use serde_test::{assert_tokens, Token}; + use serde_test::{Token, assert_tokens}; assert_tokens( &Test { @@ -183,7 +183,7 @@ mod tests { #[test] fn deserialize_error() { - use serde_test::{assert_de_tokens_error, Token}; + use serde_test::{Token, assert_de_tokens_error}; assert_de_tokens_error::( &[ @@ -224,7 +224,7 @@ mod tests { #[test] fn serde_optional() { - use serde_test::{assert_tokens, Token}; + use serde_test::{Token, assert_tokens}; assert_tokens( &TestOption { @@ -290,7 +290,7 @@ mod tests { #[test] fn deserialize_optional_error() { - use serde_test::{assert_de_tokens_error, Token}; + use serde_test::{Token, assert_de_tokens_error}; assert_de_tokens_error::( &[ diff --git a/src/file_time/unix_time.rs b/src/file_time/unix_time.rs index 81d90fb..3fce4d7 100644 --- a/src/file_time/unix_time.rs +++ b/src/file_time/unix_time.rs @@ -8,7 +8,7 @@ use core::time::Duration; -use super::{FileTime, FILE_TIMES_PER_SEC}; +use super::{FILE_TIMES_PER_SEC, FileTime}; use crate::error::{FileTimeRangeError, FileTimeRangeErrorKind}; impl FileTime { diff --git a/src/lib.rs b/src/lib.rs index 281b30f..f1f3824 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,8 @@ //! use core::time::Duration; //! //! use nt_time::{ -//! time::{macros::datetime, OffsetDateTime}, //! FileTime, +//! time::{OffsetDateTime, macros::datetime}, //! }; //! //! let ft = FileTime::NT_TIME_EPOCH; @@ -56,8 +56,8 @@ //! use core::time::Duration; //! //! use nt_time::{ -//! time::{OffsetDateTime, UtcOffset}, //! FileTime, +//! time::{OffsetDateTime, UtcOffset}, //! }; //! //! // `1970-01-01 00:00:00 UTC`. @@ -87,7 +87,7 @@ //! [`time::OffsetDateTime`]. //! //! ``` -//! use nt_time::{time::OffsetDateTime, FileTime}; +//! use nt_time::{FileTime, time::OffsetDateTime}; //! //! let ft = FileTime::NT_TIME_EPOCH; //! assert_eq!(format!("{ft}"), "0"); diff --git a/src/serde_with/iso_8601.rs b/src/serde_with/iso_8601.rs index 63f0b5a..263c6c2 100644 --- a/src/serde_with/iso_8601.rs +++ b/src/serde_with/iso_8601.rs @@ -14,9 +14,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::iso_8601, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -40,7 +40,7 @@ pub mod option; -use serde::{de::Error as _, ser::Error as _, Deserializer, Serializer}; +use serde::{Deserializer, Serializer, de::Error as _, ser::Error as _}; use time::serde::iso8601; use crate::FileTime; @@ -70,7 +70,7 @@ pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result>( #[cfg(test)] mod tests { use serde::{Deserialize, Serialize}; - use serde_test::{assert_de_tokens_error, assert_tokens, Token}; + use serde_test::{Token, assert_de_tokens_error, assert_tokens}; use super::*; diff --git a/src/serde_with/rfc_2822.rs b/src/serde_with/rfc_2822.rs index b40ad69..0b374ce 100644 --- a/src/serde_with/rfc_2822.rs +++ b/src/serde_with/rfc_2822.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::rfc_2822, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -37,7 +37,7 @@ pub mod option; -use serde::{de::Error as _, ser::Error as _, Deserializer, Serializer}; +use serde::{Deserializer, Serializer, de::Error as _, ser::Error as _}; use time::serde::rfc2822; use crate::FileTime; @@ -67,7 +67,7 @@ pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result>( #[cfg(test)] mod tests { use serde::{Deserialize, Serialize}; - use serde_test::{assert_ser_tokens_error, assert_tokens, Token}; + use serde_test::{Token, assert_ser_tokens_error, assert_tokens}; use super::*; diff --git a/src/serde_with/rfc_3339.rs b/src/serde_with/rfc_3339.rs index 9ba5616..d4ff56d 100644 --- a/src/serde_with/rfc_3339.rs +++ b/src/serde_with/rfc_3339.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::rfc_3339, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -37,7 +37,7 @@ pub mod option; -use serde::{de::Error as _, ser::Error as _, Deserializer, Serializer}; +use serde::{Deserializer, Serializer, de::Error as _, ser::Error as _}; use time::serde::rfc3339; use crate::FileTime; @@ -67,7 +67,7 @@ pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result>( #[cfg(test)] mod tests { use serde::{Deserialize, Serialize}; - use serde_test::{assert_de_tokens_error, assert_ser_tokens_error, assert_tokens, Token}; + use serde_test::{Token, assert_de_tokens_error, assert_ser_tokens_error, assert_tokens}; use super::*; diff --git a/src/serde_with/unix_time.rs b/src/serde_with/unix_time.rs index f1cffa8..f435a01 100644 --- a/src/serde_with/unix_time.rs +++ b/src/serde_with/unix_time.rs @@ -10,9 +10,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -39,7 +39,7 @@ pub mod milliseconds; pub mod nanoseconds; pub mod option; -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; @@ -70,7 +70,7 @@ mod tests { use core::time::Duration; use serde_test::{ - assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token, + Token, assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, }; use super::*; diff --git a/src/serde_with/unix_time/microseconds.rs b/src/serde_with/unix_time/microseconds.rs index 8b2ec7f..8c174da 100644 --- a/src/serde_with/unix_time/microseconds.rs +++ b/src/serde_with/unix_time/microseconds.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -37,7 +37,7 @@ pub mod option; -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; @@ -68,7 +68,7 @@ mod tests { use core::time::Duration; use serde_test::{ - assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token, + Token, assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, }; use super::*; diff --git a/src/serde_with/unix_time/microseconds/option.rs b/src/serde_with/unix_time/microseconds/option.rs index ff86aa4..cd78242 100644 --- a/src/serde_with/unix_time/microseconds/option.rs +++ b/src/serde_with/unix_time/microseconds/option.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -42,7 +42,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [`with`]: https://serde.rs/field-attrs.html#with -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; @@ -78,7 +78,7 @@ mod tests { use core::time::Duration; use serde_test::{ - assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token, + Token, assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, }; use super::*; diff --git a/src/serde_with/unix_time/milliseconds.rs b/src/serde_with/unix_time/milliseconds.rs index 6d140bd..0552fbc 100644 --- a/src/serde_with/unix_time/milliseconds.rs +++ b/src/serde_with/unix_time/milliseconds.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -37,7 +37,7 @@ pub mod option; -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; @@ -68,7 +68,7 @@ mod tests { use core::time::Duration; use serde_test::{ - assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token, + Token, assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, }; use super::*; diff --git a/src/serde_with/unix_time/milliseconds/option.rs b/src/serde_with/unix_time/milliseconds/option.rs index 0b80559..3c98a6f 100644 --- a/src/serde_with/unix_time/milliseconds/option.rs +++ b/src/serde_with/unix_time/milliseconds/option.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -42,7 +42,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [`with`]: https://serde.rs/field-attrs.html#with -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; @@ -78,7 +78,7 @@ mod tests { use core::time::Duration; use serde_test::{ - assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token, + Token, assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, }; use super::*; diff --git a/src/serde_with/unix_time/nanoseconds.rs b/src/serde_with/unix_time/nanoseconds.rs index 872c1b4..232d11c 100644 --- a/src/serde_with/unix_time/nanoseconds.rs +++ b/src/serde_with/unix_time/nanoseconds.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -37,7 +37,7 @@ pub mod option; -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; diff --git a/src/serde_with/unix_time/nanoseconds/option.rs b/src/serde_with/unix_time/nanoseconds/option.rs index 41d73c2..56d116b 100644 --- a/src/serde_with/unix_time/nanoseconds/option.rs +++ b/src/serde_with/unix_time/nanoseconds/option.rs @@ -11,9 +11,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -42,7 +42,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [`with`]: https://serde.rs/field-attrs.html#with -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; diff --git a/src/serde_with/unix_time/option.rs b/src/serde_with/unix_time/option.rs index 5f84a99..8c378ab 100644 --- a/src/serde_with/unix_time/option.rs +++ b/src/serde_with/unix_time/option.rs @@ -10,9 +10,9 @@ //! //! ``` //! use nt_time::{ +//! FileTime, //! serde::{Deserialize, Serialize}, //! serde_with::unix_time, -//! FileTime, //! }; //! //! #[derive(Deserialize, Serialize)] @@ -41,7 +41,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [`with`]: https://serde.rs/field-attrs.html#with -use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; use crate::FileTime; @@ -77,7 +77,7 @@ mod tests { use core::time::Duration; use serde_test::{ - assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token, + Token, assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, }; use super::*; From 87b120e8bf15121bdef0a957ceccc9aaf6ab4d95 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Mon, 24 Feb 2025 09:31:38 +0900 Subject: [PATCH 13/69] chore: Update example --- examples/parse.rs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/examples/parse.rs b/examples/parse.rs index 2a4b926..581c394 100644 --- a/examples/parse.rs +++ b/examples/parse.rs @@ -4,6 +4,8 @@ //! An example of printing a human-readable date and time as the file time. +use std::{ops::Deref, str::FromStr}; + use anyhow::Context; use clap::{Parser, ValueEnum}; use nt_time::{ @@ -33,8 +35,8 @@ struct Opt { /// /// is a string representing a date and time in either ISO 8601, RFC /// 2822, or RFC 3339 format. - #[arg(value_parser(parse_offset_date_time), value_name("DATE"))] - dt: OffsetDateTime, + #[arg(value_name("DATE"))] + dt: DateTime, } #[derive(Clone, Debug, Default, ValueEnum)] @@ -56,16 +58,32 @@ enum Format { HighLow, } -fn parse_offset_date_time(dt: &str) -> Result { - OffsetDateTime::parse(dt, &Iso8601::DEFAULT) - .or_else(|_| OffsetDateTime::parse(dt, &Rfc2822)) - .or_else(|_| OffsetDateTime::parse(dt, &Rfc3339)) +#[derive(Clone, Debug)] +struct DateTime(OffsetDateTime); + +impl Deref for DateTime { + type Target = OffsetDateTime; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl FromStr for DateTime { + type Err = Parse; + + fn from_str(dt: &str) -> Result { + OffsetDateTime::parse(dt, &Iso8601::DEFAULT) + .or_else(|_| OffsetDateTime::parse(dt, &Rfc2822)) + .or_else(|_| OffsetDateTime::parse(dt, &Rfc3339)) + .map(Self) + } } fn main() -> anyhow::Result<()> { let opt = Opt::parse(); - let ft = FileTime::try_from(opt.dt).context("could not convert time")?; + let ft = FileTime::try_from(*opt.dt).context("could not convert time")?; match opt.format { Format::Raw => println!("{}", ft.to_raw()), Format::BeBytes => println!("{:#04x?}", ft.to_be_bytes()), From 17c4cda11aa224a1a8f2dcd0efe9a5e4811f52f5 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Mon, 24 Feb 2025 18:18:39 +0900 Subject: [PATCH 14/69] docs: Add warning block --- README.md | 11 ++++++----- src/file_time.rs | 16 ++++++++++++++++ src/file_time/consts.rs | 4 ++++ src/file_time/dos_date_time.rs | 8 ++++++++ src/lib.rs | 4 ++++ src/serde_with/iso_8601.rs | 4 ++++ src/serde_with/iso_8601/option.rs | 4 ++++ 7 files changed, 46 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ae8f6b1..85d4ea9 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,12 @@ number of 100-nanosecond intervals that have elapsed since "1601-01-01 00:00:00 UTC", and is used as timestamps such as [NTFS] and [7z]. Windows uses a file time to record when an application creates, accesses, or writes to a file. -Note that many environments, such as the [Win32 API], may limit the largest -value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is equal -to the largest value of a 64-bit signed integer type when represented as an -underlying integer value. This is the largest file time accepted by the -[`FileTimeToSystemTime`] function of the Win32 API. +> [!IMPORTANT] +> Note that many environments, such as the [Win32 API], may limit the largest +> value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is +> equal to the largest value of a 64-bit signed integer type when represented +> as an underlying integer value. This is the largest file time accepted by the +> [`FileTimeToSystemTime`] function of the Win32 API. ## Usage diff --git a/src/file_time.rs b/src/file_time.rs index c108d62..8296365 100644 --- a/src/file_time.rs +++ b/src/file_time.rs @@ -34,12 +34,16 @@ const FILE_TIMES_PER_SEC: u64 = 10_000_000; /// This represents the same value as the [`FILETIME`] structure of the [Win32 /// API], which represents a 64-bit unsigned integer value. /// +///
+/// /// Note that many environments, such as the Win32 API, may limit the largest /// value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is /// equal to [`i64::MAX`], the largest value of a 64-bit signed integer type /// when represented as an underlying integer value. This is the largest file /// time accepted by the [`FileTimeToSystemTime`] function of the Win32 API. /// +///
+/// /// Also, the file time is sometimes represented as an [`i64`] value, such as in /// the [`DateTime.FromFileTimeUtc`] method and the [`DateTime.ToFileTimeUtc`] /// method in [.NET]. @@ -175,10 +179,14 @@ impl FileTime { /// Returns the memory representation of this `FileTime` as a byte array in /// native byte order. /// + ///
+ /// /// As the target platform's native endianness is used, portable code should /// use [`FileTime::to_be_bytes`] or [`FileTime::to_le_bytes`], as /// appropriate, instead. /// + ///
+ /// /// # Examples /// /// ``` @@ -268,10 +276,14 @@ impl FileTime { /// Creates a native endian `FileTime` value from its memory representation /// as a byte array in native endianness. /// + ///
+ /// /// As the target platform's native endianness is used, portable code likely /// wants to use [`FileTime::from_be_bytes`] or [`FileTime::from_le_bytes`], /// as appropriate instead. /// + ///
+ /// /// # Examples /// /// ``` @@ -409,10 +421,14 @@ impl FromStr for FileTime { /// Parses a string `s` to return a value of `FileTime`. /// + ///
+ /// /// The string is expected to be a decimal non-negative integer. If the /// string is not a decimal integer, use [`u64::from_str_radix`] and /// [`FileTime::new`] instead. /// + ///
+ /// /// # Errors /// /// Returns [`Err`] if [`u64::from_str`] returns an error. diff --git a/src/file_time/consts.rs b/src/file_time/consts.rs index 4c71d94..c814436 100644 --- a/src/file_time/consts.rs +++ b/src/file_time/consts.rs @@ -56,6 +56,8 @@ impl FileTime { /// environments, it is generally recommended that you use this constant as /// the largest value instead of [`FileTime::MAX`]. /// + ///
+ /// /// Note that the actual largest value of the [`SYSTEMTIME`] structure of /// the Win32 API is "+30827-12-31 23:59:59.999000000" (which is either in /// UTC or local time, depending on the function that is being called), @@ -63,6 +65,8 @@ impl FileTime { /// function accepts the value of this constant, but it is an invalid date /// and time for the `SYSTEMTIME` structure. /// + ///
+ /// /// # Examples /// /// ``` diff --git a/src/file_time/dos_date_time.rs b/src/file_time/dos_date_time.rs index 1a10ba3..c176e23 100644 --- a/src/file_time/dos_date_time.rs +++ b/src/file_time/dos_date_time.rs @@ -31,6 +31,8 @@ impl FileTime { /// a multiple of 15 minute intervals, returns the UTC date and time as a /// date and time and [`None`] as the UTC offset. /// + ///
+ /// /// Note that exFAT supports `resolution` for creation and last modified /// times, and the `offset` return value for these times and last access /// time, but other file systems and file formats may not support these. For @@ -38,6 +40,8 @@ impl FileTime { /// records `date` and `time`, not `resolution` and the `offset` return /// value. /// + ///
+ /// /// # Errors /// /// Returns [`Err`] if the resulting date and time is out of range for @@ -170,12 +174,16 @@ impl FileTime { /// [`None`] or is not a multiple of 15 minute intervals, assumes the /// provided date and time is in UTC. /// + ///
+ /// /// Note that exFAT supports `resolution` for creation and last modified /// times, and `offset` for these times and last access time, but other file /// systems and file formats may not support these. For example, the /// built-in timestamp of ZIP used for last modified time only records /// `date` and `time`, not `resolution` and `offset`. /// + ///
+ /// /// # Errors /// /// Returns [`Err`] if `date` or `time` is an invalid date and time. diff --git a/src/lib.rs b/src/lib.rs index f1f3824..fe77bb2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,12 +10,16 @@ //! timestamps such as [NTFS] and [7z]. Windows uses a file time to record when //! an application creates, accesses, or writes to a file. //! +//!
+//! //! Note that many environments, such as the [Win32 API], may limit the largest //! value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is //! equal to [`i64::MAX`], the largest value of a 64-bit signed integer type //! when represented as an underlying integer value. This is the largest file //! time accepted by the [`FileTimeToSystemTime`] function of the Win32 API. //! +//!
+//! //! # Examples //! //! ## Basic usage diff --git a/src/serde_with/iso_8601.rs b/src/serde_with/iso_8601.rs index 263c6c2..522401b 100644 --- a/src/serde_with/iso_8601.rs +++ b/src/serde_with/iso_8601.rs @@ -7,9 +7,13 @@ //! //! Use this module in combination with Serde's [`with`] attribute. //! +//!
+//! //! If the `large-dates` feature is not enabled, the largest date and time is //! "9999-12-31 23:59:59.999999999 UTC". //! +//!
+//! //! # Examples //! //! ``` diff --git a/src/serde_with/iso_8601/option.rs b/src/serde_with/iso_8601/option.rs index 4b67194..0d411eb 100644 --- a/src/serde_with/iso_8601/option.rs +++ b/src/serde_with/iso_8601/option.rs @@ -7,9 +7,13 @@ //! //! Use this module in combination with Serde's [`with`] attribute. //! +//!
+//! //! If the `large-dates` feature is not enabled, the largest date and time is //! "9999-12-31 23:59:59.999999999 UTC". //! +//!
+//! //! # Examples //! //! ``` From 31729b7344e1f74c30d584637de747c0eff42736 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 26 Feb 2025 05:11:16 +0900 Subject: [PATCH 15/69] feat: Add `FileTime::from_str_radix` --- CHANGELOG.adoc | 4 + benches/file_time.rs | 7 - benches/str.rs | 22 ++ src/file_time.rs | 204 +----------- src/file_time/str.rs | 772 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 800 insertions(+), 209 deletions(-) create mode 100644 benches/str.rs create mode 100644 src/file_time/str.rs diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index de2acc3..63e73b7 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -16,6 +16,10 @@ project adheres to https://semver.org/[Semantic Versioning]. == {compare-url}/v0.10.6\...HEAD[Unreleased] +=== Added + +* Add `FileTime::from_str_radix` ({pull-request-url}/296[#296]) + === Changed * Change MSRV to 1.85.0 ({pull-request-url}/294[#294]) diff --git a/benches/file_time.rs b/benches/file_time.rs index 310e034..69c653a 100644 --- a/benches/file_time.rs +++ b/benches/file_time.rs @@ -6,8 +6,6 @@ extern crate test; -use core::str::FromStr; - use nt_time::FileTime; use test::Bencher; @@ -71,8 +69,3 @@ fn from_high_low(b: &mut Bencher) { fn default(b: &mut Bencher) { b.iter(FileTime::default); } - -#[bench] -fn from_str(b: &mut Bencher) { - b.iter(|| FileTime::from_str("116444736000000000").unwrap()); -} diff --git a/benches/str.rs b/benches/str.rs new file mode 100644 index 0000000..075347f --- /dev/null +++ b/benches/str.rs @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2024 Shun Sakai +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +#![feature(test)] + +extern crate test; + +use core::str::FromStr; + +use nt_time::FileTime; +use test::Bencher; + +#[bench] +fn from_str_radix(b: &mut Bencher) { + b.iter(|| FileTime::from_str_radix("6355435732517500000", 8).unwrap()); +} + +#[bench] +fn from_str(b: &mut Bencher) { + b.iter(|| FileTime::from_str("116444736000000000").unwrap()); +} diff --git a/src/file_time.rs b/src/file_time.rs index 8296365..a8d4c09 100644 --- a/src/file_time.rs +++ b/src/file_time.rs @@ -16,11 +16,10 @@ mod ops; mod rand; #[cfg(feature = "serde")] mod serde; +mod str; mod unix_time; -use core::{mem, str::FromStr}; - -use crate::error::ParseFileTimeError; +use core::mem; const FILE_TIMES_PER_SEC: u64 = 10_000_000; @@ -416,66 +415,8 @@ impl Default for FileTime { } } -impl FromStr for FileTime { - type Err = ParseFileTimeError; - - /// Parses a string `s` to return a value of `FileTime`. - /// - ///
- /// - /// The string is expected to be a decimal non-negative integer. If the - /// string is not a decimal integer, use [`u64::from_str_radix`] and - /// [`FileTime::new`] instead. - /// - ///
- /// - /// # Errors - /// - /// Returns [`Err`] if [`u64::from_str`] returns an error. - /// - /// # Examples - /// - /// ``` - /// # use core::str::FromStr; - /// # - /// # use nt_time::FileTime; - /// # - /// assert_eq!(FileTime::from_str("0"), Ok(FileTime::NT_TIME_EPOCH)); - /// assert_eq!( - /// FileTime::from_str("116444736000000000"), - /// Ok(FileTime::UNIX_EPOCH) - /// ); - /// assert_eq!( - /// FileTime::from_str("+9223372036854775807"), - /// Ok(FileTime::SIGNED_MAX) - /// ); - /// assert_eq!( - /// FileTime::from_str("+18446744073709551615"), - /// Ok(FileTime::MAX) - /// ); - /// - /// assert!(FileTime::from_str("").is_err()); - /// - /// assert!(FileTime::from_str("a").is_err()); - /// assert!(FileTime::from_str("-1").is_err()); - /// assert!(FileTime::from_str("+").is_err()); - /// assert!(FileTime::from_str("0 ").is_err()); - /// - /// assert!(FileTime::from_str("18446744073709551616").is_err()); - /// ``` - #[inline] - fn from_str(s: &str) -> Result { - s.parse().map_err(ParseFileTimeError::new).map(Self::new) - } -} - #[cfg(test)] mod tests { - use core::{ - error::Error, - num::{IntErrorKind, ParseIntError}, - }; - use super::*; #[test] @@ -811,145 +752,4 @@ mod tests { fn default() { assert_eq!(FileTime::default(), FileTime::NT_TIME_EPOCH); } - - #[test] - fn from_str() { - assert_eq!(FileTime::from_str("0").unwrap(), FileTime::NT_TIME_EPOCH); - assert_eq!(FileTime::from_str("+0").unwrap(), FileTime::NT_TIME_EPOCH); - assert_eq!( - FileTime::from_str("116444736000000000").unwrap(), - FileTime::UNIX_EPOCH - ); - assert_eq!( - FileTime::from_str("+116444736000000000").unwrap(), - FileTime::UNIX_EPOCH - ); - assert_eq!( - FileTime::from_str("9223372036854775807").unwrap(), - FileTime::SIGNED_MAX - ); - assert_eq!( - FileTime::from_str("+9223372036854775807").unwrap(), - FileTime::SIGNED_MAX - ); - assert_eq!( - FileTime::from_str("18446744073709551615").unwrap(), - FileTime::MAX - ); - assert_eq!( - FileTime::from_str("+18446744073709551615").unwrap(), - FileTime::MAX - ); - } - - #[cfg(feature = "std")] - #[test_strategy::proptest] - fn from_str_roundtrip(#[strategy(r"\+?[0-9]{1,19}")] s: std::string::String) { - use proptest::prop_assert_eq; - - let ft = s.parse().unwrap(); - prop_assert_eq!(FileTime::from_str(&s).unwrap(), FileTime::new(ft)); - } - - #[test] - fn from_str_when_empty() { - assert_eq!( - FileTime::from_str("") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::Empty - ); - } - - #[test] - fn from_str_with_invalid_digit() { - assert_eq!( - FileTime::from_str("a") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::InvalidDigit - ); - assert_eq!( - FileTime::from_str("-1") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::InvalidDigit - ); - assert_eq!( - FileTime::from_str("+") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::InvalidDigit - ); - assert_eq!( - FileTime::from_str("-") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::InvalidDigit - ); - assert_eq!( - FileTime::from_str(" 0") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::InvalidDigit - ); - assert_eq!( - FileTime::from_str("0 ") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::InvalidDigit - ); - } - - #[cfg(feature = "std")] - #[test_strategy::proptest] - fn from_str_with_invalid_digit_roundtrip( - #[strategy(r"-[0-9]+|[^0-9]+")] s: std::string::String, - ) { - use proptest::prop_assert; - - prop_assert!(FileTime::from_str(&s).is_err()); - } - - #[test] - fn from_str_when_positive_overflow() { - assert_eq!( - FileTime::from_str("18446744073709551616") - .unwrap_err() - .source() - .unwrap() - .downcast_ref::() - .unwrap() - .kind(), - &IntErrorKind::PosOverflow - ); - } } diff --git a/src/file_time/str.rs b/src/file_time/str.rs new file mode 100644 index 0000000..7a05c69 --- /dev/null +++ b/src/file_time/str.rs @@ -0,0 +1,772 @@ +// SPDX-FileCopyrightText: 2023 Shun Sakai +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +//! Utilities for string related operations. + +use core::str::FromStr; + +use super::FileTime; +use crate::error::ParseFileTimeError; + +impl FileTime { + /// Parses a `FileTime` from a string slice with digits in a given base. + /// + /// The string is expected to be an optional `+` sign followed by only + /// digits. Leading and trailing non-digit characters (including whitespace) + /// represent an error. Underscores (which are accepted in Rust literals) + /// also represent an error. + /// + /// Digits are a subset of these characters, depending on `radix`: + /// + /// - `0-9` + /// - `a-z` + /// - `A-Z` + /// + /// # Errors + /// + /// Returns [`Err`] if [`u64::from_str_radix`] returns an error. + /// + /// # Panics + /// + /// Panics if `radix` is not in the range from 2 to 36. + /// + /// # Examples + /// + /// ``` + /// # use nt_time::FileTime; + /// # + /// assert_eq!( + /// FileTime::from_str_radix("0", 2), + /// Ok(FileTime::NT_TIME_EPOCH) + /// ); + /// assert_eq!( + /// FileTime::from_str_radix("6355435732517500000", 8), + /// Ok(FileTime::UNIX_EPOCH) + /// ); + /// assert_eq!( + /// FileTime::from_str_radix("+9223372036854775807", 10), + /// Ok(FileTime::SIGNED_MAX) + /// ); + /// assert_eq!( + /// FileTime::from_str_radix("+ffffffffffffffff", 16), + /// Ok(FileTime::MAX) + /// ); + /// + /// assert!(FileTime::from_str_radix("8", 8).is_err()); + /// + /// assert!(FileTime::from_str_radix("", 16).is_err()); + /// + /// assert!(FileTime::from_str_radix("Z", 16).is_err()); + /// assert!(FileTime::from_str_radix("_", 16).is_err()); + /// assert!(FileTime::from_str_radix("-1", 16).is_err()); + /// assert!(FileTime::from_str_radix("+", 16).is_err()); + /// assert!(FileTime::from_str_radix("0 ", 16).is_err()); + /// + /// assert!(FileTime::from_str_radix("3W5E11264SGSG", 36).is_err()); + /// ``` + /// + /// `radix` must be greater than or equal to 2: + /// + /// ```should_panic + /// # use nt_time::FileTime; + /// # + /// let _ = FileTime::from_str_radix("0", 1); + /// ``` + /// + /// `radix` must be less than or equal to 36: + /// + /// ```should_panic + /// # use nt_time::FileTime; + /// # + /// let _ = FileTime::from_str_radix("0", 37); + /// ``` + #[inline] + pub fn from_str_radix(src: &str, radix: u32) -> Result { + u64::from_str_radix(src, radix) + .map_err(ParseFileTimeError::new) + .map(Self::new) + } +} + +impl FromStr for FileTime { + type Err = ParseFileTimeError; + + /// Parses a string `src` to return a value of `FileTime`. + /// + ///
+ /// + /// The string is expected to be a decimal non-negative integer. If the + /// string is not a decimal integer, use [`FileTime::from_str_radix`] + /// instead. + /// + ///
+ /// + /// # Errors + /// + /// Returns [`Err`] if [`u64::from_str`] returns an error. + /// + /// # Examples + /// + /// ``` + /// # use core::str::FromStr; + /// # + /// # use nt_time::FileTime; + /// # + /// assert_eq!(FileTime::from_str("0"), Ok(FileTime::NT_TIME_EPOCH)); + /// assert_eq!( + /// FileTime::from_str("116444736000000000"), + /// Ok(FileTime::UNIX_EPOCH) + /// ); + /// assert_eq!( + /// FileTime::from_str("+9223372036854775807"), + /// Ok(FileTime::SIGNED_MAX) + /// ); + /// assert_eq!( + /// FileTime::from_str("+18446744073709551615"), + /// Ok(FileTime::MAX) + /// ); + /// + /// assert!(FileTime::from_str("").is_err()); + /// + /// assert!(FileTime::from_str("a").is_err()); + /// assert!(FileTime::from_str("_").is_err()); + /// assert!(FileTime::from_str("-1").is_err()); + /// assert!(FileTime::from_str("+").is_err()); + /// assert!(FileTime::from_str("0 ").is_err()); + /// + /// assert!(FileTime::from_str("18446744073709551616").is_err()); + /// ``` + #[inline] + fn from_str(src: &str) -> Result { + Self::from_str_radix(src, 10) + } +} + +#[cfg(test)] +mod tests { + use core::{ + error::Error, + num::{IntErrorKind, ParseIntError}, + }; + + use super::*; + + #[test] + fn from_str_radix() { + assert_eq!( + FileTime::from_str_radix("0", 2).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+0", 2).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix( + "110011101101100011101111011010101001111101000000000000000", + 2 + ) + .unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix( + "+110011101101100011101111011010101001111101000000000000000", + 2 + ) + .unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix( + "111111111111111111111111111111111111111111111111111111111111111", + 2 + ) + .unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix( + "+111111111111111111111111111111111111111111111111111111111111111", + 2 + ) + .unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix( + "1111111111111111111111111111111111111111111111111111111111111111", + 2 + ) + .unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix( + "+1111111111111111111111111111111111111111111111111111111111111111", + 2 + ) + .unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("0", 8).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+0", 8).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("6355435732517500000", 8).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+6355435732517500000", 8).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("777777777777777777777", 8).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("+777777777777777777777", 8).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("1777777777777777777777", 8).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("+1777777777777777777777", 8).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("0", 10).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+0", 10).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("116444736000000000", 10).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+116444736000000000", 10).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("9223372036854775807", 10).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("+9223372036854775807", 10).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("18446744073709551615", 10).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("+18446744073709551615", 10).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("0", 16).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+0", 16).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("19db1ded53e8000", 16).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("19DB1DED53E8000", 16).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+19db1ded53e8000", 16).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+19DB1DED53E8000", 16).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("7fffffffffffffff", 16).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("7FFFFFFFFFFFFFFF", 16).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("+7fffffffffffffff", 16).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("+7FFFFFFFFFFFFFFF", 16).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("ffffffffffffffff", 16).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("FFFFFFFFFFFFFFFF", 16).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("+ffffffffffffffff", 16).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("+FFFFFFFFFFFFFFFF", 16).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("0", 36).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+0", 36).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("vuk7p84etc0", 36).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("VUK7P84ETC0", 36).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+vuk7p84etc0", 36).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("+VUK7P84ETC0", 36).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str_radix("1y2p0ij32e8e7", 36).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("1Y2P0IJ32E8E7", 36).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("+1y2p0ij32e8e7", 36).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("+1Y2P0IJ32E8E7", 36).unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str_radix("3w5e11264sgsf", 36).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("3W5E11264SGSF", 36).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("+3w5e11264sgsf", 36).unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str_radix("+3W5E11264SGSF", 36).unwrap(), + FileTime::MAX + ); + } + + #[test] + fn from_str_radix_with_invalid_digit_radix() { + assert_eq!( + FileTime::from_str_radix("2", 2) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("8", 8) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("a", 10) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("A", 10) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("g", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("G", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + } + + #[test] + fn from_str_radix_when_empty() { + assert_eq!( + FileTime::from_str_radix("", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::Empty + ); + } + + #[test] + fn from_str_radix_with_invalid_digit() { + assert_eq!( + FileTime::from_str_radix("Z", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("_", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("-1", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("+", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("-", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix(" 0", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str_radix("0 ", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + } + + #[test] + fn from_str_radix_when_positive_overflow() { + assert_eq!( + FileTime::from_str_radix( + "10000000000000000000000000000000000000000000000000000000000000000", + 2 + ) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + assert_eq!( + FileTime::from_str_radix("2000000000000000000000", 8) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + assert_eq!( + FileTime::from_str_radix("18446744073709551616", 10) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + assert_eq!( + FileTime::from_str_radix("10000000000000000", 16) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + assert_eq!( + FileTime::from_str_radix("3w5e11264sgsg", 36) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + assert_eq!( + FileTime::from_str_radix("3W5E11264SGSG", 36) + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + } + + #[test] + #[should_panic] + fn from_str_radix_when_radix_is_less_than_2() { + let _ = FileTime::from_str_radix("0", 1); + } + + #[test] + #[should_panic] + fn from_str_radix_when_radix_is_greater_than_36() { + let _ = FileTime::from_str_radix("0", 37); + } + + #[test] + fn from_str() { + assert_eq!(FileTime::from_str("0").unwrap(), FileTime::NT_TIME_EPOCH); + assert_eq!(FileTime::from_str("+0").unwrap(), FileTime::NT_TIME_EPOCH); + assert_eq!( + FileTime::from_str("116444736000000000").unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str("+116444736000000000").unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::from_str("9223372036854775807").unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str("+9223372036854775807").unwrap(), + FileTime::SIGNED_MAX + ); + assert_eq!( + FileTime::from_str("18446744073709551615").unwrap(), + FileTime::MAX + ); + assert_eq!( + FileTime::from_str("+18446744073709551615").unwrap(), + FileTime::MAX + ); + } + + #[cfg(feature = "std")] + #[test_strategy::proptest] + fn from_str_roundtrip(#[strategy(r"\+?[0-9]{1,19}")] s: std::string::String) { + use proptest::prop_assert_eq; + + let ft = s.parse().unwrap(); + prop_assert_eq!(FileTime::from_str(&s).unwrap(), FileTime::new(ft)); + } + + #[test] + fn from_str_when_empty() { + assert_eq!( + FileTime::from_str("") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::Empty + ); + } + + #[test] + fn from_str_with_invalid_digit() { + assert_eq!( + FileTime::from_str("a") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str("_") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str("-1") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str("+") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str("-") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str(" 0") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + assert_eq!( + FileTime::from_str("0 ") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::InvalidDigit + ); + } + + #[cfg(feature = "std")] + #[test_strategy::proptest] + fn from_str_with_invalid_digit_roundtrip( + #[strategy(r"-[0-9]+|[^0-9]+")] s: std::string::String, + ) { + use proptest::prop_assert; + + prop_assert!(FileTime::from_str(&s).is_err()); + } + + #[test] + fn from_str_when_positive_overflow() { + assert_eq!( + FileTime::from_str("18446744073709551616") + .unwrap_err() + .source() + .unwrap() + .downcast_ref::() + .unwrap() + .kind(), + &IntErrorKind::PosOverflow + ); + } +} From f1865e573d9efbb9eb4e3c47872e30e9e7832667 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 26 Feb 2025 19:32:27 +0900 Subject: [PATCH 16/69] chore(release): Update version to 0.11.0 --- .bumpversion.toml | 2 +- CHANGELOG.adoc | 2 +- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 6 +++--- src/lib.rs | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 5d24cd2..05991b0 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [tool.bumpversion] -current_version = "0.10.6" +current_version = "0.11.0" [[tool.bumpversion.files]] filename = "src/lib.rs" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 63e73b7..66fb4ba 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. -== {compare-url}/v0.10.6\...HEAD[Unreleased] +== {compare-url}/v0.10.6\...v0.11.0[0.11.0] - 2025-02-26 === Added diff --git a/Cargo.lock b/Cargo.lock index 26ad7dc..835f03f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,18 +99,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "num-traits", ] [[package]] name = "clap" -version = "4.5.30" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", "clap_derive", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.30" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstream", "anstyle", @@ -233,9 +233,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "linux-raw-sys" @@ -251,7 +251,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "nt-time" -version = "0.10.6" +version = "0.11.0" dependencies = [ "anyhow", "chrono", @@ -375,7 +375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.1", + "rand_core 0.9.2", "zerocopy 0.8.20", ] @@ -396,7 +396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.1", + "rand_core 0.9.2", ] [[package]] @@ -410,9 +410,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" +checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c" dependencies = [ "getrandom 0.3.1", "zerocopy 0.8.20", diff --git a/Cargo.toml b/Cargo.toml index df8c543..76eb92a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "nt-time" -version = "0.10.6" +version = "0.11.0" authors = ["Shun Sakai "] edition = "2024" rust-version = "1.85.0" @@ -51,14 +51,14 @@ path = "examples/unix2ft.rs" required-features = ["std"] [dependencies] -chrono = { version = "0.4.39", default-features = false, optional = true } +chrono = { version = "0.4.40", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.218", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.37", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.96" -clap = { version = "4.5.30", features = ["derive"] } +clap = { version = "4.5.31", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.139" diff --git a/src/lib.rs b/src/lib.rs index fe77bb2..1fc6083 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,7 +108,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -#![doc(html_root_url = "https://docs.rs/nt-time/0.10.6/")] +#![doc(html_root_url = "https://docs.rs/nt-time/0.11.0/")] #![no_std] #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))] // Lint levels of rustc. From 4b5e35d1f4d47c9107e7b95879fce233b3d82d2d Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Fri, 28 Feb 2025 19:11:17 +0900 Subject: [PATCH 17/69] chore: Update `justfile` --- justfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 3abd627..97e9cc3 100644 --- a/justfile +++ b/justfile @@ -24,6 +24,10 @@ default: build @test: cargo test +# Run benchmarks +@bench: + cargo +nightly bench + # Run the formatter @fmt: cargo fmt @@ -40,6 +44,10 @@ default: build @clippy-fix: cargo +nightly clippy --fix --allow-dirty --allow-staged -- -D warnings +# Build the package documentation +@doc $RUSTDOCFLAGS="--cfg docsrs": + cargo +nightly doc --all-features + # Run the linter for GitHub Actions workflow files @lint-github-actions: actionlint -verbose @@ -50,5 +58,5 @@ default: build # Increment the version @bump part: - bump-my-version bump {{part}} - cargo set-version --bump {{part}} + bump-my-version bump {{ part }} + cargo set-version --bump {{ part }} From dcca9ec35da09760e72a7aa2d60eb43ec60fa299 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:47:11 +0000 Subject: [PATCH 18/69] chore(deps): Bump serde_json from 1.0.139 to 1.0.140 (#298) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.139 to 1.0.140. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.139...v1.0.140) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 835f03f..42fcf3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -486,9 +486,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 76eb92a..8807af0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ anyhow = "1.0.96" clap = { version = "4.5.31", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" -serde_json = "1.0.139" +serde_json = "1.0.140" serde_test = "1.0.177" test-strategy = "0.4.0" time = { version = "0.3.37", features = ["parsing"] } From 279a8cc19357a57b770c31e51ac8b6e8dd23ed6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:47:56 +0000 Subject: [PATCH 19/69] chore(deps): Bump anyhow from 1.0.96 to 1.0.97 (#299) Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.96 to 1.0.97. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.96...1.0.97) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42fcf3e..1412015 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "autocfg" diff --git a/Cargo.toml b/Cargo.toml index 8807af0..afb2718 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ serde = { version = "1.0.218", default-features = false, features = ["derive"], time = { version = "0.3.37", default-features = false, features = ["macros"] } [dev-dependencies] -anyhow = "1.0.96" +anyhow = "1.0.97" clap = { version = "4.5.31", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" From ee80494a33d402ccf5d75afb265a2c084e3ea1d3 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Tue, 4 Mar 2025 19:49:39 +0900 Subject: [PATCH 20/69] chore(just): Update default recipe --- justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 97e9cc3..d4da741 100644 --- a/justfile +++ b/justfile @@ -2,11 +2,11 @@ # # SPDX-License-Identifier: Apache-2.0 OR MIT -alias all := default alias lint := clippy # Run default recipe -default: build +@_default: + just -l # Build a package @build: From 7deaf5c0874f8073800ee45b0cfdb3a43a27dcca Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sat, 8 Mar 2025 00:45:32 +0900 Subject: [PATCH 21/69] chore: Change `FileTime::from_str_radix` to `const fn` --- CHANGELOG.adoc | 6 ++++++ src/file_time/str.rs | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 66fb4ba..315e004 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,12 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. +== {compare-url}/v0.11.0\...HEAD[Unreleased] + +=== Changed + +* Change `FileTime::from_str_radix` to `const fn` ({pull-request-url}/300[#300]) + == {compare-url}/v0.10.6\...v0.11.0[0.11.0] - 2025-02-26 === Added diff --git a/src/file_time/str.rs b/src/file_time/str.rs index 7a05c69..10b37d6 100644 --- a/src/file_time/str.rs +++ b/src/file_time/str.rs @@ -82,10 +82,11 @@ impl FileTime { /// let _ = FileTime::from_str_radix("0", 37); /// ``` #[inline] - pub fn from_str_radix(src: &str, radix: u32) -> Result { - u64::from_str_radix(src, radix) - .map_err(ParseFileTimeError::new) - .map(Self::new) + pub const fn from_str_radix(src: &str, radix: u32) -> Result { + match u64::from_str_radix(src, radix) { + Ok(ft) => Ok(Self::new(ft)), + Err(err) => Err(ParseFileTimeError::new(err)), + } } } @@ -619,6 +620,11 @@ mod tests { let _ = FileTime::from_str_radix("0", 37); } + #[test] + const fn from_str_radix_is_const_fn() { + const _: Result = FileTime::from_str_radix("0", 2); + } + #[test] fn from_str() { assert_eq!(FileTime::from_str("0").unwrap(), FileTime::NT_TIME_EPOCH); From 77cb9c4dfcd4fbd64788dca750f0bfff0753834f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 09:58:01 +0000 Subject: [PATCH 22/69] chore(deps): Bump time from 0.3.37 to 0.3.39 (#301) Bumps [time](https://github.com/time-rs/time) from 0.3.37 to 0.3.39. - [Release notes](https://github.com/time-rs/time/releases) - [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md) - [Commits](https://github.com/time-rs/time/compare/v0.3.37...v0.3.39) --- updated-dependencies: - dependency-name: time dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ Cargo.toml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1412015..1fefbfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -573,9 +573,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" dependencies = [ "deranged", "itoa", @@ -588,15 +588,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "e8093bc3e81c3bc5f7879de09619d06c9a5a5e45ca44dfeeb7225bae38005c5c" dependencies = [ "num-conv", "time-core", diff --git a/Cargo.toml b/Cargo.toml index afb2718..bd22558 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ required-features = ["std"] chrono = { version = "0.4.40", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.218", default-features = false, features = ["derive"], optional = true } -time = { version = "0.3.37", default-features = false, features = ["macros"] } +time = { version = "0.3.39", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.97" @@ -64,7 +64,7 @@ proptest-derive = "0.5.1" serde_json = "1.0.140" serde_test = "1.0.177" test-strategy = "0.4.0" -time = { version = "0.3.37", features = ["parsing"] } +time = { version = "0.3.39", features = ["parsing"] } [features] default = ["std"] From 3102435c88d54bdae02a555c23ae4058026be248 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 10:03:05 +0000 Subject: [PATCH 23/69] chore(deps): Bump serde from 1.0.218 to 1.0.219 (#302) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.218 to 1.0.219. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.218...v1.0.219) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fefbfc..b813606 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -466,18 +466,18 @@ checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index bd22558..d416156 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.40", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } -serde = { version = "1.0.218", default-features = false, features = ["derive"], optional = true } +serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.39", default-features = false, features = ["macros"] } [dev-dependencies] From 31d1eb07ad55349a820b2a327e6391fe7ac74b47 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 12 Mar 2025 10:20:44 +0900 Subject: [PATCH 24/69] docs: Fix typo in parameters --- src/file_time/convert.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/file_time/convert.rs b/src/file_time/convert.rs index 1e5a42e..728d1e0 100644 --- a/src/file_time/convert.rs +++ b/src/file_time/convert.rs @@ -117,7 +117,7 @@ impl TryFrom for OffsetDateTime { /// /// # Errors /// - /// Returns [`Err`] if `time` is out of range for [`OffsetDateTime`]. + /// Returns [`Err`] if `ft` is out of range for [`OffsetDateTime`]. /// /// # Examples /// @@ -280,7 +280,7 @@ impl TryFrom for FileTime { /// /// # Errors /// - /// Returns [`Err`] if `time` is out of range for the file time. + /// Returns [`Err`] if `st` is out of range for the file time. /// /// # Examples /// From e2c8c639e5998fc3174a07de948fb07fb8c7aa19 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 12 Mar 2025 14:57:26 +0900 Subject: [PATCH 25/69] feat: Supports `jiff` crate --- CHANGELOG.adoc | 4 + Cargo.lock | 160 +++++++------ Cargo.toml | 6 +- README.md | 5 + benches/cmp.rs | 32 +++ benches/convert.rs | 16 ++ benches/ops.rs | 50 ++++ src/file_time/cmp.rs | 104 +++++++++ src/file_time/convert.rs | 127 ++++++++++ src/file_time/ops.rs | 487 +++++++++++++++++++++++++++++++++++++++ src/lib.rs | 2 + 11 files changed, 920 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 315e004..0949630 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -16,6 +16,10 @@ project adheres to https://semver.org/[Semantic Versioning]. == {compare-url}/v0.11.0\...HEAD[Unreleased] +=== Added + +* Supports `jiff` crate ({pull-request-url}/303[#303]) + === Changed * Change `FileTime::from_str_radix` to `const fn` ({pull-request-url}/300[#300]) diff --git a/Cargo.lock b/Cargo.lock index b813606..fa89c12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,15 +81,9 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "cfg-if" @@ -108,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.31" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" +checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" dependencies = [ "clap_builder", "clap_derive", @@ -118,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.31" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" +checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" dependencies = [ "anstream", "anstyle", @@ -130,9 +124,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.28" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck", "proc-macro2", @@ -221,9 +215,33 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jiff" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "8d16e75759ee0aa64c57a56acbf43916987b20c77373cb7e808979e02b93c9f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "lazy_static" @@ -233,15 +251,21 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" + +[[package]] +name = "log" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "memchr" @@ -256,6 +280,7 @@ dependencies = [ "anyhow", "chrono", "clap", + "jiff", "proptest", "proptest-derive", "rand 0.9.0", @@ -283,9 +308,24 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad" + +[[package]] +name = "portable-atomic" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] [[package]] name = "powerfmt" @@ -295,18 +335,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.7.35", + "zerocopy", ] [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -350,9 +390,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -375,8 +415,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.2", - "zerocopy 0.8.20", + "rand_core 0.9.3", + "zerocopy", ] [[package]] @@ -396,7 +436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.2", + "rand_core 0.9.3", ] [[package]] @@ -410,12 +450,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.20", ] [[package]] @@ -435,9 +474,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "0.38.44" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" dependencies = [ "bitflags", "errno", @@ -460,9 +499,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" @@ -536,9 +575,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -547,9 +586,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.17.1" +version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" +checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567" dependencies = [ "cfg-if", "fastrand", @@ -610,9 +649,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf8parse" @@ -728,39 +767,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" dependencies = [ - "byteorder", - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c" -dependencies = [ - "zerocopy-derive 0.8.20", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.20" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d416156..6e62bed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,13 +52,14 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.40", default-features = false, optional = true } +jiff = { version = "0.2.4", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.39", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.97" -clap = { version = "4.5.31", features = ["derive"] } +clap = { version = "4.5.32", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" @@ -69,11 +70,12 @@ time = { version = "0.3.39", features = ["parsing"] } [features] default = ["std"] chrono = ["dep:chrono"] +jiff = ["dep:jiff"] large-dates = ["time/large-dates"] rand = ["dep:rand"] serde = ["dep:serde"] serde-human-readable = ["serde", "time/serde-human-readable"] -std = ["chrono?/std", "rand?/std", "time/std"] +std = ["chrono?/std", "jiff?/std", "rand?/std", "time/std"] [lints.clippy] cargo = { level = "warn", priority = -1 } diff --git a/README.md b/README.md index 85d4ea9..9a01e10 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ cargo add nt-time Enables the [`chrono`] crate. +#### `jiff` + +Enables the [`jiff`] crate. + #### `large-dates` Enables the `large-dates` feature of the [`time`] crate. @@ -119,6 +123,7 @@ licensing information. [`FileTimeToSystemTime`]: https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-filetimetosystemtime [`time`]: https://crates.io/crates/time [`chrono`]: https://crates.io/crates/chrono +[`jiff`]: https://crates.io/crates/jiff [`rand`]: https://crates.io/crates/rand [`serde`]: https://serde.rs/ [CHANGELOG.adoc]: CHANGELOG.adoc diff --git a/benches/cmp.rs b/benches/cmp.rs index a065067..ac25f0a 100644 --- a/benches/cmp.rs +++ b/benches/cmp.rs @@ -68,6 +68,22 @@ fn equality_file_time_and_chrono_date_time(b: &mut Bencher) { }); } +#[cfg(feature = "jiff")] +#[bench] +fn equality_jiff_timestamp_and_file_time(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| Timestamp::from_second(-11_644_473_600).unwrap() == FileTime::NT_TIME_EPOCH); +} + +#[cfg(feature = "jiff")] +#[bench] +fn equality_file_time_and_jiff_timestamp(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| FileTime::NT_TIME_EPOCH == Timestamp::from_second(-11_644_473_600).unwrap()); +} + #[cfg(feature = "std")] #[bench] fn order_system_time_and_file_time(b: &mut Bencher) { @@ -112,3 +128,19 @@ fn order_file_time_and_chrono_date_time(b: &mut Bencher) { b.iter(|| FileTime::UNIX_EPOCH > "1601-01-01 00:00:00 UTC".parse::>().unwrap()); } + +#[cfg(feature = "jiff")] +#[bench] +fn order_jiff_timestamp_and_file_time(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| Timestamp::UNIX_EPOCH > FileTime::NT_TIME_EPOCH); +} + +#[cfg(feature = "jiff")] +#[bench] +fn order_file_time_and_jiff_timestamp(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| FileTime::UNIX_EPOCH > Timestamp::from_second(-11_644_473_600).unwrap()); +} diff --git a/benches/convert.rs b/benches/convert.rs index 92bed5b..e6f8eff 100644 --- a/benches/convert.rs +++ b/benches/convert.rs @@ -40,6 +40,14 @@ fn from_file_time_to_chrono_date_time(b: &mut Bencher) { b.iter(|| DateTime::::from(FileTime::UNIX_EPOCH)); } +#[cfg(feature = "jiff")] +#[bench] +fn try_from_file_time_to_jiff_timestamp(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| Timestamp::try_from(FileTime::UNIX_EPOCH).unwrap()); +} + #[bench] fn from_u64_to_file_time(b: &mut Bencher) { b.iter(|| FileTime::from(u64::MIN)); @@ -70,3 +78,11 @@ fn try_from_chrono_date_time_to_file_time(b: &mut Bencher) { b.iter(|| FileTime::try_from(DateTime::::UNIX_EPOCH).unwrap()); } + +#[cfg(feature = "jiff")] +#[bench] +fn try_from_jiff_timestamp_to_file_time(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| FileTime::try_from(Timestamp::UNIX_EPOCH).unwrap()); +} diff --git a/benches/ops.rs b/benches/ops.rs index eadf7b3..abd5f0b 100644 --- a/benches/ops.rs +++ b/benches/ops.rs @@ -74,6 +74,22 @@ fn add_negative_chrono_time_delta(b: &mut Bencher) { b.iter(|| FileTime::MAX + TimeDelta::nanoseconds(-100)); } +#[cfg(feature = "jiff")] +#[bench] +fn add_positive_jiff_span(b: &mut Bencher) { + use jiff::ToSpan; + + b.iter(|| FileTime::NT_TIME_EPOCH + 100.nanoseconds()); +} + +#[cfg(feature = "jiff")] +#[bench] +fn add_negative_jiff_span(b: &mut Bencher) { + use jiff::ToSpan; + + b.iter(|| FileTime::MAX + (-100).nanoseconds()); +} + #[bench] fn sub_file_time(b: &mut Bencher) { b.iter(|| FileTime::MAX - FileTime::NT_TIME_EPOCH); @@ -116,6 +132,22 @@ fn sub_negative_chrono_time_delta(b: &mut Bencher) { b.iter(|| FileTime::NT_TIME_EPOCH - TimeDelta::nanoseconds(-100)); } +#[cfg(feature = "jiff")] +#[bench] +fn sub_positive_jiff_span(b: &mut Bencher) { + use jiff::ToSpan; + + b.iter(|| FileTime::MAX - 100.nanoseconds()); +} + +#[cfg(feature = "jiff")] +#[bench] +fn sub_negative_jiff_span(b: &mut Bencher) { + use jiff::ToSpan; + + b.iter(|| FileTime::NT_TIME_EPOCH - (-100).nanoseconds()); +} + #[cfg(feature = "std")] #[bench] fn sub_file_time_from_system_time(b: &mut Bencher) { @@ -168,3 +200,21 @@ fn sub_chrono_date_time_from_file_time(b: &mut Bencher) { b.iter(|| FileTime::MAX - "1601-01-01 00:00:00 UTC".parse::>().unwrap()); } + +#[cfg(feature = "jiff")] +#[bench] +fn sub_file_time_from_jiff_timestamp(b: &mut Bencher) { + use jiff::{Timestamp, ToSpan}; + + b.iter(|| (Timestamp::MAX - 99.nanoseconds()) - FileTime::NT_TIME_EPOCH); +} + +#[cfg(feature = "jiff")] +#[bench] +fn sub_jiff_timestamp_from_file_time(b: &mut Bencher) { + use jiff::Timestamp; + + b.iter(|| { + FileTime::new(2_650_466_808_009_999_999) - Timestamp::from_second(-11_644_473_600).unwrap() + }); +} diff --git a/src/file_time/cmp.rs b/src/file_time/cmp.rs index c7b767a..71ec0fd 100644 --- a/src/file_time/cmp.rs +++ b/src/file_time/cmp.rs @@ -61,6 +61,24 @@ impl PartialEq> for FileTime { } } +#[cfg(feature = "jiff")] +impl PartialEq for jiff::Timestamp { + #[inline] + fn eq(&self, other: &FileTime) -> bool { + self == &Self::try_from(*other).expect("`other` is out of range for `Timestamp`") + } +} + +#[cfg(feature = "jiff")] +impl PartialEq for FileTime { + #[inline] + fn eq(&self, other: &jiff::Timestamp) -> bool { + use jiff::Timestamp; + + &Timestamp::try_from(*self).expect("`self` is out of range for `Timestamp`") == other + } +} + #[cfg(feature = "std")] impl PartialOrd for std::time::SystemTime { #[inline] @@ -115,6 +133,26 @@ impl PartialOrd> for FileTime { } } +#[cfg(feature = "jiff")] +impl PartialOrd for jiff::Timestamp { + #[inline] + fn partial_cmp(&self, other: &FileTime) -> Option { + self.partial_cmp(&Self::try_from(*other).expect("`other` is out of range for `Timestamp`")) + } +} + +#[cfg(feature = "jiff")] +impl PartialOrd for FileTime { + #[inline] + fn partial_cmp(&self, other: &jiff::Timestamp) -> Option { + use jiff::Timestamp; + + Timestamp::try_from(*self) + .expect("`self` is out of range for `Timestamp`") + .partial_cmp(other) + } +} + #[cfg(test)] mod tests { use time::macros::datetime; @@ -266,6 +304,46 @@ mod tests { ); } + #[cfg(feature = "jiff")] + #[test] + fn equality_jiff_timestamp_and_file_time() { + use jiff::{Timestamp, ToSpan}; + + assert_eq!( + Timestamp::MAX - 99.nanoseconds(), + FileTime::new(2_650_466_808_009_999_999) + ); + assert_ne!(Timestamp::MAX - 99.nanoseconds(), FileTime::NT_TIME_EPOCH); + assert_ne!( + Timestamp::from_second(-11_644_473_600).unwrap(), + FileTime::new(2_650_466_808_009_999_999) + ); + assert_eq!( + Timestamp::from_second(-11_644_473_600).unwrap(), + FileTime::NT_TIME_EPOCH + ); + } + + #[cfg(feature = "jiff")] + #[test] + fn equality_file_time_and_jiff_timestamp() { + use jiff::{Timestamp, ToSpan}; + + assert_eq!( + FileTime::new(2_650_466_808_009_999_999), + Timestamp::MAX - 99.nanoseconds() + ); + assert_ne!(FileTime::NT_TIME_EPOCH, Timestamp::MAX - 99.nanoseconds()); + assert_ne!( + FileTime::new(2_650_466_808_009_999_999), + Timestamp::from_second(-11_644_473_600).unwrap() + ); + assert_eq!( + FileTime::NT_TIME_EPOCH, + Timestamp::from_second(-11_644_473_600).unwrap() + ); + } + #[cfg(feature = "std")] #[test] fn order_system_time_and_file_time() { @@ -348,4 +426,30 @@ mod tests { ); assert!(FileTime::UNIX_EPOCH > "1601-01-01 00:00:00 UTC".parse::>().unwrap()); } + + #[cfg(feature = "jiff")] + #[test] + fn order_jiff_timestamp_and_file_time() { + use jiff::Timestamp; + + assert!(Timestamp::UNIX_EPOCH < FileTime::new(2_650_466_808_009_999_999)); + assert_eq!( + Timestamp::UNIX_EPOCH.partial_cmp(&FileTime::UNIX_EPOCH), + Some(Ordering::Equal) + ); + assert!(Timestamp::UNIX_EPOCH > FileTime::NT_TIME_EPOCH); + } + + #[cfg(feature = "jiff")] + #[test] + fn order_file_time_and_jiff_timestamp() { + use jiff::Timestamp; + + assert!(FileTime::UNIX_EPOCH < Timestamp::MAX); + assert_eq!( + FileTime::UNIX_EPOCH.partial_cmp(&Timestamp::UNIX_EPOCH), + Some(Ordering::Equal) + ); + assert!(FileTime::UNIX_EPOCH > Timestamp::from_second(-11_644_473_600).unwrap()); + } } diff --git a/src/file_time/convert.rs b/src/file_time/convert.rs index 728d1e0..a692e84 100644 --- a/src/file_time/convert.rs +++ b/src/file_time/convert.rs @@ -208,6 +208,39 @@ impl From for chrono::DateTime { } } +#[cfg(feature = "jiff")] +impl TryFrom for jiff::Timestamp { + type Error = jiff::Error; + + /// Converts a `FileTime` to a [`Timestamp`](jiff::Timestamp). + /// + /// # Errors + /// + /// Returns [`Err`] if `ft` is out of range for + /// [`Timestamp`](jiff::Timestamp). + /// + /// # Examples + /// + /// ``` + /// # use nt_time::{FileTime, jiff::Timestamp}; + /// # + /// assert_eq!( + /// Timestamp::try_from(FileTime::NT_TIME_EPOCH).unwrap(), + /// Timestamp::from_second(-11_644_473_600).unwrap() + /// ); + /// assert_eq!( + /// Timestamp::try_from(FileTime::UNIX_EPOCH).unwrap(), + /// Timestamp::UNIX_EPOCH + /// ); + /// + /// assert!(Timestamp::try_from(FileTime::MAX).is_err()); + /// ``` + #[inline] + fn try_from(ft: FileTime) -> Result { + Self::from_nanosecond(ft.to_unix_time_nanos()) + } +} + impl From for FileTime { /// Converts the file time to a `FileTime`. /// @@ -435,6 +468,42 @@ impl TryFrom> for FileTime { } } +#[cfg(feature = "jiff")] +impl TryFrom for FileTime { + type Error = FileTimeRangeError; + + /// Converts a [`Timestamp`](jiff::Timestamp) to a `FileTime`. + /// + /// # Errors + /// + /// Returns [`Err`] if `ts` is out of range for the file time. + /// + /// # Examples + /// + /// ``` + /// # use nt_time::{FileTime, jiff::Timestamp}; + /// # + /// assert_eq!( + /// FileTime::try_from(Timestamp::from_second(-11_644_473_600).unwrap()), + /// Ok(FileTime::NT_TIME_EPOCH) + /// ); + /// assert_eq!( + /// FileTime::try_from(Timestamp::UNIX_EPOCH), + /// Ok(FileTime::UNIX_EPOCH) + /// ); + /// + /// // Before `1601-01-01 00:00:00 UTC`. + /// assert!( + /// FileTime::try_from(Timestamp::from_nanosecond(-11_644_473_600_000_000_001).unwrap()) + /// .is_err() + /// ); + /// ``` + #[inline] + fn try_from(ts: jiff::Timestamp) -> Result { + Self::from_unix_time_nanos(ts.as_nanosecond()) + } +} + #[cfg(test)] mod tests { use super::*; @@ -602,6 +671,33 @@ mod tests { ); } + #[cfg(feature = "jiff")] + #[test] + fn try_from_file_time_to_jiff_timestamp() { + use jiff::{Timestamp, ToSpan}; + + assert_eq!( + Timestamp::try_from(FileTime::NT_TIME_EPOCH).unwrap(), + Timestamp::from_second(-11_644_473_600).unwrap() + ); + assert_eq!( + Timestamp::try_from(FileTime::UNIX_EPOCH).unwrap(), + Timestamp::UNIX_EPOCH + ); + assert_eq!( + Timestamp::try_from(FileTime::new(2_650_466_808_009_999_999)).unwrap(), + Timestamp::MAX - 99.nanoseconds() + ); + } + + #[cfg(feature = "jiff")] + #[test] + fn try_from_file_time_to_jiff_timestamp_with_invalid_file_time() { + use jiff::Timestamp; + + assert!(Timestamp::try_from(FileTime::new(2_650_466_808_010_000_000)).is_err()); + } + #[test] fn from_u64_to_file_time() { assert_eq!(FileTime::from(u64::MIN), FileTime::NT_TIME_EPOCH); @@ -897,4 +993,35 @@ mod tests { FileTimeRangeErrorKind::Overflow.into() ); } + + #[cfg(feature = "jiff")] + #[test] + fn try_from_jiff_timestamp_to_file_time_before_nt_time_epoch() { + use jiff::Timestamp; + + assert_eq!( + FileTime::try_from(Timestamp::from_nanosecond(-11_644_473_600_000_000_001).unwrap()) + .unwrap_err(), + FileTimeRangeErrorKind::Negative.into() + ); + } + + #[cfg(feature = "jiff")] + #[test] + fn try_from_jiff_timestamp_to_file_time() { + use jiff::Timestamp; + + assert_eq!( + FileTime::try_from(Timestamp::from_second(-11_644_473_600).unwrap()).unwrap(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::try_from(Timestamp::UNIX_EPOCH).unwrap(), + FileTime::UNIX_EPOCH + ); + assert_eq!( + FileTime::try_from(Timestamp::MAX).unwrap(), + FileTime::new(2_650_466_808_009_999_999) + ); + } } diff --git a/src/file_time/ops.rs b/src/file_time/ops.rs index 5837201..80aee4d 100644 --- a/src/file_time/ops.rs +++ b/src/file_time/ops.rs @@ -172,6 +172,22 @@ impl Add for FileTime { } } +#[cfg(feature = "jiff")] +impl Add for FileTime { + type Output = Self; + + #[inline] + fn add(self, rhs: jiff::Span) -> Self::Output { + use core::time::Duration; + + if rhs.is_positive() { + self + Duration::try_from(rhs.abs()).expect("duration is less than zero") + } else { + self - Duration::try_from(rhs.abs()).expect("duration is less than zero") + } + } +} + impl AddAssign for FileTime { #[inline] fn add_assign(&mut self, rhs: core::time::Duration) { @@ -194,6 +210,14 @@ impl AddAssign for FileTime { } } +#[cfg(feature = "jiff")] +impl AddAssign for FileTime { + #[inline] + fn add_assign(&mut self, rhs: jiff::Span) { + *self = *self + rhs; + } +} + impl Sub for FileTime { type Output = core::time::Duration; @@ -247,6 +271,22 @@ impl Sub for FileTime { } } +#[cfg(feature = "jiff")] +impl Sub for FileTime { + type Output = Self; + + #[inline] + fn sub(self, rhs: jiff::Span) -> Self::Output { + use core::time::Duration; + + if rhs.is_positive() { + self - Duration::try_from(rhs.abs()).expect("duration is less than zero") + } else { + self + Duration::try_from(rhs.abs()).expect("duration is less than zero") + } + } +} + #[cfg(feature = "std")] impl Sub for std::time::SystemTime { type Output = std::time::Duration; @@ -312,6 +352,28 @@ impl Sub> for FileTime { } } +#[cfg(feature = "jiff")] +impl Sub for jiff::Timestamp { + type Output = jiff::Span; + + #[inline] + fn sub(self, rhs: FileTime) -> Self::Output { + self - Self::try_from(rhs).expect("RHS is out of range for `Timestamp`") + } +} + +#[cfg(feature = "jiff")] +impl Sub for FileTime { + type Output = jiff::Span; + + #[inline] + fn sub(self, rhs: jiff::Timestamp) -> Self::Output { + use jiff::Timestamp; + + Timestamp::try_from(self).expect("LHS is out of range for `Timestamp`") - rhs + } +} + impl SubAssign for FileTime { #[inline] fn sub_assign(&mut self, rhs: core::time::Duration) { @@ -334,6 +396,14 @@ impl SubAssign for FileTime { } } +#[cfg(feature = "jiff")] +impl SubAssign for FileTime { + #[inline] + fn sub_assign(&mut self, rhs: jiff::Span) { + *self = *self - rhs; + } +} + #[cfg(test)] mod tests { use time::macros::datetime; @@ -717,6 +787,78 @@ mod tests { let _ = FileTime::NT_TIME_EPOCH + TimeDelta::nanoseconds(-100); } + #[cfg(feature = "jiff")] + #[test] + fn add_positive_jiff_span() { + use jiff::{Span, ToSpan}; + + assert_eq!( + FileTime::NT_TIME_EPOCH + Span::new(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH + 1.nanosecond(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH + 99.nanoseconds(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH + 100.nanoseconds(), + FileTime::new(1) + ); + + assert_eq!(FileTime::MAX + Span::new(), FileTime::MAX); + assert_eq!(FileTime::MAX + 1.nanosecond(), FileTime::MAX); + assert_eq!(FileTime::MAX + 99.nanoseconds(), FileTime::MAX); + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when adding duration to date and time")] + fn add_positive_jiff_span_with_overflow() { + use jiff::ToSpan; + + let _ = FileTime::MAX + 100.nanoseconds(); + } + + #[cfg(feature = "jiff")] + #[test] + fn add_negative_jiff_span() { + use jiff::{Span, ToSpan}; + + assert_eq!(FileTime::MAX + -Span::new(), FileTime::MAX); + assert_eq!(FileTime::MAX + (-1).nanosecond(), FileTime::MAX); + assert_eq!(FileTime::MAX + (-99).nanoseconds(), FileTime::MAX); + assert_eq!( + FileTime::MAX + (-100).nanoseconds(), + FileTime::new(u64::MAX - 1) + ); + + assert_eq!( + FileTime::NT_TIME_EPOCH + -Span::new(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH + (-1).nanosecond(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH + (-99).nanoseconds(), + FileTime::NT_TIME_EPOCH + ); + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when subtracting duration from date and time")] + fn add_negative_jiff_span_with_overflow() { + use jiff::ToSpan; + + let _ = FileTime::NT_TIME_EPOCH + (-100).nanoseconds(); + } + #[test] fn add_assign_std_duration() { use core::time::Duration; @@ -976,6 +1118,112 @@ mod tests { ft += TimeDelta::nanoseconds(-100); } + #[cfg(feature = "jiff")] + #[test] + fn add_assign_positive_jiff_span() { + use jiff::{Span, ToSpan}; + + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += Span::new(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += 1.nanosecond(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += 99.nanoseconds(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += 100.nanoseconds(); + assert_eq!(ft, FileTime::new(1)); + } + + { + let mut ft = FileTime::MAX; + ft += Span::new(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft += 1.nanosecond(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft += 99.nanoseconds(); + assert_eq!(ft, FileTime::MAX); + } + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when adding duration to date and time")] + fn add_assign_positive_jiff_span_with_overflow() { + use jiff::ToSpan; + + let mut ft = FileTime::MAX; + ft += 100.nanoseconds(); + } + + #[cfg(feature = "jiff")] + #[test] + fn add_assign_negative_jiff_span() { + use jiff::{Span, ToSpan}; + + { + let mut ft = FileTime::MAX; + ft += -Span::new(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft += (-1).nanosecond(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft += (-99).nanoseconds(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft += (-100).nanoseconds(); + assert_eq!(ft, FileTime::new(u64::MAX - 1)); + } + + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += -Span::new(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += (-1).nanosecond(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft += (-99).nanoseconds(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when subtracting duration from date and time")] + fn add_assign_negative_jiff_span_with_overflow() { + use jiff::ToSpan; + + let mut ft = FileTime::NT_TIME_EPOCH; + ft += (-100).nanoseconds(); + } + #[test] fn sub_file_time() { use core::time::Duration; @@ -1173,6 +1421,78 @@ mod tests { let _ = FileTime::MAX - TimeDelta::nanoseconds(-100); } + #[cfg(feature = "jiff")] + #[test] + fn sub_positive_jiff_span() { + use jiff::{Span, ToSpan}; + + assert_eq!(FileTime::MAX - Span::new(), FileTime::MAX); + assert_eq!(FileTime::MAX - 1.nanosecond(), FileTime::MAX); + assert_eq!(FileTime::MAX - 99.nanoseconds(), FileTime::MAX); + assert_eq!( + FileTime::MAX - 100.nanoseconds(), + FileTime::new(u64::MAX - 1) + ); + + assert_eq!( + FileTime::NT_TIME_EPOCH - Span::new(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH - 1.nanosecond(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH - 99.nanoseconds(), + FileTime::NT_TIME_EPOCH + ); + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when subtracting duration from date and time")] + fn sub_positive_jiff_span_with_overflow() { + use jiff::ToSpan; + + let _ = FileTime::NT_TIME_EPOCH - 100.nanoseconds(); + } + + #[cfg(feature = "jiff")] + #[test] + fn sub_negative_jiff_span() { + use jiff::{Span, ToSpan}; + + assert_eq!( + FileTime::NT_TIME_EPOCH - -Span::new(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH - (-1).nanosecond(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH - (-99).nanoseconds(), + FileTime::NT_TIME_EPOCH + ); + assert_eq!( + FileTime::NT_TIME_EPOCH - (-100).nanoseconds(), + FileTime::new(1) + ); + + assert_eq!(FileTime::MAX - -Span::new(), FileTime::MAX); + assert_eq!(FileTime::MAX - (-1).nanosecond(), FileTime::MAX); + assert_eq!(FileTime::MAX - (-99).nanoseconds(), FileTime::MAX); + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when adding duration to date and time")] + fn sub_negative_jiff_span_with_overflow() { + use jiff::ToSpan; + + let _ = FileTime::MAX - (-100).nanoseconds(); + } + #[cfg(feature = "std")] #[test] fn sub_file_time_from_system_time() { @@ -1368,6 +1688,67 @@ mod tests { ); } + #[cfg(feature = "jiff")] + #[test] + fn sub_file_time_from_jiff_timestamp() { + use jiff::{Span, Timestamp, ToSpan}; + + assert_eq!( + (Timestamp::MAX - 99.nanoseconds()) - FileTime::new(2_650_466_808_009_999_999), + Span::new().fieldwise() + ); + assert_eq!( + (Timestamp::MAX - 99.nanoseconds()) + - (FileTime::new(2_650_466_808_009_999_999) - 100.nanoseconds()), + 100.nanoseconds().fieldwise() + ); + assert_eq!( + (Timestamp::MAX - 99.nanoseconds()) - FileTime::NT_TIME_EPOCH, + 265_046_680_800_i64 + .seconds() + .milliseconds(999) + .microseconds(999) + .nanoseconds(900) + .fieldwise() + ); + } + + #[cfg(feature = "jiff")] + #[test] + fn sub_jiff_timestamp_from_file_time() { + use jiff::{Span, Timestamp, ToSpan}; + + assert_eq!( + FileTime::new(2_650_466_808_009_999_999) - (Timestamp::MAX - 99.nanoseconds()), + Span::new().fieldwise() + ); + assert_eq!( + FileTime::new(2_650_466_808_009_999_999) + - ((Timestamp::MAX - 99.nanoseconds()) - 1.nanosecond()), + 1.nanosecond().fieldwise() + ); + assert_eq!( + FileTime::new(2_650_466_808_009_999_999) + - ((Timestamp::MAX - 99.nanoseconds()) - 99.nanoseconds()), + 99.nanoseconds().fieldwise() + ); + assert_eq!( + FileTime::new(2_650_466_808_009_999_999) + - ((Timestamp::MAX - 99.nanoseconds()) - 100.nanoseconds()), + 100.nanoseconds().fieldwise() + ); + assert_eq!( + FileTime::new(2_650_466_808_009_999_999) + - Timestamp::from_second(-11_644_473_600).unwrap(), + 265_046_680_800_i64 + .seconds() + .milliseconds(999) + .microseconds(999) + .nanoseconds(900) + .fieldwise() + ); + } + #[test] fn sub_assign_std_duration() { use core::time::Duration; @@ -1626,4 +2007,110 @@ mod tests { let mut ft = FileTime::MAX; ft -= TimeDelta::nanoseconds(-100); } + + #[cfg(feature = "jiff")] + #[test] + fn sub_assign_positive_jiff_span() { + use jiff::{Span, ToSpan}; + + { + let mut ft = FileTime::MAX; + ft -= Span::new(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft -= 1.nanosecond(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft -= 99.nanoseconds(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft -= 100.nanoseconds(); + assert_eq!(ft, FileTime::new(u64::MAX - 1)); + } + + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= Span::new(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= 1.nanosecond(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= 99.nanoseconds(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when subtracting duration from date and time")] + fn sub_assign_positive_jiff_span_with_overflow() { + use jiff::ToSpan; + + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= 100.nanoseconds(); + } + + #[cfg(feature = "jiff")] + #[test] + fn sub_assign_negative_jiff_span() { + use jiff::{Span, ToSpan}; + + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= -Span::new(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= (-1).nanosecond(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= (-99).nanoseconds(); + assert_eq!(ft, FileTime::NT_TIME_EPOCH); + } + { + let mut ft = FileTime::NT_TIME_EPOCH; + ft -= (-100).nanoseconds(); + assert_eq!(ft, FileTime::new(1)); + } + + { + let mut ft = FileTime::MAX; + ft -= -Span::new(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft -= (-1).nanosecond(); + assert_eq!(ft, FileTime::MAX); + } + { + let mut ft = FileTime::MAX; + ft -= (-99).nanoseconds(); + assert_eq!(ft, FileTime::MAX); + } + } + + #[cfg(feature = "jiff")] + #[test] + #[should_panic(expected = "overflow when adding duration to date and time")] + fn sub_assign_negative_jiff_span_with_overflow() { + use jiff::ToSpan; + + let mut ft = FileTime::MAX; + ft -= (-100).nanoseconds(); + } } diff --git a/src/lib.rs b/src/lib.rs index 1fc6083..40599a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,6 +127,8 @@ pub mod serde_with; #[cfg(feature = "chrono")] pub use chrono; +#[cfg(feature = "jiff")] +pub use jiff; #[cfg(feature = "rand")] pub use rand; #[cfg(feature = "serde")] From 10681e18441ef52f61a9f46e57d31eada053c1f0 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 12 Mar 2025 16:01:20 +0900 Subject: [PATCH 26/69] chore(release): Update version to 0.11.1 --- .bumpversion.toml | 2 +- CHANGELOG.adoc | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 05991b0..d03f5a3 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [tool.bumpversion] -current_version = "0.11.0" +current_version = "0.11.1" [[tool.bumpversion.files]] filename = "src/lib.rs" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 0949630..0f6e66f 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. -== {compare-url}/v0.11.0\...HEAD[Unreleased] +== {compare-url}/v0.11.0\...v0.11.1[0.11.1] - 2025-03-12 === Added diff --git a/Cargo.lock b/Cargo.lock index fa89c12..585b684 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -275,7 +275,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "nt-time" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 6e62bed..65c0fd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "nt-time" -version = "0.11.0" +version = "0.11.1" authors = ["Shun Sakai "] edition = "2024" rust-version = "1.85.0" diff --git a/src/lib.rs b/src/lib.rs index 40599a1..933802f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,7 +108,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -#![doc(html_root_url = "https://docs.rs/nt-time/0.11.0/")] +#![doc(html_root_url = "https://docs.rs/nt-time/0.11.1/")] #![no_std] #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))] // Lint levels of rustc. From 808cade5a5fca5bc2f4acbb4988b328c44592b6f Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 23 Mar 2025 00:50:45 +0900 Subject: [PATCH 27/69] chore: Add license files to root directory --- CONTRIBUTING.adoc | 2 +- LICENSE-APACHE | 201 ++++++++++++++++++++++++++++++++++++++++++++++ LICENSE-MIT | 21 +++++ README.md | 2 +- 4 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 830bd89..b12ebd6 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -28,7 +28,7 @@ Please see the {commit-messages-guide-url}[Commit messages guide] and the . Create your patch. If your change is a feature or a bugfix, please add a test case if possible. Note that the change must pass the CI. . Please update the copyright information if possible. This project is - compliant with version 3.2 of the + compliant with version 3.3 of the https://reuse.software/spec/[_REUSE Specification_]. https://github.com/fsfe/reuse-tool[`reuse`] is useful for updating the copyright information. diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..42b3a15 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Shun Sakai + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 9a01e10..1a66c8f 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Copyright (C) 2023 Shun Sakai (see [AUTHORS.adoc]) This library is distributed under the terms of either the _Apache License 2.0_ or the _MIT License_. -This project is compliant with version 3.2 of the [_REUSE Specification_]. See +This project is compliant with version 3.3 of the [_REUSE Specification_]. See copyright notices of individual files for more details on copyright and licensing information. From c676297c614dbdc506195506a8f5384a7cfd68ed Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 23 Mar 2025 02:47:55 +0900 Subject: [PATCH 28/69] chore: Add REUSE compliance badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1a66c8f..d981414 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT ![MSRV][msrv-badge] [![Docs][docs-badge]][docs-url] ![License][license-badge] +[![REUSE status][reuse-badge]][reuse-url] **nt-time** is a [Windows file time] library for [Rust]. @@ -115,6 +116,8 @@ licensing information. [docs-badge]: https://img.shields.io/docsrs/nt-time?style=for-the-badge&logo=docsdotrs&label=Docs.rs [docs-url]: https://docs.rs/nt-time [license-badge]: https://img.shields.io/crates/l/nt-time?style=for-the-badge +[reuse-badge]: https://img.shields.io/reuse/compliance/github.com%2Fsorairolake%2Fnt-time?style=for-the-badge +[reuse-url]: https://api.reuse.software/info/github.com/sorairolake/nt-time [Windows file time]: https://docs.microsoft.com/en-us/windows/win32/sysinfo/file-times [Rust]: https://www.rust-lang.org/ [NTFS]: https://en.wikipedia.org/wiki/NTFS From cfa169f14bf65049f8d8d406a46a191eea432ee8 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 23 Mar 2025 03:36:49 +0900 Subject: [PATCH 29/69] docs: Change link to REUSE Specification --- CONTRIBUTING.adoc | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index b12ebd6..936ee85 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -29,7 +29,7 @@ Please see the {commit-messages-guide-url}[Commit messages guide] and the case if possible. Note that the change must pass the CI. . Please update the copyright information if possible. This project is compliant with version 3.3 of the - https://reuse.software/spec/[_REUSE Specification_]. + https://reuse.software/spec-3.3/[_REUSE Specification_]. https://github.com/fsfe/reuse-tool[`reuse`] is useful for updating the copyright information. . Please update the link:CHANGELOG.adoc[Changelog] if possible. diff --git a/README.md b/README.md index d981414..8b3b684 100644 --- a/README.md +++ b/README.md @@ -132,4 +132,4 @@ licensing information. [CHANGELOG.adoc]: CHANGELOG.adoc [CONTRIBUTING.adoc]: CONTRIBUTING.adoc [AUTHORS.adoc]: AUTHORS.adoc -[_REUSE Specification_]: https://reuse.software/spec/ +[_REUSE Specification_]: https://reuse.software/spec-3.3/ From 4408b6760d3550d35e944fb5fcfe18168f9a470a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:32:37 +0000 Subject: [PATCH 30/69] chore(deps): Bump test-strategy from 0.4.0 to 0.4.1 (#308) Bumps [test-strategy](https://github.com/frozenlib/test-strategy) from 0.4.0 to 0.4.1. - [Commits](https://github.com/frozenlib/test-strategy/compare/v0.4.0...v0.4.1) --- updated-dependencies: - dependency-name: test-strategy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 585b684..a5e496a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -600,9 +600,9 @@ dependencies = [ [[package]] name = "test-strategy" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf41af45e3f54cc184831d629d41d5b2bda8297e29c81add7ae4f362ed5e01b" +checksum = "95eb2d223f5cd3ec8dd7874cf4ada95c9cf2b5ed84ecfb1046d9aefee0c28b12" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 65c0fd9..645489e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,7 @@ proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" serde_test = "1.0.177" -test-strategy = "0.4.0" +test-strategy = "0.4.1" time = { version = "0.3.39", features = ["parsing"] } [features] From 9c9484a1497c8f0cedc505717f64c9a04fe7c449 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:33:06 +0000 Subject: [PATCH 31/69] chore(deps): Bump jiff from 0.2.4 to 0.2.5 (#307) Bumps [jiff](https://github.com/BurntSushi/jiff) from 0.2.4 to 0.2.5. - [Release notes](https://github.com/BurntSushi/jiff/releases) - [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.4...jiff-static-0.2.5) --- updated-dependencies: - dependency-name: jiff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5e496a..fa80241 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,9 +221,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e" +checksum = "c102670231191d07d37a35af3eb77f1f0dbf7a71be51a962dcd57ea607be7260" dependencies = [ "jiff-static", "log", @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d16e75759ee0aa64c57a56acbf43916987b20c77373cb7e808979e02b93c9f9" +checksum = "4cdde31a9d349f1b1f51a0b3714a5940ac022976f4b49485fc04be052b183b4c" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 645489e..1a91cee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.40", default-features = false, optional = true } -jiff = { version = "0.2.4", default-features = false, optional = true } +jiff = { version = "0.2.5", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.39", default-features = false, features = ["macros"] } From f458109c902de1c716f61d0e19552dce825552cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:34:12 +0000 Subject: [PATCH 32/69] chore(deps): Bump Swatinem/rust-cache from 2.7.7 to 2.7.8 (#309) Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.7.7 to 2.7.8. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/v2.7.7...v2.7.8) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/CI.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index a936fa7..ba23562 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ matrix.toolchain }} targets: ${{ matrix.target }} - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 with: key: ${{ matrix.target }} - name: Check a package @@ -102,7 +102,7 @@ jobs: toolchain: ${{ matrix.toolchain }} targets: ${{ matrix.target }} - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 with: key: ${{ matrix.target }} - name: Run tests @@ -132,7 +132,7 @@ jobs: toolchain: stable components: rustfmt - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 - name: Check code formatted run: cargo fmt -- --check @@ -148,7 +148,7 @@ jobs: toolchain: stable components: clippy - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 - name: Check no lint warnings run: cargo clippy -- -D warnings - name: Check no lint warnings (all features) @@ -167,7 +167,7 @@ jobs: with: toolchain: stable - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 - name: Check no `rustdoc` lint warnings run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items --all-features @@ -182,6 +182,6 @@ jobs: with: toolchain: nightly - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 - name: Run benchmarks run: cargo bench --all-features From 400cada40474d83ae8807ef4c559747b30b545f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:37:01 +0000 Subject: [PATCH 33/69] chore(deps): Bump time from 0.3.39 to 0.3.41 (#306) Bumps [time](https://github.com/time-rs/time) from 0.3.39 to 0.3.41. - [Release notes](https://github.com/time-rs/time/releases) - [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md) - [Commits](https://github.com/time-rs/time/compare/v0.3.39...v0.3.41) --- updated-dependencies: - dependency-name: time dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa80241..54286c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -148,9 +148,9 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "deranged" -version = "0.3.11" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" dependencies = [ "powerfmt", "serde", @@ -612,9 +612,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.39" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "itoa", @@ -627,15 +627,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8093bc3e81c3bc5f7879de09619d06c9a5a5e45ca44dfeeb7225bae38005c5c" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ "num-conv", "time-core", diff --git a/Cargo.toml b/Cargo.toml index 1a91cee..9a63e1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ chrono = { version = "0.4.40", default-features = false, optional = true } jiff = { version = "0.2.5", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } -time = { version = "0.3.39", default-features = false, features = ["macros"] } +time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.97" @@ -65,7 +65,7 @@ proptest-derive = "0.5.1" serde_json = "1.0.140" serde_test = "1.0.177" test-strategy = "0.4.1" -time = { version = "0.3.39", features = ["parsing"] } +time = { version = "0.3.41", features = ["parsing"] } [features] default = ["std"] From 9134fe03227e24a77c10b4c8468dd9fe133e4b3a Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Mon, 24 Mar 2025 21:48:03 +0900 Subject: [PATCH 34/69] chore(just): Change recipes to echo out --- justfile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/justfile b/justfile index d4da741..62f7e72 100644 --- a/justfile +++ b/justfile @@ -5,58 +5,58 @@ alias lint := clippy # Run default recipe -@_default: +_default: just -l # Build a package -@build: +build: cargo build # Remove generated artifacts -@clean: +clean: cargo clean # Check a package -@check: +check: cargo check # Run tests -@test: +test: cargo test # Run benchmarks -@bench: +bench: cargo +nightly bench # Run the formatter -@fmt: +fmt: cargo fmt # Run the formatter with options -@fmt-with-options: +fmt-with-options: cargo +nightly fmt # Run the linter -@clippy: +clippy: cargo clippy -- -D warnings # Apply lint suggestions -@clippy-fix: +clippy-fix: cargo +nightly clippy --fix --allow-dirty --allow-staged -- -D warnings # Build the package documentation -@doc $RUSTDOCFLAGS="--cfg docsrs": +doc $RUSTDOCFLAGS="--cfg docsrs": cargo +nightly doc --all-features # Run the linter for GitHub Actions workflow files -@lint-github-actions: +lint-github-actions: actionlint -verbose # Run the formatter for the README -@fmt-readme: +fmt-readme: npx prettier -w README.md # Increment the version -@bump part: +bump part: bump-my-version bump {{ part }} cargo set-version --bump {{ part }} From eea005e9a295e79f0209528066ecb64d10d79d52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 23:13:53 +0000 Subject: [PATCH 35/69] chore(deps): Bump clap from 4.5.32 to 4.5.34 (#310) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.32 to 4.5.34. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.32...clap_complete-v4.5.34) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54286c3..702101e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.32" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.32" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 9a63e1f..9c3a513 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.97" -clap = { version = "4.5.32", features = ["derive"] } +clap = { version = "4.5.34", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" From a5ff2cedb3a2c97d8c701aef380eba655fafbbcb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:05:02 +0000 Subject: [PATCH 36/69] chore(deps): Bump clap from 4.5.34 to 4.5.35 (#311) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.34 to 4.5.35. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.34...clap_complete-v4.5.35) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.35 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 702101e..4679bcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.34" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" +checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.34" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" +checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 9c3a513..6e2adc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.97" -clap = { version = "4.5.34", features = ["derive"] } +clap = { version = "4.5.35", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" From fe231ea6505acfc581fcceaf5000d30c41ce1adc Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Mon, 14 Apr 2025 01:10:25 +0900 Subject: [PATCH 37/69] ci: Remove `mirror.yaml` --- .github/workflows/mirror.yaml | 49 ----------------------------------- README.md | 5 ---- 2 files changed, 54 deletions(-) delete mode 100644 .github/workflows/mirror.yaml diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml deleted file mode 100644 index fc0ba12..0000000 --- a/.github/workflows/mirror.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Shun Sakai -# -# SPDX-License-Identifier: Apache-2.0 OR MIT - -name: Mirror to mirror repositories - -on: - push: - branches: - - "develop" - - "master" - schedule: - - cron: "0 0 * * FRI" - workflow_dispatch: - -jobs: - gitlab: - name: Mirror to GitLab - if: (github.actor == 'sorairolake' || github.event_name == 'schedule') && github.repository_owner == 'sorairolake' - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Mirror to GitLab - uses: yesolutions/mirror-action@v0.7.0 - with: - REMOTE: "https://gitlab.com/sorairolake/nt-time.git" - GIT_USERNAME: ${{ github.actor }} - GIT_PASSWORD: ${{ secrets.GITLAB_TOKEN }} - PUSH_ALL_REFS: "false" - - codeberg: - name: Mirror to Codeberg - if: (github.actor == 'sorairolake' || github.event_name == 'schedule') && github.repository_owner == 'sorairolake' - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Mirror to Codeberg - uses: yesolutions/mirror-action@v0.7.0 - with: - REMOTE: "https://codeberg.org/sorairolake/nt-time.git" - GIT_USERNAME: ${{ github.actor }} - GIT_PASSWORD: ${{ secrets.CODEBERG_TOKEN }} - PUSH_ALL_REFS: "false" diff --git a/README.md b/README.md index 8b3b684..54af393 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,6 @@ The minimum supported Rust version (MSRV) of this library is v1.85.0. The upstream repository is available at . -The source code is also available at: - -- -- - ## Changelog Please see [CHANGELOG.adoc]. From 21dd28dcee5993e62b39e2c7237097cd4788ebe2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 09:18:10 +0000 Subject: [PATCH 38/69] chore(deps): Bump jiff from 0.2.5 to 0.2.8 (#313) Bumps [jiff](https://github.com/BurntSushi/jiff) from 0.2.5 to 0.2.8. - [Release notes](https://github.com/BurntSushi/jiff/releases) - [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.5...jiff-static-0.2.8) --- updated-dependencies: - dependency-name: jiff dependency-version: 0.2.8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4679bcd..c19319e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,9 +221,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c102670231191d07d37a35af3eb77f1f0dbf7a71be51a962dcd57ea607be7260" +checksum = "e5ad87c89110f55e4cd4dc2893a9790820206729eaf221555f742d540b0724a0" dependencies = [ "jiff-static", "log", @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cdde31a9d349f1b1f51a0b3714a5940ac022976f4b49485fc04be052b183b4c" +checksum = "d076d5b64a7e2fe6f0743f02c43ca4a6725c0f904203bfe276a5b3e793103605" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 6e2adc8..e31f7d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.40", default-features = false, optional = true } -jiff = { version = "0.2.5", default-features = false, optional = true } +jiff = { version = "0.2.8", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From 66e90275038c575d0b201c2e2c73c8ff7026c16d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 09:19:08 +0000 Subject: [PATCH 39/69] chore(deps): Bump clap from 4.5.35 to 4.5.36 (#314) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.35 to 4.5.36. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.35...clap_complete-v4.5.36) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.36 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c19319e..a404055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.35" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.35" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index e31f7d8..2d7d697 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.97" -clap = { version = "4.5.35", features = ["derive"] } +clap = { version = "4.5.36", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" From 4437d4ac61299fa4c718f0b72b1289a1a5a8b886 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 09:23:13 +0000 Subject: [PATCH 40/69] chore(deps): Bump anyhow from 1.0.97 to 1.0.98 (#315) Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.97 to 1.0.98. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.97...1.0.98) --- updated-dependencies: - dependency-name: anyhow dependency-version: 1.0.98 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a404055..bacd210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" diff --git a/Cargo.toml b/Cargo.toml index 2d7d697..9459f28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ serde = { version = "1.0.219", default-features = false, features = ["derive"], time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] -anyhow = "1.0.97" +anyhow = "1.0.98" clap = { version = "4.5.36", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" From a94a265e98a7aa77881596f799ba7db418bf8a55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 10:11:04 +0000 Subject: [PATCH 41/69] chore(deps): Bump clap from 4.5.36 to 4.5.37 (#316) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.36 to 4.5.37. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.36...clap_complete-v4.5.37) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.37 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bacd210..49b95ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.36" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.36" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 9459f28..5f7dc97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.98" -clap = { version = "4.5.36", features = ["derive"] } +clap = { version = "4.5.37", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" From ef080e69aa674ce80983235ef155660de2507388 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 10:47:34 +0000 Subject: [PATCH 42/69] chore(deps): Bump jiff from 0.2.8 to 0.2.9 (#317) Bumps [jiff](https://github.com/BurntSushi/jiff) from 0.2.8 to 0.2.9. - [Release notes](https://github.com/BurntSushi/jiff/releases) - [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.8...jiff-static-0.2.9) --- updated-dependencies: - dependency-name: jiff dependency-version: 0.2.9 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49b95ff..5588931 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,9 +221,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ad87c89110f55e4cd4dc2893a9790820206729eaf221555f742d540b0724a0" +checksum = "59ec30f7142be6fe14e1b021f50b85db8df2d4324ea6e91ec3e5dcde092021d0" dependencies = [ "jiff-static", "log", @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d076d5b64a7e2fe6f0743f02c43ca4a6725c0f904203bfe276a5b3e793103605" +checksum = "526b834d727fd59d37b076b0c3236d9adde1b1729a4361e20b2026f738cc1dbe" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 5f7dc97..cdb253f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.40", default-features = false, optional = true } -jiff = { version = "0.2.8", default-features = false, optional = true } +jiff = { version = "0.2.9", default-features = false, optional = true } rand = { version = "0.9.0", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From 61060cb9259b9de651ed9456622dd6e866f8447f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:45:39 +0000 Subject: [PATCH 43/69] chore(deps): Bump rand from 0.9.0 to 0.9.1 (#318) Bumps [rand](https://github.com/rust-random/rand) from 0.9.0 to 0.9.1. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.9.0...rand_core-0.9.1) --- updated-dependencies: - dependency-name: rand dependency-version: 0.9.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 7 +++---- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5588931..d5ff707 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -283,7 +283,7 @@ dependencies = [ "jiff", "proptest", "proptest-derive", - "rand 0.9.0", + "rand 0.9.1", "serde", "serde_json", "serde_test", @@ -410,13 +410,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", - "zerocopy", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index cdb253f..bd73e95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.40", default-features = false, optional = true } jiff = { version = "0.2.9", default-features = false, optional = true } -rand = { version = "0.9.0", default-features = false, optional = true } +rand = { version = "0.9.1", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From d92ee437608d60bc03eb335f68d48aafde8fe923 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Thu, 24 Apr 2025 11:38:46 +0900 Subject: [PATCH 44/69] chore: Change license for documents --- .github/pull_request_template.md.license | 2 +- AUTHORS.adoc | 2 +- CHANGELOG.adoc | 8 +++++++- CONTRIBUTING.adoc | 2 +- README.md | 2 +- examples/README.adoc | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/pull_request_template.md.license b/.github/pull_request_template.md.license index 90382fe..06889ab 100644 --- a/.github/pull_request_template.md.license +++ b/.github/pull_request_template.md.license @@ -1,3 +1,3 @@ SPDX-FileCopyrightText: 2023 Shun Sakai -SPDX-License-Identifier: Apache-2.0 OR MIT +SPDX-License-Identifier: CC-BY-4.0 diff --git a/AUTHORS.adoc b/AUTHORS.adoc index f8a12ea..0960605 100644 --- a/AUTHORS.adoc +++ b/AUTHORS.adoc @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: 2023 Shun Sakai // -// SPDX-License-Identifier: Apache-2.0 OR MIT +// SPDX-License-Identifier: CC-BY-4.0 = List of Authors diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 0f6e66f..ab19416 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: 2023 Shun Sakai // -// SPDX-License-Identifier: Apache-2.0 OR MIT +// SPDX-License-Identifier: CC-BY-4.0 = Changelog :toc: preamble @@ -14,6 +14,12 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. +== {compare-url}/v0.11.1\...HEAD[Unreleased] + +=== Changed + +* Change the license for documents to CC BY 4.0 ({pull-request-url}/319[#319]) + == {compare-url}/v0.11.0\...v0.11.1[0.11.1] - 2025-03-12 === Added diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 936ee85..77ce00d 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: 2023 Shun Sakai // -// SPDX-License-Identifier: Apache-2.0 OR MIT +// SPDX-License-Identifier: CC-BY-4.0 = Contribution Guide :git-flow-url: https://nvie.com/posts/a-successful-git-branching-model/ diff --git a/README.md b/README.md index 54af393..d864768 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # nt-time diff --git a/examples/README.adoc b/examples/README.adoc index a3c7cd1..c5bb982 100644 --- a/examples/README.adoc +++ b/examples/README.adoc @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: 2023 Shun Sakai // -// SPDX-License-Identifier: Apache-2.0 OR MIT +// SPDX-License-Identifier: CC-BY-4.0 = Examples From 01cd815f5a924b6a65107e4ed62fe3bb330729d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 09:57:14 +0000 Subject: [PATCH 45/69] chore(deps): Bump chrono from 0.4.40 to 0.4.41 (#320) Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.40 to 0.4.41. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.40...v0.4.41) --- updated-dependencies: - dependency-name: chrono dependency-version: 0.4.41 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5ff707..ac2f1ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,9 +93,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "num-traits", ] diff --git a/Cargo.toml b/Cargo.toml index bd73e95..0392c1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ path = "examples/unix2ft.rs" required-features = ["std"] [dependencies] -chrono = { version = "0.4.40", default-features = false, optional = true } +chrono = { version = "0.4.41", default-features = false, optional = true } jiff = { version = "0.2.9", default-features = false, optional = true } rand = { version = "0.9.1", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } From c719f6b873f41409941de08eadf35f191aed7252 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 15:49:41 +0000 Subject: [PATCH 46/69] chore(deps): Bump jiff from 0.2.9 to 0.2.12 (#321) Bumps [jiff](https://github.com/BurntSushi/jiff) from 0.2.9 to 0.2.12. - [Release notes](https://github.com/BurntSushi/jiff/releases) - [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.9...jiff-static-0.2.12) --- updated-dependencies: - dependency-name: jiff dependency-version: 0.2.12 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac2f1ce..527f4bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,9 +221,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ec30f7142be6fe14e1b021f50b85db8df2d4324ea6e91ec3e5dcde092021d0" +checksum = "f02000660d30638906021176af16b17498bd0d12813dbfe7b276d8bc7f3c0806" dependencies = [ "jiff-static", "log", @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "526b834d727fd59d37b076b0c3236d9adde1b1729a4361e20b2026f738cc1dbe" +checksum = "f3c30758ddd7188629c6713fc45d1188af4f44c90582311d0c8d8c9907f60c48" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0392c1c..04c5c9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.41", default-features = false, optional = true } -jiff = { version = "0.2.9", default-features = false, optional = true } +jiff = { version = "0.2.13", default-features = false, optional = true } rand = { version = "0.9.1", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From 0dba0f7b723539cfd63e11ac222bd49295a8bbf8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 09:29:10 +0000 Subject: [PATCH 47/69] chore(deps): Bump dependabot/fetch-metadata from 2.3.0 to 2.4.0 (#322) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.3.0 to 2.4.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v2.3.0...v2.4.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-version: 2.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot_auto_merge.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot_auto_merge.yaml b/.github/workflows/dependabot_auto_merge.yaml index 716bdb9..6225383 100644 --- a/.github/workflows/dependabot_auto_merge.yaml +++ b/.github/workflows/dependabot_auto_merge.yaml @@ -18,7 +18,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v2.3.0 + uses: dependabot/fetch-metadata@v2.4.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Approve a PR From ffd167cad6ed07f6f24a82c68369dac384f6145f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 09:40:21 +0000 Subject: [PATCH 48/69] chore(deps): Bump clap from 4.5.37 to 4.5.38 (#323) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.37 to 4.5.38. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.37...clap_complete-v4.5.38) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.38 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 527f4bd..c1e1754 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" +checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" +checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 04c5c9d..d5ec992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.98" -clap = { version = "4.5.37", features = ["derive"] } +clap = { version = "4.5.38", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" From 4a70b277c84936c65be7eaf10a4bfc11e80b9415 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Thu, 15 May 2025 15:03:24 +0900 Subject: [PATCH 49/69] refactor: Remove redundant `value_name` --- examples/parse.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/examples/parse.rs b/examples/parse.rs index 581c394..df0b35c 100644 --- a/examples/parse.rs +++ b/examples/parse.rs @@ -21,14 +21,7 @@ use nt_time::{ #[command(version, about)] struct Opt { /// The format of the output. - #[arg( - short, - long, - value_enum, - default_value_t, - value_name("FORMAT"), - ignore_case(true) - )] + #[arg(short, long, value_enum, default_value_t, ignore_case(true))] format: Format, /// Date and time to print. From fdc8f635509922b53d95091b80681bc7333e8021 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 09:56:19 +0000 Subject: [PATCH 50/69] chore(deps): Bump jiff from 0.2.13 to 0.2.14 (#324) Bumps [jiff](https://github.com/BurntSushi/jiff) from 0.2.13 to 0.2.14. - [Release notes](https://github.com/BurntSushi/jiff/releases) - [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.13...jiff-static-0.2.14) --- updated-dependencies: - dependency-name: jiff dependency-version: 0.2.14 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1e1754..583121d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,9 +221,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f02000660d30638906021176af16b17498bd0d12813dbfe7b276d8bc7f3c0806" +checksum = "a194df1107f33c79f4f93d02c80798520551949d59dfad22b6157048a88cca93" dependencies = [ "jiff-static", "log", @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c30758ddd7188629c6713fc45d1188af4f44c90582311d0c8d8c9907f60c48" +checksum = "6c6e1db7ed32c6c71b759497fae34bf7933636f75a251b9e736555da426f6442" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d5ec992..8df5f00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.41", default-features = false, optional = true } -jiff = { version = "0.2.13", default-features = false, optional = true } +jiff = { version = "0.2.14", default-features = false, optional = true } rand = { version = "0.9.1", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From d171c8ab463ab633557fbd6d91c5605e72e89850 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 09:58:40 +0000 Subject: [PATCH 51/69] chore(deps): Bump obi1kenobi/cargo-semver-checks-action from 2.6 to 2.7 (#325) Bumps [obi1kenobi/cargo-semver-checks-action](https://github.com/obi1kenobi/cargo-semver-checks-action) from 2.6 to 2.7. - [Release notes](https://github.com/obi1kenobi/cargo-semver-checks-action/releases) - [Commits](https://github.com/obi1kenobi/cargo-semver-checks-action/compare/v2.6...v2.7) --- updated-dependencies: - dependency-name: obi1kenobi/cargo-semver-checks-action dependency-version: '2.7' dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/SemverChecks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/SemverChecks.yaml b/.github/workflows/SemverChecks.yaml index fd71b82..ebb7746 100644 --- a/.github/workflows/SemverChecks.yaml +++ b/.github/workflows/SemverChecks.yaml @@ -20,4 +20,4 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Check Semantic Versioning - uses: obi1kenobi/cargo-semver-checks-action@v2.6 + uses: obi1kenobi/cargo-semver-checks-action@v2.7 From fff0764dcd4cc2edfbc6c7c9c0153c6f4d2246e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 10:05:51 +0000 Subject: [PATCH 52/69] chore(deps): Bump clap from 4.5.38 to 4.5.39 (#326) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.38 to 4.5.39. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.38...clap_complete-v4.5.39) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.39 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 583121d..ae33d5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.38" +version = "4.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" +checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.38" +version = "4.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" +checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 8df5f00..8a38a86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.98" -clap = { version = "4.5.38", features = ["derive"] } +clap = { version = "4.5.39", features = ["derive"] } proptest = "1.6.0" proptest-derive = "0.5.1" serde_json = "1.0.140" From d32f03924474fa73fae6c8140cdc08620a40aad5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 07:14:33 +0000 Subject: [PATCH 53/69] chore(deps): Bump proptest-derive from 0.5.1 to 0.6.0 (#328) Bumps [proptest-derive](https://github.com/proptest-rs/proptest) from 0.5.1 to 0.6.0. - [Release notes](https://github.com/proptest-rs/proptest/releases) - [Changelog](https://github.com/proptest-rs/proptest/blob/0.6.0/CHANGELOG.md) - [Commits](https://github.com/proptest-rs/proptest/compare/0.5.1...0.6.0) --- updated-dependencies: - dependency-name: proptest-derive dependency-version: 0.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ae33d5f..34af3e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -373,9 +373,9 @@ dependencies = [ [[package]] name = "proptest-derive" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" +checksum = "095a99f75c69734802359b682be8daaf8980296731f6470434ea2c652af1dd30" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 8a38a86..ed0b029 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } anyhow = "1.0.98" clap = { version = "4.5.39", features = ["derive"] } proptest = "1.6.0" -proptest-derive = "0.5.1" +proptest-derive = "0.6.0" serde_json = "1.0.140" serde_test = "1.0.177" test-strategy = "0.4.1" From 344cc02d57453f2bb3c630ff4965000c179c8997 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 07:20:46 +0000 Subject: [PATCH 54/69] chore(deps): Bump proptest from 1.6.0 to 1.7.0 (#327) Bumps [proptest](https://github.com/proptest-rs/proptest) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/proptest-rs/proptest/releases) - [Changelog](https://github.com/proptest-rs/proptest/blob/main/CHANGELOG.md) - [Commits](https://github.com/proptest-rs/proptest/commits) --- updated-dependencies: - dependency-name: proptest dependency-version: 1.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 75 ++++++++++-------------------------------------------- Cargo.toml | 2 +- 2 files changed, 15 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34af3e7..c92d604 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,17 +178,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.3.1" @@ -197,7 +186,7 @@ checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", "libc", - "wasi 0.13.3+wasi-0.2.2", + "wasi", "windows-targets", ] @@ -283,7 +272,7 @@ dependencies = [ "jiff", "proptest", "proptest-derive", - "rand 0.9.1", + "rand", "serde", "serde_json", "serde_test", @@ -353,17 +342,17 @@ dependencies = [ [[package]] name = "proptest" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" +checksum = "6fcdab19deb5195a31cf7726a210015ff1496ba1464fd42cb4f537b8b01b471f" dependencies = [ "bit-set", "bit-vec", "bitflags", "lazy_static", "num-traits", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rand_xorshift", "regex-syntax", "rusty-fork", @@ -397,35 +386,14 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.3", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "rand_chacha", + "rand_core", ] [[package]] @@ -435,16 +403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.3", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.15", + "rand_core", ] [[package]] @@ -453,16 +412,16 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.1", + "getrandom", ] [[package]] name = "rand_xorshift" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -591,7 +550,7 @@ checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567" dependencies = [ "cfg-if", "fastrand", - "getrandom 0.3.1", + "getrandom", "once_cell", "rustix", "windows-sys", @@ -667,12 +626,6 @@ dependencies = [ "libc", ] -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasi" version = "0.13.3+wasi-0.2.2" diff --git a/Cargo.toml b/Cargo.toml index ed0b029..d0da635 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.98" clap = { version = "4.5.39", features = ["derive"] } -proptest = "1.6.0" +proptest = "1.7.0" proptest-derive = "0.6.0" serde_json = "1.0.140" serde_test = "1.0.177" From 7cd931546a1602b5d05f0e8bbe2481ea06ab42a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:54:12 +0000 Subject: [PATCH 55/69] chore(deps): Bump clap from 4.5.39 to 4.5.40 (#329) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.39 to 4.5.40. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.39...clap_complete-v4.5.40) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.40 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c92d604..12000e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.39" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.39" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" dependencies = [ "anstream", "anstyle", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.32" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index d0da635..46d332f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.98" -clap = { version = "4.5.39", features = ["derive"] } +clap = { version = "4.5.40", features = ["derive"] } proptest = "1.7.0" proptest-derive = "0.6.0" serde_json = "1.0.140" From a0351ba9c9c52fafd705a6bb027cc8a1189c0c04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:44:54 +0000 Subject: [PATCH 56/69] chore(deps): Bump jiff from 0.2.14 to 0.2.15 (#330) Bumps [jiff](https://github.com/BurntSushi/jiff) from 0.2.14 to 0.2.15. - [Release notes](https://github.com/BurntSushi/jiff/releases) - [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.14...jiff-static-0.2.15) --- updated-dependencies: - dependency-name: jiff dependency-version: 0.2.15 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12000e4..0a91c79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,9 +210,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a194df1107f33c79f4f93d02c80798520551949d59dfad22b6157048a88cca93" +checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" dependencies = [ "jiff-static", "log", @@ -223,9 +223,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c6e1db7ed32c6c71b759497fae34bf7933636f75a251b9e736555da426f6442" +checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 46d332f..8c9e2a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.41", default-features = false, optional = true } -jiff = { version = "0.2.14", default-features = false, optional = true } +jiff = { version = "0.2.15", default-features = false, optional = true } rand = { version = "0.9.1", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From 0f4ae1fe17be7fe699144b003647f5a8e9340b83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Jun 2025 12:47:42 +0000 Subject: [PATCH 57/69] chore(deps): Bump obi1kenobi/cargo-semver-checks-action from 2.7 to 2.8 (#331) Bumps [obi1kenobi/cargo-semver-checks-action](https://github.com/obi1kenobi/cargo-semver-checks-action) from 2.7 to 2.8. - [Release notes](https://github.com/obi1kenobi/cargo-semver-checks-action/releases) - [Commits](https://github.com/obi1kenobi/cargo-semver-checks-action/compare/v2.7...v2.8) --- updated-dependencies: - dependency-name: obi1kenobi/cargo-semver-checks-action dependency-version: '2.8' dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/SemverChecks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/SemverChecks.yaml b/.github/workflows/SemverChecks.yaml index ebb7746..d408144 100644 --- a/.github/workflows/SemverChecks.yaml +++ b/.github/workflows/SemverChecks.yaml @@ -20,4 +20,4 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Check Semantic Versioning - uses: obi1kenobi/cargo-semver-checks-action@v2.7 + uses: obi1kenobi/cargo-semver-checks-action@v2.8 From e264e581f8f37989f4e80172ccb4865be980a650 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:43:03 +0000 Subject: [PATCH 58/69] chore(deps): Bump Swatinem/rust-cache from 2.7.8 to 2.8.0 (#332) Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.7.8 to 2.8.0. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/v2.7.8...v2.8.0) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-version: 2.8.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/CI.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index ba23562..e3fe7cd 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ matrix.toolchain }} targets: ${{ matrix.target }} - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.8 + uses: Swatinem/rust-cache@v2.8.0 with: key: ${{ matrix.target }} - name: Check a package @@ -102,7 +102,7 @@ jobs: toolchain: ${{ matrix.toolchain }} targets: ${{ matrix.target }} - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.8 + uses: Swatinem/rust-cache@v2.8.0 with: key: ${{ matrix.target }} - name: Run tests @@ -132,7 +132,7 @@ jobs: toolchain: stable components: rustfmt - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.8 + uses: Swatinem/rust-cache@v2.8.0 - name: Check code formatted run: cargo fmt -- --check @@ -148,7 +148,7 @@ jobs: toolchain: stable components: clippy - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.8 + uses: Swatinem/rust-cache@v2.8.0 - name: Check no lint warnings run: cargo clippy -- -D warnings - name: Check no lint warnings (all features) @@ -167,7 +167,7 @@ jobs: with: toolchain: stable - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.8 + uses: Swatinem/rust-cache@v2.8.0 - name: Check no `rustdoc` lint warnings run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items --all-features @@ -182,6 +182,6 @@ jobs: with: toolchain: nightly - name: Cache build artifacts - uses: Swatinem/rust-cache@v2.7.8 + uses: Swatinem/rust-cache@v2.8.0 - name: Run benchmarks run: cargo bench --all-features From f529c072b59a8117aa1eeb00624e1c4213d14cf8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:46:48 +0000 Subject: [PATCH 59/69] chore(deps): Bump test-strategy from 0.4.1 to 0.4.3 (#333) --- updated-dependencies: - dependency-name: test-strategy dependency-version: 0.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 17 +++++++++++++++-- Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a91c79..d93244b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,6 +156,18 @@ dependencies = [ "serde", ] +[[package]] +name = "derive-ex" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bba95f299f6b9cd47f68a847eca2ae9060a2713af532dc35c342065544845407" +dependencies = [ + "proc-macro2", + "quote", + "structmeta", + "syn", +] + [[package]] name = "errno" version = "0.3.10" @@ -558,10 +570,11 @@ dependencies = [ [[package]] name = "test-strategy" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95eb2d223f5cd3ec8dd7874cf4ada95c9cf2b5ed84ecfb1046d9aefee0c28b12" +checksum = "43b12f9683de37f9980e485167ee624bfaa0b6b04da661e98e25ef9c2669bc1b" dependencies = [ + "derive-ex", "proc-macro2", "quote", "structmeta", diff --git a/Cargo.toml b/Cargo.toml index 8c9e2a2..6c103af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,7 @@ proptest = "1.7.0" proptest-derive = "0.6.0" serde_json = "1.0.140" serde_test = "1.0.177" -test-strategy = "0.4.1" +test-strategy = "0.4.3" time = { version = "0.3.41", features = ["parsing"] } [features] From f4c29876b7eddb2b82fd3a9c07fcdd23367f5afb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Jul 2025 11:36:23 +0000 Subject: [PATCH 60/69] chore(deps): Bump clap from 4.5.40 to 4.5.41 (#334) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.40 to 4.5.41. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.40...clap_complete-v4.5.41) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.41 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d93244b..77aeda3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" dependencies = [ "anstream", "anstyle", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 6c103af..4e72ce7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ time = { version = "0.3.41", default-features = false, features = ["macros"] } [dev-dependencies] anyhow = "1.0.98" -clap = { version = "4.5.40", features = ["derive"] } +clap = { version = "4.5.41", features = ["derive"] } proptest = "1.7.0" proptest-derive = "0.6.0" serde_json = "1.0.140" From adad056ea738d6c0d0a5b9ab4beb184e197a50da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 00:44:52 +0000 Subject: [PATCH 61/69] chore(deps): Bump serde_json from 1.0.140 to 1.0.141 (#336) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.140 to 1.0.141. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.140...v1.0.141) --- updated-dependencies: - dependency-name: serde_json dependency-version: 1.0.141 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77aeda3..9986de5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -495,9 +495,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 4e72ce7..42b93a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ anyhow = "1.0.98" clap = { version = "4.5.41", features = ["derive"] } proptest = "1.7.0" proptest-derive = "0.6.0" -serde_json = "1.0.140" +serde_json = "1.0.141" serde_test = "1.0.177" test-strategy = "0.4.3" time = { version = "0.3.41", features = ["parsing"] } From 080b6c80eb1e1a77dadaed3124f3915a6e4cda26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 00:45:57 +0000 Subject: [PATCH 62/69] chore(deps): Bump rand from 0.9.1 to 0.9.2 (#335) Bumps [rand](https://github.com/rust-random/rand) from 0.9.1 to 0.9.2. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/rand_core-0.9.1...rand_core-0.9.2) --- updated-dependencies: - dependency-name: rand dependency-version: 0.9.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9986de5..c86f2b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,9 +400,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha", "rand_core", diff --git a/Cargo.toml b/Cargo.toml index 42b93a5..1399cfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ required-features = ["std"] [dependencies] chrono = { version = "0.4.41", default-features = false, optional = true } jiff = { version = "0.2.15", default-features = false, optional = true } -rand = { version = "0.9.1", default-features = false, optional = true } +rand = { version = "0.9.2", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } time = { version = "0.3.41", default-features = false, features = ["macros"] } From 5a61cb43af8ff941963de9241b0f55e788a7547f Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Mon, 28 Jul 2025 22:40:40 +0900 Subject: [PATCH 63/69] chore(release): Update version to 0.11.2 --- .bumpversion.toml | 2 +- CHANGELOG.adoc | 2 +- Cargo.lock | 228 +++++++++++++++++++++++++++++++--------------- Cargo.toml | 2 +- src/lib.rs | 2 +- 5 files changed, 160 insertions(+), 76 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index d03f5a3..9892523 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [tool.bumpversion] -current_version = "0.11.1" +current_version = "0.11.2" [[tool.bumpversion.files]] filename = "src/lib.rs" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index ab19416..d4fb54e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. -== {compare-url}/v0.11.1\...HEAD[Unreleased] +== {compare-url}/v0.11.1\...v0.11.2[0.11.2] - 2025-07-28 === Changed diff --git a/Cargo.lock b/Cargo.lock index c86f2b2..0551484 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" dependencies = [ "anstyle", "anstyle-parse", @@ -19,37 +19,37 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" dependencies = [ "anstyle", - "once_cell", - "windows-sys", + "once_cell_polyfill", + "windows-sys 0.59.0", ] [[package]] @@ -60,9 +60,9 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bit-set" @@ -81,15 +81,15 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "chrono" @@ -136,21 +136,21 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "deranged" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", "serde", @@ -170,12 +170,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.60.2", ] [[package]] @@ -192,14 +192,14 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", + "r-efi", "wasi", - "windows-targets", ] [[package]] @@ -252,31 +252,31 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "linux-raw-sys" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "log" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "nt-time" -version = "0.11.1" +version = "0.11.2" dependencies = [ "anyhow", "chrono", @@ -309,15 +309,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "portable-atomic" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "portable-atomic-util" @@ -345,9 +351,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -398,6 +404,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "rand" version = "0.9.2" @@ -444,15 +456,15 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "1.0.2" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.60.2", ] [[package]] @@ -545,9 +557,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.100" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -556,16 +568,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.18.0" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ - "cfg-if", "fastrand", "getrandom", "once_cell", "rustix", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -641,9 +652,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -654,7 +665,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", ] [[package]] @@ -663,14 +683,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -679,71 +715,119 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags", ] [[package]] name = "zerocopy" -version = "0.8.23" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.23" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 1399cfd..88d29c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "nt-time" -version = "0.11.1" +version = "0.11.2" authors = ["Shun Sakai "] edition = "2024" rust-version = "1.85.0" diff --git a/src/lib.rs b/src/lib.rs index 933802f..dd934fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,7 +108,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -#![doc(html_root_url = "https://docs.rs/nt-time/0.11.1/")] +#![doc(html_root_url = "https://docs.rs/nt-time/0.11.2/")] #![no_std] #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))] // Lint levels of rustc. From c4e7cda6915e569a40c24144c2f3e3a637543556 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Tue, 29 Jul 2025 22:34:47 +0900 Subject: [PATCH 64/69] chore!: Change MS-DOS date and time conversion methods Handle only the local date and time with the resolution of 2 seconds, just like the `FileTimeToDosDateTime` and `DosDateTimeToFileTime` functions in the Win32 API. --- CHANGELOG.adoc | 7 + benches/dos_date_time.rs | 4 +- examples/dos2ft.rs | 19 +- examples/ft2dos.rs | 15 +- src/error.rs | 32 +- src/file_time/dos_date_time.rs | 576 +++++---------------------------- src/lib.rs | 14 +- 7 files changed, 112 insertions(+), 555 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index d4fb54e..b9ab901 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,13 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. +== {compare-url}/v0.11.2\...HEAD[Unreleased] + +=== Changed + +* Change MS-DOS date and time conversion methods to handle only the local date + and time with the resolution of 2 seconds ({pull-request-url}/338[#338]) + == {compare-url}/v0.11.1\...v0.11.2[0.11.2] - 2025-07-28 === Changed diff --git a/benches/dos_date_time.rs b/benches/dos_date_time.rs index c413011..7da29eb 100644 --- a/benches/dos_date_time.rs +++ b/benches/dos_date_time.rs @@ -13,12 +13,12 @@ use test::Bencher; fn to_dos_date_time(b: &mut Bencher) { b.iter(|| { FileTime::new(119_600_064_000_000_000) - .to_dos_date_time(None) + .to_dos_date_time() .unwrap() }); } #[bench] fn from_dos_date_time(b: &mut Bencher) { - b.iter(|| FileTime::from_dos_date_time(0x0021, u16::MIN, None, None).unwrap()); + b.iter(|| FileTime::from_dos_date_time(0x0021, u16::MIN).unwrap()); } diff --git a/examples/dos2ft.rs b/examples/dos2ft.rs index a509424..824d515 100644 --- a/examples/dos2ft.rs +++ b/examples/dos2ft.rs @@ -6,21 +6,11 @@ use anyhow::Context; use clap::Parser; -use nt_time::{FileTime, time::UtcOffset}; +use nt_time::FileTime; #[derive(Debug, Parser)] #[command(version, about)] struct Opt { - /// Additional finer resolution of MS-DOS date and time. - #[arg(short, long)] - resolution: Option, - - /// UTC offset of MS-DOS date and time. - /// - /// takes the UTC offset in 15 minute intervals. - #[arg(short, long, allow_hyphen_values(true))] - offset: Option, - /// The MS-DOS date to convert. date: u16, @@ -31,12 +21,7 @@ struct Opt { fn main() -> anyhow::Result<()> { let opt = Opt::parse(); - let offset = opt - .offset - .map(|o| UtcOffset::from_whole_seconds(i32::from(o) * 900)) - .transpose() - .context("could not create the UTC offset")?; - let ft = FileTime::from_dos_date_time(opt.date, opt.time, opt.resolution, offset) + let ft = FileTime::from_dos_date_time(opt.date, opt.time) .context("could not convert date and time")?; println!("{ft}"); Ok(()) diff --git a/examples/ft2dos.rs b/examples/ft2dos.rs index 3472fe4..8355961 100644 --- a/examples/ft2dos.rs +++ b/examples/ft2dos.rs @@ -6,17 +6,11 @@ use anyhow::Context; use clap::Parser; -use nt_time::{FileTime, time::UtcOffset}; +use nt_time::FileTime; #[derive(Debug, Parser)] #[command(version, about)] struct Opt { - /// UTC offset of MS-DOS date and time. - /// - /// takes the UTC offset in 15 minute intervals. - #[arg(short, long, allow_hyphen_values(true))] - offset: Option, - /// File time to convert. time: FileTime, } @@ -24,14 +18,9 @@ struct Opt { fn main() -> anyhow::Result<()> { let opt = Opt::parse(); - let offset = opt - .offset - .map(|o| UtcOffset::from_whole_seconds(i32::from(o) * 900)) - .transpose() - .context("could not create the UTC offset")?; let dt = opt .time - .to_dos_date_time(offset) + .to_dos_date_time() .context("could not convert time")?; println!("{dt:?}"); Ok(()) diff --git a/src/error.rs b/src/error.rs index d94238c..4bba0fb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -30,10 +30,10 @@ impl DosDateTimeRangeError { /// ``` /// # use nt_time::{FileTime, error::DosDateTimeRangeErrorKind}; /// # - /// let err = FileTime::NT_TIME_EPOCH.to_dos_date_time(None).unwrap_err(); + /// let err = FileTime::NT_TIME_EPOCH.to_dos_date_time().unwrap_err(); /// assert_eq!(err.kind(), DosDateTimeRangeErrorKind::Negative); /// - /// let err = FileTime::MAX.to_dos_date_time(None).unwrap_err(); + /// let err = FileTime::MAX.to_dos_date_time().unwrap_err(); /// assert_eq!(err.kind(), DosDateTimeRangeErrorKind::Overflow); /// ``` #[must_use] @@ -69,7 +69,7 @@ pub enum DosDateTimeRangeErrorKind { /// Value was too big to be represented as [MS-DOS date and time]. /// - /// This means the date and time was after "2107-12-31 23:59:59.990000000". + /// This means the date and time was after "2107-12-31 23:59:58". /// /// [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time Overflow, @@ -79,12 +79,8 @@ impl fmt::Display for DosDateTimeRangeErrorKind { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Negative => { - write!(f, "date and time is before `1980-01-01 00:00:00`") - } - Self::Overflow => { - write!(f, "date and time is after `2107-12-31 23:59:59.990000000`") - } + Self::Negative => write!(f, "date and time is before `1980-01-01 00:00:00`"), + Self::Overflow => write!(f, "date and time is after `2107-12-31 23:59:58`"), } } } @@ -156,15 +152,11 @@ impl fmt::Display for FileTimeRangeErrorKind { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Negative => { - write!(f, "date and time is before `1601-01-01 00:00:00 UTC`") - } - Self::Overflow => { - write!( - f, - "date and time is after `+60056-05-28 05:36:10.955161500 UTC`" - ) - } + Self::Negative => write!(f, "date and time is before `1601-01-01 00:00:00 UTC`"), + Self::Overflow => write!( + f, + "date and time is after `+60056-05-28 05:36:10.955161500 UTC`" + ), } } } @@ -306,7 +298,7 @@ mod tests { "{}", DosDateTimeRangeError::new(DosDateTimeRangeErrorKind::Overflow) ), - "date and time is after `2107-12-31 23:59:59.990000000`" + "date and time is after `2107-12-31 23:59:58`" ); } @@ -403,7 +395,7 @@ mod tests { ); assert_eq!( format!("{}", DosDateTimeRangeErrorKind::Overflow), - "date and time is after `2107-12-31 23:59:59.990000000`" + "date and time is after `2107-12-31 23:59:58`" ); } diff --git a/src/file_time/dos_date_time.rs b/src/file_time/dos_date_time.rs index c176e23..1b6d14e 100644 --- a/src/file_time/dos_date_time.rs +++ b/src/file_time/dos_date_time.rs @@ -7,38 +7,27 @@ //! //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -use time::{Date, OffsetDateTime, Time, UtcOffset, error::ComponentRange, macros::offset}; +use time::{Date, OffsetDateTime, Time, error::ComponentRange}; use super::FileTime; use crate::error::{DosDateTimeRangeError, DosDateTimeRangeErrorKind}; impl FileTime { + #[allow(clippy::missing_panics_doc)] /// Returns [MS-DOS date and time] which represents the same date and time /// as this `FileTime`. This date and time is used as the timestamp such as - /// [FAT], [exFAT] or [ZIP] file format. + /// [FAT] or [ZIP] file format. /// - /// This method returns a `(date, time, resolution, offset)` tuple if the - /// result is [`Ok`]. + /// This method returns a `(date, time)` tuple if the result is [`Ok`]. /// - /// `date` and `time` represents the local date and time. This date and time - /// has no notion of time zone. The resolution of MS-DOS date and time is 2 - /// seconds, but additional [finer resolution] (10 ms units) can be - /// provided. `resolution` represents this additional finer resolution. - /// - /// When the `offset` parameter is [`Some`], converts `date` and `time` from - /// UTC to the local date and time in the provided time zone and returns it - /// with the [UTC offset]. When the `offset` parameter is [`None`] or is not - /// a multiple of 15 minute intervals, returns the UTC date and time as a - /// date and time and [`None`] as the UTC offset. + /// `date` and `time` represents the local date and time, and has no notion + /// of time zone. /// ///
/// - /// Note that exFAT supports `resolution` for creation and last modified - /// times, and the `offset` return value for these times and last access - /// time, but other file systems and file formats may not support these. For - /// example, the built-in timestamp of ZIP used for last modified time only - /// records `date` and `time`, not `resolution` and the `offset` return - /// value. + /// The resolution of MS-DOS date and time is 2 seconds. So this method + /// rounds towards zero, truncating any fractional part of the exact result + /// of dividing seconds by 2. /// ///
/// @@ -47,92 +36,41 @@ impl FileTime { /// Returns [`Err`] if the resulting date and time is out of range for /// MS-DOS date and time. /// - /// # Panics - /// - /// Panics if the `offset` parameter is out of range for the [OffsetFromUtc - /// field]. - /// /// # Examples /// /// ``` - /// # use nt_time::{FileTime, time::macros::offset}; + /// # use nt_time::FileTime; /// # - /// // `1980-01-01 00:00:00 UTC`. + /// // From `1980-01-01 00:00:00 UTC` to `1980-01-01 00:00:00`. /// assert_eq!( - /// FileTime::new(119_600_064_000_000_000).to_dos_date_time(None), - /// Ok((0x0021, u16::MIN, u8::MIN, None)) + /// FileTime::new(119_600_064_000_000_000).to_dos_date_time(), + /// Ok((0x0021, u16::MIN)) /// ); - /// // `2107-12-31 23:59:59 UTC`. + /// // From `2107-12-31 23:59:59 UTC` to `2107-12-31 23:59:58`. /// assert_eq!( - /// FileTime::new(159_992_927_990_000_000).to_dos_date_time(None), - /// Ok((0xff9f, 0xbf7d, 100, None)) + /// FileTime::new(159_992_927_990_000_000).to_dos_date_time(), + /// Ok((0xff9f, 0xbf7d)) /// ); /// /// // Before `1980-01-01 00:00:00 UTC`. /// assert!( /// FileTime::new(119_600_063_990_000_000) - /// .to_dos_date_time(None) + /// .to_dos_date_time() /// .is_err() /// ); - /// // After `2107-12-31 23:59:59.990000000 UTC`. + /// // After `2107-12-31 23:59:59.999999900 UTC`. /// assert!( /// FileTime::new(159_992_928_000_000_000) - /// .to_dos_date_time(None) + /// .to_dos_date_time() /// .is_err() /// ); - /// - /// // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:25:00 -08:00`. - /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:00))), - /// Ok((0x2d7a, 0x9b20, u8::MIN, Some(offset!(-08:00)))) - /// ); - /// ``` - /// - /// When the UTC offset is not a multiple of 15 minute intervals, returns - /// the UTC date and time: - /// - /// ``` - /// # use nt_time::{FileTime, time::macros::offset}; - /// # - /// // `2002-11-27 03:25:00 UTC`. - /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:01))), - /// Ok((0x2d7b, 0x1b20, u8::MIN, None)) - /// ); - /// // `2002-11-27 03:25:00 UTC`. - /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:14))), - /// Ok((0x2d7b, 0x1b20, u8::MIN, None)) - /// ); - /// - /// // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:10:00 -08:15`. - /// assert_eq!( - /// FileTime::new(126_828_411_000_000_000).to_dos_date_time(Some(offset!(-08:15))), - /// Ok((0x2d7a, 0x9940, u8::MIN, Some(offset!(-08:15)))) - /// ); /// ``` /// /// [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time /// [FAT]: https://en.wikipedia.org/wiki/File_Allocation_Table - /// [exFAT]: https://en.wikipedia.org/wiki/ExFAT /// [ZIP]: https://en.wikipedia.org/wiki/ZIP_(file_format) - /// [finer resolution]: https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification#749-10msincrement-fields - /// [UTC offset]: https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification#7410-utcoffset-fields - /// [OffsetFromUtc field]: https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification#74101-offsetfromutc-field - pub fn to_dos_date_time( - self, - offset: Option, - ) -> Result<(u16, u16, u8, Option), DosDateTimeRangeError> { - let offset = offset.filter(|o| o.whole_seconds() % 900 == 0); - if let Some(o) = offset { - // The UTC offset must be in the range of a 7-bit signed integer. - assert!((offset!(-16:00)..=offset!(+15:45)).contains(&o)); - } - - let dt = OffsetDateTime::try_from(self) - .ok() - .and_then(|dt| dt.checked_to_offset(offset.unwrap_or(UtcOffset::UTC))) - .ok_or(DosDateTimeRangeErrorKind::Overflow)?; + pub fn to_dos_date_time(self) -> Result<(u16, u16), DosDateTimeRangeError> { + let dt = OffsetDateTime::try_from(self).map_err(|_| DosDateTimeRangeErrorKind::Overflow)?; match dt.year() { ..=1979 => Err(DosDateTimeRangeErrorKind::Negative.into()), @@ -148,39 +86,18 @@ impl FileTime { let (hour, minute, second) = (dt.hour(), dt.minute(), dt.second() / 2); let time = (u16::from(hour) << 11) | (u16::from(minute) << 5) | u16::from(second); - let resolution = ((dt.time() - - Time::from_hms(hour, minute, second * 2) - .expect("the MS-DOS time should be in the range of `Time`")) - .whole_milliseconds() - / 10) - .try_into() - .expect("resolution should be in the range of `u8`"); - debug_assert!(resolution <= 199); - - Ok((date, time, resolution, offset)) + Ok((date, time)) } } } + #[allow(clippy::missing_panics_doc)] /// Creates a `FileTime` with the given [MS-DOS date and time]. This date - /// and time is used as the timestamp such as [FAT], [exFAT] or [ZIP] file - /// format. - /// - /// When `resolution` is [`Some`], additional [finer resolution] (10 ms - /// units) is added to `time`. - /// - /// When `offset` is [`Some`], converts `date` and `time` from the local - /// date and time in the provided time zone to UTC. When `offset` is - /// [`None`] or is not a multiple of 15 minute intervals, assumes the - /// provided date and time is in UTC. + /// and time is used as the timestamp such as [FAT] or [ZIP] file format. /// ///
/// - /// Note that exFAT supports `resolution` for creation and last modified - /// times, and `offset` for these times and last access time, but other file - /// systems and file formats may not support these. For example, the - /// built-in timestamp of ZIP used for last modified time only records - /// `date` and `time`, not `resolution` and `offset`. + /// The time zone for the local date and time is assumed to be UTC. /// ///
/// @@ -188,101 +105,32 @@ impl FileTime { /// /// Returns [`Err`] if `date` or `time` is an invalid date and time. /// - /// # Panics - /// - /// Panics if any of the following are true: - /// - /// - `resolution` is greater than 199. - /// - `offset` is out of range for the [OffsetFromUtc field]. - /// /// # Examples /// /// ``` - /// # use nt_time::{FileTime, time::macros::offset}; + /// # use nt_time::FileTime; /// # - /// // `1980-01-01 00:00:00 UTC`. + /// // From `1980-01-01 00:00:00` to `1980-01-01 00:00:00 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0x0021, u16::MIN, None, None), + /// FileTime::from_dos_date_time(0x0021, u16::MIN), /// Ok(FileTime::new(119_600_064_000_000_000)) /// ); - /// // `2107-12-31 23:59:59 UTC`. + /// // From `2107-12-31 23:59:58` to `2107-12-31 23:59:58 UTC`. /// assert_eq!( - /// FileTime::from_dos_date_time(0xff9f, 0xbf7d, Some(100), None), - /// Ok(FileTime::new(159_992_927_990_000_000)) - /// ); - /// - /// // From `2002-11-26 19:25:00 -08:00` to `2002-11-27 03:25:00 UTC`. - /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:00))), - /// Ok(FileTime::new(126_828_411_000_000_000)) + /// FileTime::from_dos_date_time(0xff9f, 0xbf7d), + /// Ok(FileTime::new(159_992_927_980_000_000)) /// ); /// /// // The Day field is 0. - /// assert!(FileTime::from_dos_date_time(0x0020, u16::MIN, None, None).is_err()); + /// assert!(FileTime::from_dos_date_time(0x0020, u16::MIN).is_err()); /// // The DoubleSeconds field is 30. - /// assert!(FileTime::from_dos_date_time(0x0021, 0x001e, None, None).is_err()); - /// ``` - /// - /// When the [UTC offset] is not a multiple of 15 minute intervals, assumes - /// the provided date and time is in UTC: - /// - /// ``` - /// # use nt_time::{FileTime, time::macros::offset}; - /// # - /// // From `2002-11-26 19:25:00 -08:01` to `2002-11-26 19:25:00 UTC`. - /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:01))), - /// Ok(FileTime::new(126_828_123_000_000_000)) - /// ); - /// // From `2002-11-26 19:25:00 -08:14` to `2002-11-26 19:25:00 UTC`. - /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:14))), - /// Ok(FileTime::new(126_828_123_000_000_000)) - /// ); - /// - /// // From `2002-11-26 19:25:00 -08:15` to `2002-11-27 03:40:00 UTC`. - /// assert_eq!( - /// FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:15))), - /// Ok(FileTime::new(126_828_420_000_000_000)) - /// ); - /// ``` - /// - /// Additional finer resolution must be in the range 0 to 199: - /// - /// ```should_panic - /// # use nt_time::FileTime; - /// # - /// let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, Some(200), None); + /// assert!(FileTime::from_dos_date_time(0x0021, 0x001e).is_err()); /// ``` /// /// [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time /// [FAT]: https://en.wikipedia.org/wiki/File_Allocation_Table - /// [exFAT]: https://en.wikipedia.org/wiki/ExFAT /// [ZIP]: https://en.wikipedia.org/wiki/ZIP_(file_format) - /// [finer resolution]: https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification#749-10msincrement-fields - /// [OffsetFromUtc field]: https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification#74101-offsetfromutc-field - /// [UTC offset]: https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification#7410-utcoffset-fields - pub fn from_dos_date_time( - date: u16, - time: u16, - resolution: Option, - offset: Option, - ) -> Result { - use core::time::Duration; - - if let Some(res) = resolution { - assert!(res <= 199); - } - let resolution = resolution.map_or(Duration::ZERO, |res| { - Duration::from_millis(u64::from(res) * 10) - }); - - let offset = offset.filter(|o| o.whole_seconds() % 900 == 0); - if let Some(o) = offset { - // The UTC offset must be in the range of a 7-bit signed integer. - assert!((offset!(-16:00)..=offset!(+15:45)).contains(&o)); - } - + pub fn from_dos_date_time(date: u16, time: u16) -> Result { let (year, month, day) = ( (1980 + (date >> 9)).into(), u8::try_from((date >> 5) & 0x0f) @@ -305,9 +153,9 @@ impl FileTime { .try_into() .expect("second should be in the range of `u8`"), ); - let time = Time::from_hms(hour, minute, second)? + resolution; + let time = Time::from_hms(hour, minute, second)?; - let ft = OffsetDateTime::new_in_offset(date, time, offset.unwrap_or(UtcOffset::UTC)) + let ft = OffsetDateTime::new_utc(date, time) .try_into() .expect("MS-DOS date and time should be in the range of `FileTime`"); Ok(ft) @@ -323,28 +171,14 @@ mod tests { // `1979-12-31 23:59:58 UTC`. assert_eq!( FileTime::new(119_600_063_980_000_000) - .to_dos_date_time(None) + .to_dos_date_time() .unwrap_err(), DosDateTimeRangeErrorKind::Negative.into() ); // `1979-12-31 23:59:59 UTC`. assert_eq!( FileTime::new(119_600_063_990_000_000) - .to_dos_date_time(None) - .unwrap_err(), - DosDateTimeRangeErrorKind::Negative.into() - ); - // `1980-01-01 00:59:58 UTC`. - assert_eq!( - FileTime::new(119_600_099_980_000_000) - .to_dos_date_time(Some(offset!(-01:00))) - .unwrap_err(), - DosDateTimeRangeErrorKind::Negative.into() - ); - // `1980-01-01 00:59:59 UTC`. - assert_eq!( - FileTime::new(119_600_099_990_000_000) - .to_dos_date_time(Some(offset!(-01:00))) + .to_dos_date_time() .unwrap_err(), DosDateTimeRangeErrorKind::Negative.into() ); @@ -358,171 +192,58 @@ mod tests { use proptest::prop_assert_eq; prop_assert_eq!( - FileTime::new(ft).to_dos_date_time(None).unwrap_err(), + FileTime::new(ft).to_dos_date_time().unwrap_err(), DosDateTimeRangeErrorKind::Negative.into() ); } #[test] fn to_dos_date_time() { - // `1980-01-01 00:00:00 UTC`. + // From `1980-01-01 00:00:00 UTC` to `1980-01-01 00:00:00`. assert_eq!( FileTime::new(119_600_064_000_000_000) - .to_dos_date_time(None) + .to_dos_date_time() .unwrap(), - (0x0021, u16::MIN, u8::MIN, None) + (0x0021, u16::MIN) ); - // `1980-01-01 00:00:01 UTC`. + // From `1980-01-01 00:00:01 UTC` to `1980-01-01 00:00:00`. assert_eq!( FileTime::new(119_600_064_010_000_000) - .to_dos_date_time(None) - .unwrap(), - (0x0021, u16::MIN, 100, None) - ); - // . - // - // `2018-11-17 10:38:30 UTC`. - assert_eq!( - FileTime::new(131_869_247_100_000_000) - .to_dos_date_time(None) - .unwrap(), - (0x4d71, 0x54cf, u8::MIN, None) - ); - // `2107-12-31 23:59:58 UTC`. - assert_eq!( - FileTime::new(159_992_927_980_000_000) - .to_dos_date_time(None) - .unwrap(), - (0xff9f, 0xbf7d, u8::MIN, None) - ); - // `2107-12-31 23:59:59 UTC`. - assert_eq!( - FileTime::new(159_992_927_990_000_000) - .to_dos_date_time(None) + .to_dos_date_time() .unwrap(), - (0xff9f, 0xbf7d, 100, None) + (0x0021, u16::MIN) ); - - // `1980-01-01 00:00:00.010000000 UTC`. - assert_eq!( - FileTime::new(119_600_064_000_100_000) - .to_dos_date_time(None) - .unwrap(), - (0x0021, u16::MIN, 1, None) - ); - // `1980-01-01 00:00:00.100000000 UTC`. - assert_eq!( - FileTime::new(119_600_064_001_000_000) - .to_dos_date_time(None) - .unwrap(), - (0x0021, u16::MIN, 10, None) - ); - // `1980-01-01 00:00:01.990000000 UTC`. - assert_eq!( - FileTime::new(119_600_064_019_900_000) - .to_dos_date_time(None) - .unwrap(), - (0x0021, u16::MIN, 199, None) - ); - // `1980-01-01 00:00:02 UTC`. - assert_eq!( - FileTime::new(119_600_064_020_000_000) - .to_dos_date_time(None) - .unwrap(), - (0x0021, 0x0001, u8::MIN, None) - ); - // . // - // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:25:00 -08:00`. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08:00))) - .unwrap(), - (0x2d7a, 0x9b20, u8::MIN, Some(offset!(-08:00))) - ); - // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:25:00 -08:00`. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08))) - .unwrap(), - (0x2d7a, 0x9b20, u8::MIN, Some(offset!(-08))) - ); - // `2002-11-27 03:25:00 UTC`. - // - // When the UTC offset is not a multiple of 15 minute intervals, returns the UTC - // date and time. + // From `2002-11-27 03:25:00 UTC` to `2002-11-27 03:25:00`. assert_eq!( FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08:00:01))) + .to_dos_date_time() .unwrap(), - (0x2d7b, 0x1b20, u8::MIN, None) + (0x2d7b, 0x1b20) ); - // `2002-11-27 03:25:00 UTC`. - // - // When the UTC offset is not a multiple of 15 minute intervals, returns the UTC - // date and time. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08:01))) - .unwrap(), - (0x2d7b, 0x1b20, u8::MIN, None) - ); - // `2002-11-27 03:25:00 UTC`. - // - // When the UTC offset is not a multiple of 15 minute intervals, returns the UTC - // date and time. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08:14))) - .unwrap(), - (0x2d7b, 0x1b20, u8::MIN, None) - ); - // `2002-11-27 03:25:00 UTC`. + // . // - // When the UTC offset is not a multiple of 15 minute intervals, returns the UTC - // date and time. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08:14:59))) - .unwrap(), - (0x2d7b, 0x1b20, u8::MIN, None) - ); - // From `2002-11-27 03:25:00 UTC` to `2002-11-26 19:10:00 -08:15`. + // From `2018-11-17 10:38:30 UTC` to `2018-11-17 10:38:30`. assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(-08:15))) - .unwrap(), - (0x2d7a, 0x9940, u8::MIN, Some(offset!(-08:15))) - ); - // `2002-11-27 03:25:00 UTC`. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(UtcOffset::UTC)) - .unwrap(), - (0x2d7b, 0x1b20, u8::MIN, Some(UtcOffset::UTC)) - ); - // `2002-11-27 03:25:00 UTC`. - assert_eq!( - FileTime::new(126_828_411_000_000_000) - .to_dos_date_time(Some(offset!(+00:00))) + FileTime::new(131_869_247_100_000_000) + .to_dos_date_time() .unwrap(), - (0x2d7b, 0x1b20, u8::MIN, Some(UtcOffset::UTC)) + (0x4d71, 0x54cf) ); - - // From `1980-01-01 00:00:00 UTC` to `1980-01-01 15:45:00 +15:45`. + // From `2107-12-31 23:59:58 UTC` to `2107-12-31 23:59:58`. assert_eq!( - FileTime::new(119_600_064_000_000_000) - .to_dos_date_time(Some(offset!(+15:45))) + FileTime::new(159_992_927_980_000_000) + .to_dos_date_time() .unwrap(), - (0x0021, 0x7da0, u8::MIN, Some(offset!(+15:45))) + (0xff9f, 0xbf7d) ); - // From `2107-12-31 23:59:58 UTC` to `2107-12-31 07:59:58 -16:00`. + // From `2107-12-31 23:59:59 UTC` to `2107-12-31 23:59:58`. assert_eq!( - FileTime::new(159_992_927_980_000_000) - .to_dos_date_time(Some(offset!(-16:00))) + FileTime::new(159_992_927_990_000_000) + .to_dos_date_time() .unwrap(), - (0xff9f, 0x3f7d, u8::MIN, Some(offset!(-16:00))) + (0xff9f, 0xbf7d) ); } @@ -533,7 +254,7 @@ mod tests { ) { use proptest::prop_assert; - prop_assert!(FileTime::new(ft).to_dos_date_time(None).is_ok()); + prop_assert!(FileTime::new(ft).to_dos_date_time().is_ok()); } #[test] @@ -541,14 +262,7 @@ mod tests { // `2108-01-01 00:00:00 UTC`. assert_eq!( FileTime::new(159_992_928_000_000_000) - .to_dos_date_time(None) - .unwrap_err(), - DosDateTimeRangeErrorKind::Overflow.into() - ); - // `2107-12-31 23:00:00 UTC`. - assert_eq!( - FileTime::new(159_992_892_000_000_000) - .to_dos_date_time(Some(offset!(+01:00))) + .to_dos_date_time() .unwrap_err(), DosDateTimeRangeErrorKind::Overflow.into() ); @@ -562,140 +276,36 @@ mod tests { use proptest::prop_assert_eq; prop_assert_eq!( - FileTime::new(ft).to_dos_date_time(None).unwrap_err(), + FileTime::new(ft).to_dos_date_time().unwrap_err(), DosDateTimeRangeErrorKind::Overflow.into() ); } - #[test] - #[should_panic] - fn to_dos_date_time_with_invalid_positive_offset() { - // From `1980-01-01 00:00:00 UTC` to `1980-01-01 16:00:00 +16:00`. - let _ = FileTime::new(119_600_064_000_000_000).to_dos_date_time(Some(offset!(+16:00))); - } - - #[test] - #[should_panic] - fn to_dos_date_time_with_invalid_negative_offset() { - // From `2107-12-31 23:59:58 UTC` to `2107-12-31 07:44:58 -16:15`. - let _ = FileTime::new(159_992_927_980_000_000).to_dos_date_time(Some(offset!(-16:15))); - } - #[test] fn from_dos_date_time() { - // `1980-01-01 00:00:00 UTC`. + // From `1980-01-01 00:00:00` to `1980-01-01 00:00:00 UTC`. assert_eq!( - FileTime::from_dos_date_time(0x0021, u16::MIN, None, None).unwrap(), + FileTime::from_dos_date_time(0x0021, u16::MIN).unwrap(), FileTime::new(119_600_064_000_000_000) ); - // `1980-01-01 00:00:01 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x0021, u16::MIN, Some(100), None).unwrap(), - FileTime::new(119_600_064_010_000_000) - ); - // . - // - // `2018-11-17 10:38:30 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x4d71, 0x54cf, None, None).unwrap(), - FileTime::new(131_869_247_100_000_000) - ); - // `2107-12-31 23:59:58 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0xff9f, 0xbf7d, None, None).unwrap(), - FileTime::new(159_992_927_980_000_000) - ); - // `2107-12-31 23:59:59 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0xff9f, 0xbf7d, Some(100), None).unwrap(), - FileTime::new(159_992_927_990_000_000) - ); - - // `1980-01-01 00:00:00.010000000 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x0021, u16::MIN, Some(1), None).unwrap(), - FileTime::new(119_600_064_000_100_000) - ); - // `1980-01-01 00:00:00.100000000 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x0021, u16::MIN, Some(10), None).unwrap(), - FileTime::new(119_600_064_001_000_000) - ); - // `1980-01-01 00:00:01.990000000 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x0021, u16::MIN, Some(199), None).unwrap(), - FileTime::new(119_600_064_019_900_000) - ); - // . // - // From `2002-11-26 19:25:00 -08:00` to `2002-11-27 03:25:00 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:00))).unwrap(), - FileTime::new(126_828_411_000_000_000) - ); - // From `2002-11-26 19:25:00 -08:00` to `2002-11-27 03:25:00 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08))).unwrap(), - FileTime::new(126_828_411_000_000_000) - ); - // From `2002-11-26 19:25:00 -08:00:01` to `2002-11-26 19:25:00 UTC`. - // - // When the UTC offset is not a multiple of 15 minute intervals, assumes the - // provided date and time is in UTC. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:00:01))).unwrap(), - FileTime::new(126_828_123_000_000_000) - ); - // From `2002-11-26 19:25:00 -08:01` to `2002-11-26 19:25:00 UTC`. - // - // When the UTC offset is not a multiple of 15 minute intervals, assumes the - // provided date and time is in UTC. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:01))).unwrap(), - FileTime::new(126_828_123_000_000_000) - ); - // From `2002-11-26 19:25:00 -08:14` to `2002-11-26 19:25:00 UTC`. - // - // When the UTC offset is not a multiple of 15 minute intervals, assumes the - // provided date and time is in UTC. + // From `2002-11-26 19:25:00` to `2002-11-26 19:25:00 UTC`. assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:14))).unwrap(), + FileTime::from_dos_date_time(0x2d7a, 0x9b20).unwrap(), FileTime::new(126_828_123_000_000_000) ); - // From `2002-11-26 19:25:00 -08:14:59` to `2002-11-26 19:25:00 UTC`. + // . // - // When the UTC offset is not a multiple of 15 minute intervals, assumes the - // provided date and time is in UTC. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:14:59))).unwrap(), - FileTime::new(126_828_123_000_000_000) - ); - // From `2002-11-26 19:25:00 -08:15` to `2002-11-27 03:40:00 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(-08:15))).unwrap(), - FileTime::new(126_828_420_000_000_000) - ); - // `2002-11-26 19:25:00 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(UtcOffset::UTC)).unwrap(), - FileTime::new(126_828_123_000_000_000) - ); - // `2002-11-26 19:25:00 UTC`. - assert_eq!( - FileTime::from_dos_date_time(0x2d7a, 0x9b20, None, Some(offset!(+00:00))).unwrap(), - FileTime::new(126_828_123_000_000_000) - ); - - // From `2107-12-31 23:59:58 +15:45` to `2107-12-31 08:14:58 UTC`. + // From `2018-11-17 10:38:30` to `2018-11-17 10:38:30 UTC`. assert_eq!( - FileTime::from_dos_date_time(0xff9f, 0xbf7d, None, Some(offset!(+15:45))).unwrap(), - FileTime::new(159_992_360_980_000_000) + FileTime::from_dos_date_time(0x4d71, 0x54cf).unwrap(), + FileTime::new(131_869_247_100_000_000) ); - // From `1980-01-01 00:00:00 -16:00` to `1980-01-01 16:00:00 UTC`. + // From `2107-12-31 23:59:58` to `2107-12-31 23:59:58 UTC`. assert_eq!( - FileTime::from_dos_date_time(0x0021, u16::MIN, None, Some(offset!(-16:00))).unwrap(), - FileTime::new(119_600_640_000_000_000) + FileTime::from_dos_date_time(0xff9f, 0xbf7d).unwrap(), + FileTime::new(159_992_927_980_000_000) ); } @@ -716,45 +326,25 @@ mod tests { let date = u16::from(day) + (u16::from(month) << 5) + ((year - 1980) << 9); let time = u16::from(second / 2) + (u16::from(minute) << 5) + (u16::from(hour) << 11); - prop_assert!(FileTime::from_dos_date_time(date, time, None, None).is_ok()); + prop_assert!(FileTime::from_dos_date_time(date, time).is_ok()); } #[test] fn from_dos_date_time_with_invalid_date_time() { // The Day field is 0. - assert!(FileTime::from_dos_date_time(0x0020, u16::MIN, None, None).is_err()); + assert!(FileTime::from_dos_date_time(0x0020, u16::MIN).is_err()); // The Day field is 30, which is after the last day of February. - assert!(FileTime::from_dos_date_time(0x005e, u16::MIN, None, None).is_err()); + assert!(FileTime::from_dos_date_time(0x005e, u16::MIN).is_err()); // The Month field is 0. - assert!(FileTime::from_dos_date_time(0x0001, u16::MIN, None, None).is_err()); + assert!(FileTime::from_dos_date_time(0x0001, u16::MIN).is_err()); // The Month field is 13. - assert!(FileTime::from_dos_date_time(0x01a1, u16::MIN, None, None).is_err()); + assert!(FileTime::from_dos_date_time(0x01a1, u16::MIN).is_err()); // The DoubleSeconds field is 30. - assert!(FileTime::from_dos_date_time(0x0021, 0x001e, None, None).is_err()); + assert!(FileTime::from_dos_date_time(0x0021, 0x001e).is_err()); // The Minute field is 60. - assert!(FileTime::from_dos_date_time(0x0021, 0x0780, None, None).is_err()); + assert!(FileTime::from_dos_date_time(0x0021, 0x0780).is_err()); // The Hour field is 24. - assert!(FileTime::from_dos_date_time(0x0021, 0xc000, None, None).is_err()); - } - - #[test] - #[should_panic] - fn from_dos_date_time_with_invalid_resolution() { - let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, Some(200), None); - } - - #[test] - #[should_panic] - fn from_dos_date_time_with_invalid_positive_offset() { - // From `2107-12-31 23:59:58 +16:00` to `2107-12-31 07:59:58 UTC`. - let _ = FileTime::from_dos_date_time(0xff9f, 0xbf7d, None, Some(offset!(+16:00))); - } - - #[test] - #[should_panic] - fn from_dos_date_time_with_invalid_negative_offset() { - // From `1980-01-01 00:00:00 -16:15` to `1980-01-01 16:15:00 UTC`. - let _ = FileTime::from_dos_date_time(0x0021, u16::MIN, None, Some(offset!(-16:15))); + assert!(FileTime::from_dos_date_time(0x0021, 0xc000).is_err()); } } diff --git a/src/lib.rs b/src/lib.rs index dd934fa..180ffa3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,10 +59,7 @@ //! ``` //! use core::time::Duration; //! -//! use nt_time::{ -//! FileTime, -//! time::{OffsetDateTime, UtcOffset}, -//! }; +//! use nt_time::{FileTime, time::OffsetDateTime}; //! //! // `1970-01-01 00:00:00 UTC`. //! let ut = i64::default(); @@ -74,13 +71,10 @@ //! let ft = FileTime::from_unix_time_secs(ut).unwrap(); //! assert_eq!(ft, FileTime::UNIX_EPOCH); //! -//! // `1980-01-01 00:00:00 UTC`. +//! // From `1980-01-01 00:00:00 UTC` to `1980-01-01 00:00:00`. //! let ft = ft + Duration::from_secs(315_532_800); -//! let dos_dt = ft.to_dos_date_time(Some(UtcOffset::UTC)); -//! assert_eq!( -//! dos_dt, -//! Ok((0x0021, u16::MIN, u8::MIN, Some(UtcOffset::UTC))) -//! ); +//! let dos_dt = ft.to_dos_date_time(); +//! assert_eq!(dos_dt, Ok((0x0021, u16::MIN))); //! ``` //! //! ## Formatting and printing the file time From 44baa2cf6fb4dedc70f84883dccb965754694eec Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 30 Jul 2025 00:23:32 +0900 Subject: [PATCH 65/69] chore(release): Update version to 0.12.0 --- .bumpversion.toml | 2 +- CHANGELOG.adoc | 2 +- Cargo.lock | 15 +++++++++++---- Cargo.toml | 2 +- src/lib.rs | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 9892523..9e930a0 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [tool.bumpversion] -current_version = "0.11.2" +current_version = "0.12.0" [[tool.bumpversion.files]] filename = "src/lib.rs" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index b9ab901..3c0fc02 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. -== {compare-url}/v0.11.2\...HEAD[Unreleased] +== {compare-url}/v0.11.2\...v0.12.0[0.12.0] - 2025-07-29 === Changed diff --git a/Cargo.lock b/Cargo.lock index 0551484..587fa2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,7 +276,7 @@ checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "nt-time" -version = "0.11.2" +version = "0.12.0" dependencies = [ "anyhow", "chrono", @@ -659,6 +659,12 @@ dependencies = [ "wit-bindgen-rt", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-sys" version = "0.59.0" @@ -674,7 +680,7 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.2", + "windows-targets 0.53.3", ] [[package]] @@ -695,10 +701,11 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.2" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ + "windows-link", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", diff --git a/Cargo.toml b/Cargo.toml index 88d29c8..06a4c62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "nt-time" -version = "0.11.2" +version = "0.12.0" authors = ["Shun Sakai "] edition = "2024" rust-version = "1.85.0" diff --git a/src/lib.rs b/src/lib.rs index 180ffa3..09f6e6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,7 +102,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -#![doc(html_root_url = "https://docs.rs/nt-time/0.11.2/")] +#![doc(html_root_url = "https://docs.rs/nt-time/0.12.0/")] #![no_std] #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))] // Lint levels of rustc. From 471484ef5f178c0002c75bd60ebcf2df49f1261a Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 3 Aug 2025 00:10:58 +0900 Subject: [PATCH 66/69] chore(deps): Remove `macros` feature from `time` --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06a4c62..38f4511 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ chrono = { version = "0.4.41", default-features = false, optional = true } jiff = { version = "0.2.15", default-features = false, optional = true } rand = { version = "0.9.2", default-features = false, optional = true } serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } -time = { version = "0.3.41", default-features = false, features = ["macros"] } +time = { version = "0.3.41", default-features = false } [dev-dependencies] anyhow = "1.0.98" @@ -65,7 +65,7 @@ proptest-derive = "0.6.0" serde_json = "1.0.141" serde_test = "1.0.177" test-strategy = "0.4.3" -time = { version = "0.3.41", features = ["parsing"] } +time = { version = "0.3.41", features = ["macros", "parsing"] } [features] default = ["std"] From 592f4cee2d8785ac2a714593e2729d49c3652f09 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 3 Aug 2025 01:21:34 +0900 Subject: [PATCH 67/69] chore(deps): Remove `derive` feature from `serde` --- Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 38f4511..5c03223 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ required-features = ["std"] chrono = { version = "0.4.41", default-features = false, optional = true } jiff = { version = "0.2.15", default-features = false, optional = true } rand = { version = "0.9.2", default-features = false, optional = true } -serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true } +serde = { version = "1.0.219", default-features = false, optional = true } time = { version = "0.3.41", default-features = false } [dev-dependencies] @@ -62,6 +62,7 @@ anyhow = "1.0.98" clap = { version = "4.5.41", features = ["derive"] } proptest = "1.7.0" proptest-derive = "0.6.0" +serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.141" serde_test = "1.0.177" test-strategy = "0.4.3" From caff0ee169211f270475b2456690f7e08bac1d51 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 3 Aug 2025 04:52:52 +0900 Subject: [PATCH 68/69] chore: Replace `StepRng` --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + benches/rand.rs | 8 +++----- src/file_time/rand.rs | 18 +++++++++++------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 587fa2f..282fa87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -285,6 +285,7 @@ dependencies = [ "proptest", "proptest-derive", "rand", + "rand_pcg", "serde", "serde_json", "serde_test", @@ -439,6 +440,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_pcg" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b48ac3f7ffaab7fac4d2376632268aa5f89abdb55f7ebf8f4d11fffccb2320f7" +dependencies = [ + "rand_core", +] + [[package]] name = "rand_xorshift" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 5c03223..368b1b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ anyhow = "1.0.98" clap = { version = "4.5.41", features = ["derive"] } proptest = "1.7.0" proptest-derive = "0.6.0" +rand_pcg = "0.9.0" serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.141" serde_test = "1.0.177" diff --git a/benches/rand.rs b/benches/rand.rs index f571904..c81193a 100644 --- a/benches/rand.rs +++ b/benches/rand.rs @@ -7,14 +7,12 @@ extern crate test; -use nt_time::{ - FileTime, - rand::{Rng, rngs::mock::StepRng}, -}; +use nt_time::{FileTime, rand::Rng}; +use rand_pcg::{Pcg64Mcg, rand_core::SeedableRng}; use test::Bencher; #[bench] fn sample(b: &mut Bencher) { - let mut rng = StepRng::new(0, 1); + let mut rng = Pcg64Mcg::from_seed(Default::default()); b.iter(|| rng.random::()); } diff --git a/src/file_time/rand.rs b/src/file_time/rand.rs index e2c56a5..4e5d150 100644 --- a/src/file_time/rand.rs +++ b/src/file_time/rand.rs @@ -20,21 +20,25 @@ impl Distribution for StandardUniform { #[cfg(test)] mod tests { - use rand::rngs::mock::StepRng; + use rand_pcg::{Pcg64Mcg, rand_core::SeedableRng}; use super::*; #[test] fn sample() { - let mut rng = StepRng::new(0, 1); - let buf: [FileTime; 4] = rng.random(); + let mut rng = Pcg64Mcg::from_seed(Default::default()); + let buf: [FileTime; 8] = rng.random(); assert_eq!( buf, [ - FileTime::new(0), - FileTime::new(1), - FileTime::new(2), - FileTime::new(3) + FileTime::new(0xe160_e532_6180_0aab), + FileTime::new(0x2a29_11d5_87fc_4ed5), + FileTime::new(0xdfe7_5554_bbd3_4d0d), + FileTime::new(0x2a4c_f66b_2879_6f51), + FileTime::new(0x500e_b6de_08bd_473b), + FileTime::new(0x8660_66c5_0dab_6374), + FileTime::new(0xe8e3_3086_f142_3eff), + FileTime::new(0x7d67_17b2_e579_844f) ] ); } From 111c98b8b20f1e1bb15ad3ff669aef4d5c147e59 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sun, 3 Aug 2025 05:48:11 +0900 Subject: [PATCH 69/69] chore(release): Update version to 0.12.1 --- .bumpversion.toml | 2 +- CHANGELOG.adoc | 7 +++++++ Cargo.lock | 14 +++++++------- Cargo.toml | 6 +++--- src/lib.rs | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 9e930a0..81bb1d9 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [tool.bumpversion] -current_version = "0.12.0" +current_version = "0.12.1" [[tool.bumpversion.files]] filename = "src/lib.rs" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 3c0fc02..cb5b8da 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,13 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. +== {compare-url}/v0.12.0\...v0.12.1[0.12.1] - 2025-08-02 + +=== Removed + +* Remove `macros` feature from `time` ({pull-request-url}/340[#340]) +* Remove `derive` feature from `serde` ({pull-request-url}/341[#341]) + == {compare-url}/v0.11.2\...v0.12.0[0.12.0] - 2025-07-29 === Changed diff --git a/Cargo.lock b/Cargo.lock index 282fa87..5fd3734 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.41" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" dependencies = [ "clap_builder", "clap_derive", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.41" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" dependencies = [ "anstream", "anstyle", @@ -276,7 +276,7 @@ checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "nt-time" -version = "0.12.0" +version = "0.12.1" dependencies = [ "anyhow", "chrono", @@ -517,9 +517,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.141" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 368b1b0..eb23c76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "nt-time" -version = "0.12.0" +version = "0.12.1" authors = ["Shun Sakai "] edition = "2024" rust-version = "1.85.0" @@ -59,12 +59,12 @@ time = { version = "0.3.41", default-features = false } [dev-dependencies] anyhow = "1.0.98" -clap = { version = "4.5.41", features = ["derive"] } +clap = { version = "4.5.42", features = ["derive"] } proptest = "1.7.0" proptest-derive = "0.6.0" rand_pcg = "0.9.0" serde = { version = "1.0.219", features = ["derive"] } -serde_json = "1.0.141" +serde_json = "1.0.142" serde_test = "1.0.177" test-strategy = "0.4.3" time = { version = "0.3.41", features = ["macros", "parsing"] } diff --git a/src/lib.rs b/src/lib.rs index 09f6e6a..9405809 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,7 +102,7 @@ //! [Unix time]: https://en.wikipedia.org/wiki/Unix_time //! [MS-DOS date and time]: https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time -#![doc(html_root_url = "https://docs.rs/nt-time/0.12.0/")] +#![doc(html_root_url = "https://docs.rs/nt-time/0.12.1/")] #![no_std] #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))] // Lint levels of rustc.