mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-12 08:00:07 +01:00
Add support for time crate.
This commit is contained in:
parent
7f9ad54694
commit
70d1ac3786
3 changed files with 24 additions and 7 deletions
|
|
@ -1,4 +1,3 @@
|
|||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use std::fmt;
|
||||
|
||||
use serde::{de, Deserialize, Deserializer};
|
||||
|
|
@ -7,12 +6,26 @@ use serde::{de, Deserialize, Deserializer};
|
|||
#[derive(Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct NumericDate(i64);
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
impl From<NumericDate> for DateTime<Utc> {
|
||||
fn from(t: NumericDate) -> Self {
|
||||
Utc.timestamp_opt(t.0, 0).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
use time::OffsetDateTime;
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
impl From<NumericDate> for OffsetDateTime {
|
||||
fn from(t: NumericDate) -> Self {
|
||||
OffsetDateTime::from_unix_timestamp(t.0).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct StringList(Vec<String>);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue