initial commit

This commit is contained in:
yggverse 2025-06-14 04:20:32 +03:00
parent fc4f0d6d1c
commit 0506b4dcb2
11 changed files with 455 additions and 1 deletions

29
src/time.rs Normal file
View file

@ -0,0 +1,29 @@
use chrono::{DateTime, Utc};
pub struct Time(String);
impl Time {
pub fn init(format: String) -> Self {
Self(format)
}
pub fn format(&self, value: Option<&str>) -> String {
match value {
Some(v) => chrono::DateTime::parse_from_rfc2822(v)
.unwrap()
.format(&self.0)
.to_string(),
None => todo!(),
}
}
pub fn now(&self) -> String {
utc().format(&self.0).to_string()
}
}
pub fn utc() -> DateTime<Utc> {
let s = std::time::SystemTime::now();
let c: chrono::DateTime<chrono::Utc> = s.into();
c
}