dgkf / dgkf/parttime

Allow casting from `Date` and `POSIXt` objects

Open
#55 2 comments 1 reaction 0 assignees View on GitHub
change::minor design (api) enhancement
Dominant language
R
Stars
18
Forks
1
PR merge metrics
No merged PRs in 30d

Description

I think that it would be useful to be able to cast `Date` and `POSIXt` objects to parttime objects.

My initial thought would be something like the following:

``` r
library(parttime)
#> Warning: package 'parttime' was built under R version 4.3.3
#> Initializing default timezone offset, which is assumed when timezone
#> parts are missing.
#>
#> options("parttime.assume_tz_offset" = 0L)
#>
#> Attaching package: 'parttime'
#> The following objects are masked from 'package:stats':
#>
#> end, start
#> The following objects are masked from 'package:base':
#>
#> pmax, pmin

as.parttime("2001")
#> [1]>
#> [1] "2001"
as.parttime(as.Date("2001-01-01"), missing_year = FALSE, missing_month = TRUE, missing_day = TRUE)
#> Error in vctrs::stop_incompatible_cast(x, to): argument "x_arg" is missing, with no default
```

Created on 2024-05-15 with [reprex v2.1.0](https://reprex.tidyverse.org)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.