feat: moved the timestamp function to lib
This commit is contained in:
parent
4ce3e94c36
commit
72776a967a
4 changed files with 17 additions and 13 deletions
10
src/lib.rs
10
src/lib.rs
|
@ -6,6 +6,7 @@ use sqlx::{Error, Pool, Sqlite};
|
|||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use chrono::{Datelike, SecondsFormat, Utc};
|
||||
use tide::prelude::*;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
|
||||
|
@ -111,6 +112,15 @@ pub fn get_now() -> i64 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_now_iso(short: bool) -> String {
|
||||
let now = Utc::now();
|
||||
if short {
|
||||
format!("{}-{:02}-{:02}", now.year(), now.month(), now.day())
|
||||
} else {
|
||||
now.to_rfc3339_opts(SecondsFormat::Millis, true)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct State {
|
||||
pub db: Pool<Sqlite>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue