Skip to content

Commit

Permalink
🚧 temporarily allow deprecated duration
Browse files Browse the repository at this point in the history
will fix in next release

Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Mar 22, 2024
1 parent 7ad1be8 commit 4310bf8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/meta/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl From<&Metadata> for Date {
impl Date {
pub fn render(&self, colors: &Colors, flags: &Flags) -> ColoredString {
let now = Local::now();
#[allow(deprecated)]
let elem = match self {
&Date::Date(modified) if modified > now - Duration::hours(1) => Elem::HourOld,
&Date::Date(modified) if modified > now - Duration::days(1) => Elem::DayOld,
Expand All @@ -46,6 +47,7 @@ impl Date {
let locale = current_locale();

if let Date::Date(val) = self {
#[allow(deprecated)]
match &flags.date {
DateFlag::Date => val.format("%c").to_string(),
DateFlag::Locale => val.format_localized("%c", locale).to_string(),
Expand Down Expand Up @@ -119,6 +121,7 @@ mod test {
let mut file_path = env::temp_dir();
file_path.push("test_an_hour_old_file_color.tmp");

#[allow(deprecated)]
let creation_date = Local::now() - chrono::Duration::seconds(4);

let success = cross_platform_touch(&file_path, &creation_date)
Expand Down Expand Up @@ -146,6 +149,7 @@ mod test {
let mut file_path = env::temp_dir();
file_path.push("test_a_day_old_file_color.tmp");

#[allow(deprecated)]
let creation_date = Local::now() - chrono::Duration::hours(4);

let success = cross_platform_touch(&file_path, &creation_date)
Expand Down Expand Up @@ -173,6 +177,7 @@ mod test {
let mut file_path = env::temp_dir();
file_path.push("test_a_several_days_old_file_color.tmp");

#[allow(deprecated)]
let creation_date = Local::now() - chrono::Duration::days(2);

let success = cross_platform_touch(&file_path, &creation_date)
Expand Down Expand Up @@ -200,6 +205,7 @@ mod test {
let mut file_path = env::temp_dir();
file_path.push("test_with_relative_date.tmp");

#[allow(deprecated)]
let creation_date = Local::now() - chrono::Duration::days(2);

let success = cross_platform_touch(&file_path, &creation_date)
Expand Down Expand Up @@ -285,6 +291,7 @@ mod test {
let mut file_path = env::temp_dir();
file_path.push("test_iso_format_year_old.tmp");

#[allow(deprecated)]
let creation_date = Local::now() - Duration::days(400);
let success = cross_platform_touch(&file_path, &creation_date)
.unwrap()
Expand Down

0 comments on commit 4310bf8

Please sign in to comment.