Skip to content

Commit

Permalink
Update time to 0.3.36 (#3190)
Browse files Browse the repository at this point in the history
* update time to 0.3.35

* fmt fix

* update version to 0.3.36
  • Loading branch information
BlackSoulHub authored Apr 12, 2024
1 parent 03926de commit 6a4f61e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
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

0 comments on commit 6a4f61e

Please sign in to comment.