Skip to content

fix(date): parse RFC 2822 and RFC 3339 date strings in --date flag#1163

Open
chaliy wants to merge 2 commits intomainfrom
fix/issue-1156-date-parse-rfc2822
Open

fix(date): parse RFC 2822 and RFC 3339 date strings in --date flag#1163
chaliy wants to merge 2 commits intomainfrom
fix/issue-1156-date-parse-rfc2822

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 9, 2026

Summary

  • Add RFC 2822 parsing (DateTime::parse_from_rfc2822) to parse_base_date() so date --date="Mon, 06 Apr 2026 12:00:00 +0000" works
  • Add RFC 3339 parsing (DateTime::parse_from_rfc3339) for timezone-aware ISO strings
  • Both use chrono's built-in parsers — no custom parsing logic

Why

date +"%B %d, %Y" --date="Mon, 06 Apr 2026 12:00:00 +0000" returned empty output because parse_base_date didn't recognize RFC 2822 format. This broke bashblog's timestamp formatting.

Tests

  • 3 unit tests: RFC 2822 format output, RFC 2822 epoch output, RFC 3339 input
  • 2 spec tests: date_rfc2822_input, date_rfc2822_input_epoch
  • All existing date tests continue to pass

Closes #1156

chaliy added 2 commits April 9, 2026 03:19
Closes #1156 — `date --date="Mon, 06 Apr 2026 12:00:00 +0000"` now
correctly parses RFC 2822 date strings instead of returning empty output.
Also adds RFC 3339 parsing support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(date): date --date= flag returns empty output

1 participant