This suggestion references @billdenney 's comment in #629, with the addition of a specific use case.
Bill wrote:
I didn't do the additional formatting for adding Z instead of -0000 for UTC because that would have added a notable amount more code. I can do it, but the longer-term maintenance didn't seem like it was worthwhile. If you'd like Z, I can make that update.
Example use case
The Twitter API v2 (example) currently only accepts YYYY-MM-DDTHH:mm:ssZ format for the start_time and end_time query parameters. Passing in YYYY-MM-DDTHH:mm:ss+0000 format results in a HTTP 400 Bad Request error. This makes it incompatible with lubridate::format_ISO8601()'s output.
lubridate::format_ISO8601(
lubridate::make_datetime(2019),
usetz = TRUE)
#> [1] "2019-01-01T00:00:00+0000"
It's not difficult for me to construct the "Z" format locally within my script and use that, but it would be great if this could be made part of lubridate's capability. Something like:
# pseudocode
lubridate::format_ISO8601(
lubridate::make_datetime(2019),
use_z_format = TRUE)
#> [1] "2019-01-01T00:00:00Z"
This option obviously is only appropriate when the tz is UTC, or more realistically, where no timezone is stipulated. Would require some thought as to how it would work in cases when a date with a timezone is passed in. Just return an error, I suppose.
I'm happy to work on a PR to try to provide this feature, but I haven't looked into the code yet.
PS I'm adding the inverse feature suggestion on Twitter's API feedback forum - that they should accept all valid ISO8601 datetime formats, but we don't have much control over what they do!
This suggestion references @billdenney 's comment in #629, with the addition of a specific use case.
Bill wrote:
Example use case
The Twitter API v2 (example) currently only accepts
YYYY-MM-DDTHH:mm:ssZformat for thestart_timeandend_timequery parameters. Passing inYYYY-MM-DDTHH:mm:ss+0000format results in a HTTP 400 Bad Request error. This makes it incompatible withlubridate::format_ISO8601()'s output.It's not difficult for me to construct the "Z" format locally within my script and use that, but it would be great if this could be made part of
lubridate's capability. Something like:This option obviously is only appropriate when the
tzis UTC, or more realistically, where no timezone is stipulated. Would require some thought as to how it would work in cases when a date with a timezone is passed in. Just return an error, I suppose.I'm happy to work on a PR to try to provide this feature, but I haven't looked into the code yet.
PS I'm adding the inverse feature suggestion on Twitter's API feedback forum - that they should accept all valid ISO8601 datetime formats, but we don't have much control over what they do!