{"record":{"id":"bb539ede51511de2","repo":"sharkdp/fd","slug":"is-not-a-valid-date-or-duration-see-fd-he","errorCode":null,"errorMessage":"'{}' is not a valid date or duration. See 'fd --help'.","messagePattern":"'(.+?)' is not a valid date or duration\\. See 'fd --help'\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":502,"sourceCode":"            return Err(anyhow!(\n                \"'fd --list-details' is not supported on Windows unless GNU 'ls' is installed.\"\n            ));\n        }\n    } else {\n        return Err(anyhow!(\n            \"'fd --list-details' is not supported on this platform.\"\n        ));\n    };\n    Ok(cmd)\n}\n\nfn extract_time_constraints(opts: &Opts) -> Result<Vec<TimeFilter>> {\n    let mut time_constraints: Vec<TimeFilter> = Vec::new();\n    if let Some(ref t) = opts.changed_within {\n        if let Some(f) = TimeFilter::after(t) {\n            time_constraints.push(f);\n        } else {\n            return Err(anyhow!(\n                \"'{}' is not a valid date or duration. See 'fd --help'.\",\n                t\n            ));\n        }\n    }\n    if let Some(ref t) = opts.changed_before {\n        if let Some(f) = TimeFilter::before(t) {\n            time_constraints.push(f);\n        } else {\n            return Err(anyhow!(\n                \"'{}' is not a valid date or duration. See 'fd --help'.\",\n                t\n            ));\n        }\n    }\n    Ok(time_constraints)\n}\n","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/sharkdp/fd/blob/ee20f426ddf338ac7ead5c5f00ea49258005caaf/src/main.rs#L484-L520","documentation":"extract_time_constraints (main.rs:496) parses --changed-within through TimeFilter::after, which tries four parsers in order (filter/time.rs:29): a jiff Span duration (e.g. '1d', '30min'), a Timestamp, a civil DateTime, or '@<unix-secs>'. If all four return None, the value is rejected at main.rs:502 with this message.","triggerScenarios":"Passing `fd --changed-within foo`, `fd --changed-within 5` (bare number, no unit), `fd --changed-within 2024-13-99` (bad date), or any value jiff cannot parse as span/timestamp/datetime/@epoch.","commonSituations":"Forgetting the duration unit; locale-specific date formats jiff doesn't accept; typos; confusing fd's duration grammar with find -mtime days (which is a count, not a duration string).","solutions":["Use a duration string: `fd --changed-within 1d`, `fd --changed-within 2h30min`, `fd --changed-within 1week`.","Use an ISO datetime or timestamp: `fd --changed-within 2024-01-01`, `fd --changed-within @1700000000`.","Consult `fd --help` for the accepted duration/date grammar."],"exampleFix":"# before\nfd --changed-within 5\n\n# after\nfd --changed-within 5d      # within last 5 days\nfd --changed-within 2h      # within last 2 hours","handlingStrategy":"validation","validationCode":"validate_within() {\n  # accept jiff span (e.g. 1d, 2h30min), ISO datetime, or @<epoch>\n  printf '%s' \"$1\" | grep -Eq '^(@[0-9]+|[0-9]{4}-[0-9]{2}-[0-9]{2}|[0-9]+[a-z]+)$' \\\n    && fd --changed-within \"$1\" \\\n    || { echo \"invalid duration/date\" >&2; exit 1; }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a unit for durations (d, h, min, week).","Use ISO 8601 dates or '@<epoch>' for absolute times.","Do not pass find-style bare day counts."],"tags":["time-filter","parsing","cli","duration"],"backgroundTag":null,"analyzedSha":"ee20f426ddf338ac7ead5c5f00ea49258005caaf","analyzedAt":"2026-08-09T08:21:40.573Z","contentChangedAt":"2026-08-09T08:21:40.573Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}