Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update time to 0.3.36 #3190

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ chrono = { version = "0.4.22", default-features = false }
ipnetwork = "0.20.0"
mac_address = "1.1.5"
rust_decimal = "1.26.1"
time = { version = "0.3.14", features = ["formatting", "parsing", "macros"] }
time = { version = "0.3.36", features = ["formatting", "parsing", "macros"] }
uuid = "1.1.2"

# Common utility crates
Expand Down
35 changes: 18 additions & 17 deletions sqlx-sqlite/src/types/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
types::Type,
Sqlite, SqliteArgumentValue, SqliteTypeInfo, SqliteValueRef,
};
use time::format_description::{well_known::Rfc3339, FormatItem};
use time::format_description::{well_known::Rfc3339, BorrowedFormatItem};
use time::macros::format_description as fd;
use time::{Date, OffsetDateTime, PrimitiveDateTime, Time};

Expand Down Expand Up @@ -177,21 +177,22 @@ fn decode_datetime_from_text(value: &str) -> Option<PrimitiveDateTime> {
}

let formats = [
FormatItem::Compound(formats::PRIMITIVE_DATE_TIME_SPACE_SEPARATED),
FormatItem::Compound(formats::PRIMITIVE_DATE_TIME_T_SEPARATED),
BorrowedFormatItem::Compound(formats::PRIMITIVE_DATE_TIME_SPACE_SEPARATED),
BorrowedFormatItem::Compound(formats::PRIMITIVE_DATE_TIME_T_SEPARATED),
];

if let Ok(dt) = PrimitiveDateTime::parse(value, &FormatItem::First(&formats)) {
if let Ok(dt) = PrimitiveDateTime::parse(value, &BorrowedFormatItem::First(&formats)) {
return Some(dt);
}

None
}

mod formats {
use time::format_description::{modifier, Component::*, FormatItem, FormatItem::*};
use time::format_description::BorrowedFormatItem::{Component, Literal, Optional};
use time::format_description::{modifier, BorrowedFormatItem, Component::*};

const YEAR: FormatItem<'_> = Component(Year({
const YEAR: BorrowedFormatItem<'_> = Component(Year({
let mut value = modifier::Year::default();
value.padding = modifier::Padding::Zero;
value.repr = modifier::YearRepr::Full;
Expand All @@ -200,59 +201,59 @@ mod formats {
value
}));

const MONTH: FormatItem<'_> = Component(Month({
const MONTH: BorrowedFormatItem<'_> = Component(Month({
let mut value = modifier::Month::default();
value.padding = modifier::Padding::Zero;
value.repr = modifier::MonthRepr::Numerical;
value.case_sensitive = true;
value
}));

const DAY: FormatItem<'_> = Component(Day({
const DAY: BorrowedFormatItem<'_> = Component(Day({
let mut value = modifier::Day::default();
value.padding = modifier::Padding::Zero;
value
}));

const HOUR: FormatItem<'_> = Component(Hour({
const HOUR: BorrowedFormatItem<'_> = Component(Hour({
let mut value = modifier::Hour::default();
value.padding = modifier::Padding::Zero;
value.is_12_hour_clock = false;
value
}));

const MINUTE: FormatItem<'_> = Component(Minute({
const MINUTE: BorrowedFormatItem<'_> = Component(Minute({
let mut value = modifier::Minute::default();
value.padding = modifier::Padding::Zero;
value
}));

const SECOND: FormatItem<'_> = Component(Second({
const SECOND: BorrowedFormatItem<'_> = Component(Second({
let mut value = modifier::Second::default();
value.padding = modifier::Padding::Zero;
value
}));

const SUBSECOND: FormatItem<'_> = Component(Subsecond({
const SUBSECOND: BorrowedFormatItem<'_> = Component(Subsecond({
let mut value = modifier::Subsecond::default();
value.digits = modifier::SubsecondDigits::OneOrMore;
value
}));

const OFFSET_HOUR: FormatItem<'_> = Component(OffsetHour({
const OFFSET_HOUR: BorrowedFormatItem<'_> = Component(OffsetHour({
let mut value = modifier::OffsetHour::default();
value.sign_is_mandatory = true;
value.padding = modifier::Padding::Zero;
value
}));

const OFFSET_MINUTE: FormatItem<'_> = Component(OffsetMinute({
const OFFSET_MINUTE: BorrowedFormatItem<'_> = Component(OffsetMinute({
let mut value = modifier::OffsetMinute::default();
value.padding = modifier::Padding::Zero;
value
}));

pub(super) const OFFSET_DATE_TIME: &[FormatItem<'_>] = {
pub(super) const OFFSET_DATE_TIME: &[BorrowedFormatItem<'_>] = {
&[
YEAR,
Literal(b"-"),
Expand All @@ -274,7 +275,7 @@ mod formats {
]
};

pub(super) const PRIMITIVE_DATE_TIME_SPACE_SEPARATED: &[FormatItem<'_>] = {
pub(super) const PRIMITIVE_DATE_TIME_SPACE_SEPARATED: &[BorrowedFormatItem<'_>] = {
&[
YEAR,
Literal(b"-"),
Expand All @@ -293,7 +294,7 @@ mod formats {
]
};

pub(super) const PRIMITIVE_DATE_TIME_T_SEPARATED: &[FormatItem<'_>] = {
pub(super) const PRIMITIVE_DATE_TIME_T_SEPARATED: &[BorrowedFormatItem<'_>] = {
&[
YEAR,
Literal(b"-"),
Expand Down
Loading