Skip to content

Feature Request: as.ISO8601 #629

Closed
Closed
@billdenney

Description

@billdenney

as.ISO8601 methods would be useful for all the date, date/time, period, duration, and interval functions.

To make this as useful as possible, I think it would benefit to not use as.character and make a new as.ISO8601 generic function with arguments:

  • x: The object to convert
  • format: This would depend on what is being represented:
    • With dates, it could be "ymd" (year month day), "ywd" (year week day), "yd" (year day in YYYY-DDD format), "y" (year only), "m" (month only), "md" (month day only)
    • With times, it could be "hms", "hm", or "h"
    • With date/times, it could be any pair of the options for dates and times separated by a "T" (default "ymdThms"). I chose "T" rather than something else to align with the expected output as defined in the ISO standard.
    • Periods would share the format specifier with date, times, or date/times.
  • include_tz: if NULL (default), include/exclude the time zone from the date/time based on the input data. If FALSE, exclude the time zone from the representation, and if TRUE include the time zone in the representation. (It would be ignored if time zone does not apply to the output format.)
  • repeat: (default: NULL) For intervals, repeating could be specified by setting to a non-NULL, positive integer or Inf for indefinite, future repeats.
  • repeat_start: (default: NULL) For intervals, repeat start date/time. (Must be a date, time, or date/time object type.)

(As initially discussed in #362)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions