Use ellipsizing and replace chrono with jiff (#1323)
* refactor(time): use `jiff` instead of `chrono` * improv: use text ellipsizing
This commit is contained in:
parent
02b035ce93
commit
7029fcccf6
10 changed files with 708 additions and 530 deletions
|
|
@ -1,11 +1,14 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use chrono::{Datelike, Days, NaiveDate, Weekday};
|
||||
use jiff::{
|
||||
ToSpan,
|
||||
civil::{Date, Weekday},
|
||||
};
|
||||
|
||||
/// Gets the first date that will be visible on the calendar
|
||||
pub fn get_calendar_first(year: i32, month: u32, from_weekday: Weekday) -> NaiveDate {
|
||||
let date = NaiveDate::from_ymd_opt(year, month, 1).unwrap();
|
||||
let num_days = (date.weekday() as u32 + 7 - from_weekday as u32) % 7; // chrono::Weekday.num_days_from
|
||||
date.checked_sub_days(Days::new(num_days as u64)).unwrap()
|
||||
pub fn get_calendar_first(year: i16, month: i8, from_weekday: Weekday) -> Date {
|
||||
let date = Date::new(year, month, 1).expect("valid date");
|
||||
let num_days = date.weekday().since(from_weekday);
|
||||
date.checked_sub(num_days.days()).expect("valid date")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue