Can export data to FinancesManager
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
//! # Time utilities
|
||||
|
||||
use chrono::Datelike;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
/// Get the current time since epoch
|
||||
@ -19,3 +20,15 @@ pub fn unix_to_system_time(time: u64) -> SystemTime {
|
||||
pub fn unix_to_http_date(time: u64) -> String {
|
||||
httpdate::fmt_http_date(unix_to_system_time(time))
|
||||
}
|
||||
|
||||
/// Format given UNIX time in a simple format
|
||||
pub fn format_date(time: i64) -> anyhow::Result<String> {
|
||||
let date = chrono::DateTime::from_timestamp(time, 0).ok_or(anyhow::anyhow!("invalid date"))?;
|
||||
|
||||
Ok(format!(
|
||||
"{:0>2}/{:0>2}/{}",
|
||||
date.day(),
|
||||
date.month(),
|
||||
date.year()
|
||||
))
|
||||
}
|
||||
|
Reference in New Issue
Block a user