Skip to content

Commit

Permalink
Update time crate to 0.3.35 version
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Apr 10, 2024
1 parent 6f9c5b1 commit 6ffbb66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion juniper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ serde = { version = "1.0.122", features = ["derive"] }
serde_json = { version = "1.0.18", features = ["std"], default-features = false, optional = true }
smartstring = "1.0"
static_assertions = "1.1"
time = { version = "0.3", features = ["formatting", "macros", "parsing"], optional = true }
time = { version = "0.3.35", features = ["formatting", "macros", "parsing"], optional = true }
url = { version = "2.0", optional = true }
uuid = { version = "1.3", default-features = false, optional = true }

Expand Down
25 changes: 13 additions & 12 deletions juniper/src/integrations/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! [s5]: https://graphql-scalars.dev/docs/scalars/utc-offset

use time::{
format_description::{well_known::Rfc3339, FormatItem},
format_description::{well_known::Rfc3339, BorrowedFormatItem},
macros::format_description,
};

Expand Down Expand Up @@ -52,12 +52,12 @@ mod date {
/// Format of a [`Date` scalar][1].
///
/// [1]: https://graphql-scalars.dev/docs/scalars/date
const FORMAT: &[FormatItem<'_>] = format_description!("[year]-[month]-[day]");
const FORMAT: &[BorrowedFormatItem<'_>] = format_description!("[year]-[month]-[day]");

pub(super) fn to_output<S: ScalarValue>(v: &Date) -> Value<S> {
Value::scalar(
v.format(FORMAT)
.unwrap_or_else(|e| panic!("Failed to format `Date`: {e}")),
.unwrap_or_else(|e| panic!("failed to format `Date`: {e}")),
)
}

Expand Down Expand Up @@ -89,18 +89,19 @@ mod local_time {
/// Full format of a [`LocalTime` scalar][1].
///
/// [1]: https://graphql-scalars.dev/docs/scalars/local-time
const FORMAT: &[FormatItem<'_>] =
const FORMAT: &[BorrowedFormatItem<'_>] =
format_description!("[hour]:[minute]:[second].[subsecond digits:3]");

/// Format of a [`LocalTime` scalar][1] without milliseconds.
///
/// [1]: https://graphql-scalars.dev/docs/scalars/local-time
const FORMAT_NO_MILLIS: &[FormatItem<'_>] = format_description!("[hour]:[minute]:[second]");
const FORMAT_NO_MILLIS: &[BorrowedFormatItem<'_>] =
format_description!("[hour]:[minute]:[second]");

/// Format of a [`LocalTime` scalar][1] without seconds.
///
/// [1]: https://graphql-scalars.dev/docs/scalars/local-time
const FORMAT_NO_SECS: &[FormatItem<'_>] = format_description!("[hour]:[minute]");
const FORMAT_NO_SECS: &[BorrowedFormatItem<'_>] = format_description!("[hour]:[minute]");

pub(super) fn to_output<S: ScalarValue>(v: &LocalTime) -> Value<S> {
Value::scalar(
Expand All @@ -109,7 +110,7 @@ mod local_time {
} else {
v.format(FORMAT)
}
.unwrap_or_else(|e| panic!("Failed to format `LocalTime`: {e}")),
.unwrap_or_else(|e| panic!("failed to format `LocalTime`: {e}")),
)
}

Expand Down Expand Up @@ -140,13 +141,13 @@ mod local_date_time {
use super::*;

/// Format of a [`LocalDateTime`] scalar.
const FORMAT: &[FormatItem<'_>] =
const FORMAT: &[BorrowedFormatItem<'_>] =
format_description!("[year]-[month]-[day] [hour]:[minute]:[second]");

pub(super) fn to_output<S: ScalarValue>(v: &LocalDateTime) -> Value<S> {
Value::scalar(
v.format(FORMAT)
.unwrap_or_else(|e| panic!("Failed to format `LocalDateTime`: {e}")),
.unwrap_or_else(|e| panic!("failed to format `LocalDateTime`: {e}")),
)
}

Expand Down Expand Up @@ -185,7 +186,7 @@ mod date_time {
Value::scalar(
v.to_offset(UtcOffset::UTC)
.format(&Rfc3339)
.unwrap_or_else(|e| panic!("Failed to format `DateTime`: {e}")),
.unwrap_or_else(|e| panic!("failed to format `DateTime`: {e}")),
)
}

Expand All @@ -202,7 +203,7 @@ mod date_time {
/// Format of a [`UtcOffset` scalar][1].
///
/// [1]: https://graphql-scalars.dev/docs/scalars/utc-offset
const UTC_OFFSET_FORMAT: &[FormatItem<'_>] =
const UTC_OFFSET_FORMAT: &[BorrowedFormatItem<'_>] =
format_description!("[offset_hour sign:mandatory]:[offset_minute]");

/// Offset from UTC in `±hh:mm` format. See [list of database time zones][0].
Expand All @@ -227,7 +228,7 @@ mod utc_offset {
pub(super) fn to_output<S: ScalarValue>(v: &UtcOffset) -> Value<S> {
Value::scalar(
v.format(UTC_OFFSET_FORMAT)
.unwrap_or_else(|e| panic!("Failed to format `UtcOffset`: {e}")),
.unwrap_or_else(|e| panic!("failed to format `UtcOffset`: {e}")),
)
}

Expand Down

0 comments on commit 6ffbb66

Please sign in to comment.