Use ellipsizing and replace chrono with jiff (#1323)

* refactor(time): use `jiff` instead of `chrono`

* improv: use text ellipsizing
This commit is contained in:
Vukašin Vojinović 2026-03-03 23:57:49 +01:00 • committed by GitHub
parent 02b035ce93
commit 7029fcccf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 708 additions and 530 deletions

View file

@ -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")
}