mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-26 13:31:02 +00:00
Make format_datetime() crate public
This commit is contained in:
parent
9c177f6286
commit
1770336c11
2 changed files with 29 additions and 29 deletions
|
@ -334,6 +334,7 @@ impl SmtpNewWithAddr for smtp::SmtpClient {
|
|||
#[macro_use]
|
||||
mod tests {
|
||||
use crate::{db_conn, migrations::IMPORTED_MIGRATIONS, Connection as Conn, CONFIG};
|
||||
use chrono::{naive::NaiveDateTime, Datelike, Timelike};
|
||||
use diesel::r2d2::ConnectionManager;
|
||||
use plume_common::utils::random_hex;
|
||||
use std::env::temp_dir;
|
||||
|
@ -366,6 +367,33 @@ mod tests {
|
|||
pool
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
pub(crate) fn format_datetime(dt: &NaiveDateTime) -> String {
|
||||
format!(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}.{:06}Z",
|
||||
dt.year(),
|
||||
dt.month(),
|
||||
dt.day(),
|
||||
dt.hour(),
|
||||
dt.minute(),
|
||||
dt.second(),
|
||||
dt.timestamp_subsec_micros()
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
pub(crate) fn format_datetime(dt: &NaiveDateTime) -> String {
|
||||
format!(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}Z",
|
||||
dt.year(),
|
||||
dt.month(),
|
||||
dt.day(),
|
||||
dt.hour(),
|
||||
dt.minute(),
|
||||
dt.second()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod admin;
|
||||
|
|
|
@ -944,39 +944,11 @@ mod tests {
|
|||
use crate::inbox::{inbox, tests::fill_database, InboxResult};
|
||||
use crate::mentions::{Mention, NewMention};
|
||||
use crate::safe_string::SafeString;
|
||||
use crate::tests::db;
|
||||
use crate::tests::{db, format_datetime};
|
||||
use assert_json_diff::assert_json_eq;
|
||||
use chrono::{naive::NaiveDateTime, Datelike, Timelike};
|
||||
use diesel::Connection;
|
||||
use serde_json::{json, to_value};
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
fn format_datetime(dt: &NaiveDateTime) -> String {
|
||||
format!(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}.{:06}Z",
|
||||
dt.year(),
|
||||
dt.month(),
|
||||
dt.day(),
|
||||
dt.hour(),
|
||||
dt.minute(),
|
||||
dt.second(),
|
||||
dt.timestamp_subsec_micros()
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
fn format_datetime(dt: &NaiveDateTime) -> String {
|
||||
format!(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}Z",
|
||||
dt.year(),
|
||||
dt.month(),
|
||||
dt.day(),
|
||||
dt.hour(),
|
||||
dt.minute(),
|
||||
dt.second()
|
||||
)
|
||||
}
|
||||
|
||||
fn prepare_activity(conn: &DbConn) -> (Post, Mention, Vec<Post>, Vec<User>, Vec<Blog>) {
|
||||
let (posts, users, blogs) = fill_database(conn);
|
||||
let post = &posts[0];
|
||||
|
|
Loading…
Reference in a new issue