multidb
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use argon2::{
|
||||
password_hash::SaltString, Argon2, PasswordHash, PasswordHasher, PasswordVerifier,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use rand_core::{OsRng, RngCore};
|
||||
use serde::Serialize;
|
||||
use sqlx::FromRow;
|
||||
@@ -198,9 +198,25 @@ fn hash_password(password: &str) -> String {
|
||||
}
|
||||
|
||||
pub fn normalize_timestamp(value: &str) -> String {
|
||||
DateTime::parse_from_rfc3339(value)
|
||||
.map(|dt| dt.with_timezone(&Utc).to_rfc3339())
|
||||
.unwrap_or_else(|_| value.replace(' ', "T") + "Z")
|
||||
let value = value.trim();
|
||||
|
||||
if let Ok(timestamp) = DateTime::parse_from_rfc3339(value) {
|
||||
return timestamp.with_timezone(&Utc).to_rfc3339();
|
||||
}
|
||||
|
||||
for format in ["%Y-%m-%d %H:%M:%S%.f%:z", "%Y-%m-%d %H:%M:%S%.f%#z"] {
|
||||
if let Ok(timestamp) = DateTime::parse_from_str(value, format) {
|
||||
return timestamp.with_timezone(&Utc).to_rfc3339();
|
||||
}
|
||||
}
|
||||
|
||||
for format in ["%Y-%m-%d %H:%M:%S%.f", "%Y-%m-%dT%H:%M:%S%.f"] {
|
||||
if let Ok(timestamp) = NaiveDateTime::parse_from_str(value, format) {
|
||||
return timestamp.and_utc().to_rfc3339();
|
||||
}
|
||||
}
|
||||
|
||||
value.to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, FromRow)]
|
||||
|
||||
Reference in New Issue
Block a user