Skip to content

Document which casts xcast() supports for hms, Date and POSIXct - #117

Merged
joethorley merged 1 commit into
mainfrom
f-38-xcast-date-docs
Sep 30, 2026
Merged

joethorley merged 1 commit into
mainfrom
f-38-xcast-date-docs

Conversation

@joethorley

Copy link
Copy Markdown
Member

Closes #38.

xcast() passes the conversion to vctrs::vec_cast(). The hms package provides casts from numeric and character values to hms, but vctrs deliberately does not provide casts from numeric or character values to Date or POSIXct as they require an origin, format or time zone.

  • Explains this in the xcast() details and says that Date and POSIXct values must be created with the required class (e.g. as.Date(), as.POSIXct()), and that POSIXct values are converted to the time zone of the column.
  • Adds examples casting to hms from character and supplying Date and POSIXct values.
  • Adds a test that Date and POSIXct values are accepted and that POSIXct keeps the same instant in the column's time zone.

No behaviour change.

🤖 Generated with Claude Code

Closes #38.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@joethorley
joethorley merged commit 0976adb into main Sep 30, 2026
9 checks passed
@joethorley
joethorley deleted the f-38-xcast-date-docs branch September 30, 2026 23:31
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.

Why can xcast numeric and text to hms but not to Date or POSIXt?

1 participant