Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: ISO 8601 representations with reduced accuracy #1142

Open
ramiromagno opened this issue Oct 14, 2023 · 0 comments
Open

Question: ISO 8601 representations with reduced accuracy #1142

ramiromagno opened this issue Oct 14, 2023 · 0 comments

Comments

@ramiromagno
Copy link

ISO 8601 allows for "representations with reduced accuracy," meaning that you can omit certain components of the date and time if they are not relevant or available. Here are some examples:

Date Only:
    YYYY-MM-DD (complete)
    YYYY-MM (reduced accuracy, no day)
    YYYY (reduced accuracy, no month or day)

Time Only:
    HH:MM:SS (complete)
    HH:MM (reduced accuracy, no seconds)
    HH (reduced accuracy, no minutes or seconds)

Combined Date and Time:
    YYYY-MM-DDTHH:MM:SS (complete)
    YYYY-MM-DDTHH:MM (reduced accuracy, no seconds)
    YYYY-MM-DDTHH (reduced accuracy, no minutes or seconds)

Is this supported in lubridate? I mean, is there a way to generate ISO 8601 strings with missing components, and indicate how those missing components are represented, e.g. with an hyphen? Are lubridate functions' implementation, in one way or the other, always going through strftime() or strptime()? As far as I understand these functions always impute the missing values to 0. Is there any low-level parser that collects all date-time components into a list before missing elements are converted to default values?

Here are examples of ISO 8601 dates or date-times that illustrate what I would like to achieve:

From Precision To
December 15, 2003 13:14 Unknown seconds 2003-12-15T13:14
December 15, 2003 13 Unknown minutes and seconds 2003-12-15T13
December 15, 2003 Unknown time 2003-12-15
December, 2003 Unknown day and time 2003-12
2003 Unknown month, day, and time 2003
Between 10:00 and 10:30 on the morning of December 15, 2003 2003-12-15T10:00/2003-12-15T10:30
Between the first of this year (2003) until "now" (February 15, 2003) 2003-01-01/2003-02-15
December 15, 2003 ??:15 Unknown hour with known minutes 2003-12-15T-:15
December 15, 2003 13:??:17 Unknown minutes with known date, hours, and seconds 2003-12-15T13:-:17
The 15th of some month in 2003, time not collected Unknown month and time with known year and day 2003---15
December 15, but can't remember the year, time not collected Unknown year with known month and day --12-15
7:15 of some unknown date Unknown date with known hour and minute -----T07:15
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

No branches or pull requests

1 participant