fix: remove split seconds

This commit is contained in:
ThetaDev 2022-10-18 23:06:19 +02:00
parent 3c1cc92461
commit 9f7f337efd
5 changed files with 17 additions and 6 deletions

View file

@ -1,4 +1,4 @@
use time::{Date, Month};
use time::{Date, Month, OffsetDateTime};
pub const fn month_from_n(n: u8) -> Option<Month> {
match n {
@ -42,3 +42,14 @@ pub fn shift_months(date: Date, months: i32) -> Date {
pub fn shift_years(date: Date, years: i32) -> Date {
shift_months(date, years * 12)
}
/// Get the current datetime without milli/micro/nanoseconds
pub fn now_sec() -> OffsetDateTime {
OffsetDateTime::now_utc()
.replace_millisecond(0)
.unwrap()
.replace_microsecond(0)
.unwrap()
.replace_nanosecond(0)
.unwrap()
}

View file

@ -3,7 +3,7 @@ mod protobuf;
pub mod dictionary;
pub use date::{month_from_n, shift_months, shift_years};
pub use date::{month_from_n, now_sec, shift_months, shift_years};
pub use protobuf::ProtoBuilder;
use std::{