fix: resolve TODO comments in storage models crate (#151)

This commit is contained in:
Nishant Joshi
2022-12-15 19:10:02 +05:30
committed by GitHub
parent d36ae26460
commit bc2f13ab07
13 changed files with 78 additions and 102 deletions

View File

@ -24,12 +24,20 @@ pub mod validation;
/// Date-time utilities.
pub mod date_time {
use time::{OffsetDateTime, PrimitiveDateTime};
/// Struct to represent milliseconds in time sensitive data fields
#[derive(Debug)]
pub struct Milliseconds(i32);
/// Create a new [`PrimitiveDateTime`] with the current date and time in UTC.
pub fn now() -> PrimitiveDateTime {
let utc_date_time = OffsetDateTime::now_utc();
PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time())
}
/// Convert from OffsetDateTime to PrimitiveDateTime
pub fn convert_to_pdt(offset_time: OffsetDateTime) -> PrimitiveDateTime {
PrimitiveDateTime::new(offset_time.date(), offset_time.time())
}
}
/// Generate a nanoid with the given prefix and length