Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
mod locale;

use clap::{Arg, ArgAction, Command};
use jiff::ToSpan;
use jiff::fmt::strtime;
use jiff::tz::{TimeZone, TimeZoneDatabase};
use jiff::{Timestamp, Zoned};
Expand Down Expand Up @@ -297,8 +298,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} else if let Some(total_hours) = military_tz_with_offset {
// Military timezone with optional hour offset
// Convert to UTC time: midnight + military_tz_offset + additional_hours
let date_part =
strtime::format("%F", &now).unwrap_or_else(|_| String::from("1970-01-01"));
let yesterday = now.checked_sub(1.day());
let date_part = match yesterday {
Ok(yesterday) => strtime::format("%F", &yesterday)
.unwrap_or_else(|_| String::from("1970-01-01")),
Err(_) => String::from("1970-01-01"),
};
let composed = format!("{date_part} {total_hours:02}:00:00 +00:00");
parse_date(composed)
} else if is_pure_digits {
Expand Down
Loading