Skip to content

Commit

Permalink
release: 0.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Nov 28, 2024
2 parents 626b364 + e98ab2c commit 8d483ad
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 46 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@



## [0.11.1](https://github.com/Blobfolio/utc2k/releases/tag/v0.11.1) - 2024-11-28

### Changed

* Bump `brunch` to `0.7` (dev)
* `FmtUtf2k::date` is now const
* `FmtUtf2k::time` is now const
* `FmtUtf2k::year` is now const
* Miscellaneous code changes and lints



## [0.11.0](https://github.com/Blobfolio/utc2k/releases/tag/v0.11.0) - 2024-10-25

### New
Expand Down
21 changes: 18 additions & 3 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Project Dependencies
Package: utc2k
Version: 0.11.0
Generated: 2024-10-25 18:12:03 UTC
Version: 0.11.1
Generated: 2024-11-28 19:08:01 UTC

This package has no dependencies.
| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [_proc-macro2_](https://github.com/dtolnay/proc-macro2) ⚒️ | 1.0.92 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_quote_](https://github.com/dtolnay/quote) ⚒️ | 1.0.37 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [**_serde_**](https://github.com/serde-rs/serde) | 1.0.215 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_serde_derive_](https://github.com/serde-rs/serde) | 1.0.215 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_syn_](https://github.com/dtolnay/syn) ⚒️ | 2.0.89 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [**_tz-rs_**](https://github.com/x-hgg-x/tz-rs) | 0.7.0 | x-hgg-x | MIT OR Apache-2.0 |
| [_unicode-ident_](https://github.com/dtolnay/unicode-ident) ⚒️ | 1.0.14 | [David Tolnay](mailto:[email protected]) | (MIT OR Apache-2.0) AND Unicode-3.0 |

### Legend

* **Direct Dependency**
* Child Dependency
* _Optional Dependency_
* ⚒️ Build-Only
9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "utc2k"
version = "0.11.0"
authors = ["Blobfolio, LLC. <hello@blobfolio.com>"]
version = "0.11.1"
authors = ["Josh Stoik <josh@blobfolio.com>"]
edition = "2021"
rust-version = "1.81"
description = "A fast and lean UTC date/time library concerned only with happenings in this century (2000-2099)."
Expand All @@ -26,12 +26,9 @@ default-target = "x86_64-unknown-linux-gnu"

[package.metadata.bashman]
name = "UTC2K"
bash-dir = "./"
man-dir = "./"
credits-dir = "./"

[dev-dependencies]
brunch = "0.6.*"
brunch = "0.7.*"
fastrand = "2"
serde = "1.0.*"
serde_json = "1.0.*"
Expand Down
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,3 @@ Add `utc2k` to your `dependencies` in `Cargo.toml`, like:
[dependencies]
utc2k = "0.11.*"
```



## License

Copyright © 2024 [Blobfolio, LLC](https://blobfolio.com) &lt;[email protected]&gt;

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
67 changes: 55 additions & 12 deletions src/date/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,27 @@ impl FmtUtc2k {
/// assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
/// assert_eq!(fmt.date(), "2099-12-31");
/// ```
pub fn date(&self) -> &str {
debug_assert!(self.0[..10].is_ascii(), "Bug: Date is not ASCII.");
// Safety: datetimes are valid ASCII.
unsafe { std::str::from_utf8_unchecked(&self.0[..10]) }
pub const fn date(&self) -> &str {
if let Some(v) = self.0.first_chunk::<10>() {
debug_assert!(
v[0].is_ascii_digit() &&
v[1].is_ascii_digit() &&
v[2].is_ascii_digit() &&
v[3].is_ascii_digit() &&
v[4] == b'-' &&
v[5].is_ascii_digit() &&
v[6].is_ascii_digit() &&
v[7] == b'-' &&
v[8].is_ascii_digit() &&
v[9].is_ascii_digit(),
"Bug: Date is not ASCII.",
);

// Safety: datetimes are valid ASCII.
unsafe { std::str::from_utf8_unchecked(v.as_slice()) }
}
// Unreachable.
else { "2000-01-01" }
}

#[expect(unsafe_code, reason = "Content is ASCII.")]
Expand All @@ -428,10 +445,21 @@ impl FmtUtc2k {
/// assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
/// assert_eq!(fmt.year(), "2099");
/// ```
pub fn year(&self) -> &str {
debug_assert!(self.0.iter().take(4).all(u8::is_ascii_digit), "Bug: Year is not numeric.");
// Safety: datetimes are valid ASCII.
unsafe { std::str::from_utf8_unchecked(&self.0[..4]) }
pub const fn year(&self) -> &str {
if let Some(v) = self.0.first_chunk::<4>() {
debug_assert!(
v[0].is_ascii_digit() &&
v[1].is_ascii_digit() &&
v[2].is_ascii_digit() &&
v[3].is_ascii_digit(),
"Bug: Year is not ASCII.",
);

// Safety: datetimes are valid ASCII.
unsafe { std::str::from_utf8_unchecked(v.as_slice()) }
}
// Unreachable.
else { "2000" }
}

#[expect(unsafe_code, reason = "Content is ASCII.")]
Expand All @@ -450,10 +478,25 @@ impl FmtUtc2k {
/// assert_eq!(fmt.as_str(), "2099-12-31 23:59:59");
/// assert_eq!(fmt.time(), "23:59:59");
/// ```
pub fn time(&self) -> &str {
debug_assert!(self.0[11..].is_ascii(), "Bug: Time is not ASCII.");
// Safety: datetimes are valid ASCII.
unsafe { std::str::from_utf8_unchecked(&self.0[11..]) }
pub const fn time(&self) -> &str {
if let Some(v) = self.0.last_chunk::<8>() {
debug_assert!(
v[0].is_ascii_digit() &&
v[1].is_ascii_digit() &&
v[2] == b':' &&
v[3].is_ascii_digit() &&
v[4].is_ascii_digit() &&
v[5] == b':' &&
v[6].is_ascii_digit() &&
v[7].is_ascii_digit(),
"Bug: Time is not ASCII.",
);

// Safety: datetimes are valid ASCII.
unsafe { std::str::from_utf8_unchecked(v.as_slice()) }
}
// Unreachable.
else { "00:00:00" }
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'de> Deserialize<'de> for Utc2k {
);
}

impl<'de> de::Visitor<'de> for Visitor {
impl de::Visitor<'_> for Visitor {
type Value = Utc2k;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'de> Deserialize<'de> for Month {
/// # Visitor Instance.
struct Visitor;

impl<'de> de::Visitor<'de> for Visitor {
impl de::Visitor<'_> for Visitor {
type Value = Month;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'de> Deserialize<'de> for Weekday {
/// # Visitor Instance.
struct Visitor;

impl<'de> de::Visitor<'de> for Visitor {
impl de::Visitor<'_> for Visitor {
type Value = Weekday;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down

0 comments on commit 8d483ad

Please sign in to comment.