Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ binary-heap-plus = "0.5.0"
bstr = "1.9"
bytecount = "0.6.7"
byteorder = "1.5.0"
chrono = { version = "^0.4.34", default-features = false, features = [
chrono = { version = "^0.4.35", default-features = false, features = [
"std",
"alloc",
"clock",
Expand Down
3 changes: 2 additions & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,8 @@ fn display_date(metadata: &Metadata, config: &Config) -> String {
Some(time) => {
//Date is recent if from past 6 months
//According to GNU a Gregorian year has 365.2425 * 24 * 60 * 60 == 31556952 seconds on the average.
let recent = time + chrono::TimeDelta::seconds(31_556_952 / 2) > chrono::Local::now();
let recent = time + chrono::TimeDelta::try_seconds(31_556_952 / 2).unwrap()
> chrono::Local::now();

match &config.time_style {
TimeStyle::FullIso => time.format("%Y-%m-%d %H:%M:%S.%f %z"),
Expand Down
4 changes: 2 additions & 2 deletions src/uu/touch/src/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ fn parse_timestamp(s: &str) -> UResult<FileTime> {
// only care about the timestamp anyway.
// Tested in gnu/tests/touch/60-seconds
if local.second() == 59 && ts.ends_with(".60") {
local += Duration::seconds(1);
local += Duration::try_seconds(1).unwrap();
}

// Due to daylight saving time switch, local time can jump from 1:59 AM to
// 3:00 AM, in which case any time between 2:00 AM and 2:59 AM is not
// valid. If we are within this jump, chrono takes the offset from before
// the jump. If we then jump forward an hour, we get the new corrected
// offset. Jumping back will then now correctly take the jump into account.
let local2 = local + Duration::hours(1) - Duration::hours(1);
let local2 = local + Duration::try_hours(1).unwrap() - Duration::try_hours(1).unwrap();
if local.hour() != local2.hour() {
return Err(USimpleError::new(
1,
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {

fn str_to_filetime(format: &str, s: &str) -> FileTime {
let tm = chrono::NaiveDateTime::parse_from_str(s, format).unwrap();
FileTime::from_unix_time(tm.timestamp(), tm.timestamp_subsec_nanos())
FileTime::from_unix_time(tm.and_utc().timestamp(), tm.timestamp_subsec_nanos())
}

#[test]
Expand Down