Skip to content

fix: auto-detect 2-digit-year (M/D/YY) dates and datetimes (#36088)#1

Open
hidekoji wants to merge 1 commit into
detect_slash_datetimefrom
fix/issue-36088-2digit-year
Open

fix: auto-detect 2-digit-year (M/D/YY) dates and datetimes (#36088)#1
hidekoji wants to merge 1 commit into
detect_slash_datetimefrom
fix/issue-36088-2digit-year

Conversation

@hidekoji

@hidekoji hidekoji commented Jun 1, 2026

Copy link
Copy Markdown

Problem

exploratory-io/tam#36088: dragging a CSV with M/D/YY dates (e.g. 5/29/26) imports the date columns as character. The year-last date heuristic only accepted 4-digit years, and there was no year-last heuristic for datetimes.

Fix

  • consumeYearFlexible(): consume a 2- or 4-digit year, applying the %y pivot (00-68→2000s, 69-99→1900s); reject 3-digit years.
  • parseYearLastHeuristic() + parseDateOrder() 'y' case route through it.
  • Add parseYearLastHeuristicDateTime(); wire into guess_type.cc isDateTime() and vroom_dttm.cc materialization as an ISO8601 fallback.
  • Extract disambiguateDayMonth() shared by both heuristics.

Tests

testthat coverage for 2-digit MDY/DMY/ambiguous dates, the %y pivot, invalid/3-digit rejection, 2- and 4-digit MDY datetimes, and explicit date_order with 2-digit years. Existing test-datetime.R passes with no regressions.

Version → 1.7.0.3.

🤖 Generated with Claude Code

The year-last date heuristic only accepted 4-digit years
(consumeInteger(4, &year_) with exact=true, plus a year_ < 1000 guard),
so M/D/YY values like 5/29/26 were guessed as character. Datetime
auto-detection only handled ISO8601.

- Add consumeYearFlexible(): consume a 2- or 4-digit year, applying the
  %y pivot (00-68 -> 2000s, 69-99 -> 1900s); reject 3-digit years.
- parseYearLastHeuristic() + parseDateOrder() 'y' case route through it.
- Add parseYearLastHeuristicDateTime() and wire it into guess_type
  isDateTime() and vroom_dttm.cc materialization as an ISO8601 fallback.
- Extract disambiguateDayMonth() shared by both heuristics.
- Add testthat coverage for 2-digit MDY/DMY/ambiguous dates, %y pivot,
  invalid/3-digit rejection, 2- and 4-digit MDY datetimes, and explicit
  date_order with 2-digit years.

Bump version to 1.7.0.3.

Ref: exploratory-io/tam#36088

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hidekoji hidekoji changed the base branch from main to detect_slash_datetime June 1, 2026 22:06
@hidekoji

hidekoji commented Jun 1, 2026

Copy link
Copy Markdown
Author

Released as v1.7.0.3 (tagged off this branch head 8b480fa7 = v1.7.0.2 + the 2-digit-year fix), per tam#36088. Mac Intel+ARM binaries built from this tag are uploaded to download2 and referenced by tam PR exploratory-io/tam#36090.

Base retargeted from main (which predates the date_order feature) to detect_slash_datetime (the feature/release lineage). Not auto-merging — branch reconciliation (incl. the interim archive_read/test commits and fast-forwarding main) is left to the maintainer. Windows binary still pending (build host was offline).

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.

1 participant