From c97e7c81b37a6037f0cb04551b4e48228b837043 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 15 Sep 2025 12:51:19 -0700 Subject: [PATCH] rust: Allow creation date in system files to contain dashes. --- rust/doc/src/system-file.md | 8 ++++---- rust/pspp/src/sys/cooked.rs | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rust/doc/src/system-file.md b/rust/doc/src/system-file.md index 06767966ce..4e23a04fc7 100644 --- a/rust/doc/src/system-file.md +++ b/rust/doc/src/system-file.md @@ -263,14 +263,14 @@ A system file begins with the file header, with the following format: Date of creation of the system file, in `dd mmm yy` format, with the month as standard English abbreviations, using an initial - capital letter and following with lowercase. If the date is not - available then this field is arbitrarily set to `01 Jan 70`. + capital letter and following with lowercase. + + > Some files in the corpus have the date in `dd-mmm-yy` format. * `char creation_time[8];` Time of creation of the system file, in `hh:mm:ss` format and using - 24-hour time. If the time is not available then this field is - arbitrarily set to `00:00:00`. + 24-hour time. * `char file_label[64];` diff --git a/rust/pspp/src/sys/cooked.rs b/rust/pspp/src/sys/cooked.rs index abb18fd599..5702522ec9 100644 --- a/rust/pspp/src/sys/cooked.rs +++ b/rust/pspp/src/sys/cooked.rs @@ -1474,6 +1474,7 @@ impl Metadata { fn decode(header: &FileHeader, headers: &Records, mut warn: impl FnMut(Error)) -> Self { let header = &header; let creation_date = NaiveDate::parse_from_str(&header.creation_date, "%e %b %y") + .or_else(|_| NaiveDate::parse_from_str(&header.creation_date, "%e-%b-%y")) .unwrap_or_else(|_| { warn(Error::InvalidCreationDate(header.creation_date.to_string())); Default::default() -- 2.30.2