{"record":{"id":"22f7d81b34931b31","repo":"can1357/oh-my-pi","slug":"unable-to-parse-date-0","errorCode":null,"errorMessage":"Unable to parse date: {0}","messagePattern":"Unable to parse date: (.+?)","errorType":"error_code","errorClass":"TouchError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/touch.rs","lineNumber":41,"sourceCode":"use jiff::{Timestamp, ToSpan, Zoned, civil::Time, fmt::strtime, tz::TimeZone};\n#[cfg(unix)]\nuse libc::O_NONBLOCK;\n#[cfg(unix)]\nuse rustix::fs::Timestamps;\n#[cfg(unix)]\nuse rustix::fs::futimens;\n#[cfg(target_os = \"linux\")]\nuse uucore::libc;\nuse uucore::{display::Quotable, parser::shortcut_value_parser::ShortcutValueParser};\n\nuse brush_core::{ShellExtensions, builtins::Registration};\nuse thiserror::Error as ThisError;\n\nuse crate::host::{Host, Utility, format_usage, matches_parser, util};\n\n#[derive(Debug, ThisError)]\nenum TouchError {\n\t#[error(\"Unable to parse date: {0}\")]\n\tInvalidDateFormat(String),\n\t#[error(\"Source has invalid access or modification time: {0}\")]\n\tInvalidFiletime(FileTime),\n\t#[error(\"failed to get attributes of {}: {}\", .0.quote(), io_error(.1))]\n\tReferenceFileInaccessible(PathBuf, std::io::Error),\n\t#[cfg(windows)]\n\t#[error(\"GetFinalPathNameByHandleW failed with code {0}\")]\n\tWindowsStdoutPathError(String),\n\t#[error(\"{0}\")]\n\tMessage(String),\n}\n\nfn io_error(error: &std::io::Error) -> String {\n\tif error.raw_os_error().is_some() {\n\t\tmatch error.kind() {\n\t\t\tErrorKind::NotFound => \"No such file or directory\".into(),\n\t\t\tErrorKind::PermissionDenied => \"Permission denied\".into(),\n\t\t\tErrorKind::AlreadyExists => \"Already exists\".into(),","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/touch.rs#L23-L59","documentation":"This touch builtin error (crates/pi-builtins/src/touch.rs, InvalidDateFormat) means the date string supplied with -d/--date could not be parsed. Touch accepts a limited set of human date formats (matching GNU touch); the raw string is echoed back in the message. It is a pure argument-validation error raised before any file is touched.","triggerScenarios":"Running touch with an unparsable --date value, e.g. `touch -d 'not a date' f`, locale-dependent formats like `touch -d '31/12/2026'` (day-first is not supported), or missing time components.","commonSituations":"Scripts generating dates with `date`-specific formats touch doesn't accept; regional date orders (DD/MM/YYYY); empty variables expanding to `touch -d ''`; porting from systems whose touch has a different date grammar.","solutions":["Use an ISO 8601 timestamp: `touch -d '2026-08-30 12:00:00' file`.","Feed dates through `date -I` / `date --iso-8601` when generating the value in scripts.","Validate/normalize the date variable before invoking touch (non-empty, ISO order YYYY-MM-DD).","If you meant 'now', omit -d entirely or use `touch -d now file`."],"exampleFix":"// before\ntouch -d '31/12/2026' stamp.txt  // Unable to parse date: 31/12/2026\n\n// after\ntouch -d '2026-12-31 00:00:00' stamp.txt","handlingStrategy":"validation","validationCode":"function isIsoDate(s) {\n  return typeof s === 'string' && /^\\d{4}-\\d{2}-\\d{2}([ T]\\d{2}:\\d{2}(:\\d{2})?)?$/.test(s) && !Number.isNaN(Date.parse(s.replace(' ', 'T')));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await touch.run(['-d', dateStr, file]);\n} catch (err) {\n  if (String(err).startsWith('Unable to parse date:')) {\n    console.error(`normalize '${dateStr}' to ISO 8601 (YYYY-MM-DD HH:MM:SS)`);\n  } else throw err;\n}","preventionTips":["Always generate -d values in ISO 8601 (YYYY-MM-DD HH:MM:SS).","Produce dates via `date --iso-8601` in scripts rather than locale formats.","Guard against empty/unset variables before passing them to -d."],"tags":["touch","date-parsing","input-validation"],"backgroundTag":"invalid-date-format","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}