add: icon resolver
add: config "no_track" file list option add: rainbeam-shared -> tetratto-shared add: l10n
This commit is contained in:
parent
b6fe2fba37
commit
d2ca9e23d3
40 changed files with 1107 additions and 583 deletions
23
crates/shared/src/time.rs
Normal file
23
crates/shared/src/time.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use chrono::{TimeZone, Utc};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
/// Get a [`u128`] timestamp
|
||||
pub fn unix_epoch_timestamp() -> u128 {
|
||||
let right_now = SystemTime::now();
|
||||
let time_since = right_now
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("Time travel is not allowed");
|
||||
|
||||
time_since.as_millis()
|
||||
}
|
||||
|
||||
/// Get a [`i64`] timestamp from the given `year` epoch
|
||||
pub fn epoch_timestamp(year: i32) -> i64 {
|
||||
let now = Utc::now().timestamp_millis();
|
||||
let then = Utc
|
||||
.with_ymd_and_hms(year, 1, 1, 0, 0, 0)
|
||||
.unwrap()
|
||||
.timestamp_millis();
|
||||
|
||||
now - then
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue