mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
chore(deps): update time crate to 0.3.35 (#4338)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -265,3 +265,22 @@ pub mod iso8601custom {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn test_leap_second_parse() {
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Try {
|
||||
#[serde(with = "crate::custom_serde::iso8601")]
|
||||
f: time::PrimitiveDateTime,
|
||||
}
|
||||
let leap_second_date_time = json!({"f": "2023-12-31T23:59:60.000Z"});
|
||||
let deser = serde_json::from_value::<Try>(leap_second_date_time);
|
||||
|
||||
assert!(deser.is_ok())
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,15 +23,15 @@ pub mod validation;
|
||||
|
||||
/// Date-time utilities.
|
||||
pub mod date_time {
|
||||
#[cfg(feature = "async_ext")]
|
||||
use std::time::Instant;
|
||||
use std::{marker::PhantomData, num::NonZeroU8};
|
||||
|
||||
use masking::{Deserialize, Serialize};
|
||||
#[cfg(feature = "async_ext")]
|
||||
use time::Instant;
|
||||
use time::{
|
||||
format_description::{
|
||||
well_known::iso8601::{Config, EncodedConfig, Iso8601, TimePrecision},
|
||||
FormatItem,
|
||||
BorrowedFormatItem,
|
||||
},
|
||||
OffsetDateTime, PrimitiveDateTime,
|
||||
};
|
||||
@ -68,7 +68,7 @@ pub mod date_time {
|
||||
) -> (T, f64) {
|
||||
let start = Instant::now();
|
||||
let result = block().await;
|
||||
(result, start.elapsed().as_seconds_f64() * 1000f64)
|
||||
(result, start.elapsed().as_secs_f64() * 1000f64)
|
||||
}
|
||||
|
||||
/// Return the given date and time in UTC with the given format Eg: format: YYYYMMDDHHmmss Eg: 20191105081132
|
||||
@ -76,7 +76,7 @@ pub mod date_time {
|
||||
date: PrimitiveDateTime,
|
||||
format: DateFormat,
|
||||
) -> Result<String, time::error::Format> {
|
||||
let format = <&[FormatItem<'_>]>::from(format);
|
||||
let format = <&[BorrowedFormatItem<'_>]>::from(format);
|
||||
date.format(&format)
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ pub mod date_time {
|
||||
now().assume_utc().format(&Iso8601::<ISO_CONFIG>)
|
||||
}
|
||||
|
||||
impl From<DateFormat> for &[FormatItem<'_>] {
|
||||
impl From<DateFormat> for &[BorrowedFormatItem<'_>] {
|
||||
fn from(format: DateFormat) -> Self {
|
||||
match format {
|
||||
DateFormat::YYYYMMDDHHmmss => time::macros::format_description!("[year repr:full][month padding:zero repr:numerical][day padding:zero][hour padding:zero repr:24][minute padding:zero][second padding:zero]"),
|
||||
|
||||
Reference in New Issue
Block a user