-
Notifications
You must be signed in to change notification settings - Fork 209
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
Add format_ISO8601 with methods #700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Thanks a bunch for this.
R/format_ISO8601.r
Outdated
#' more precise than \code{max_precision}, a warning is given and | ||
#' \code{max_precision} is returned. | ||
format_ISO8601_precision_check <- function(precision, max_precision, usetz=FALSE) { | ||
precision_map <- list(y="%Y", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be stored outside of the function to avoid construction on every call.
R/format_ISO8601.r
Outdated
if (is.null(precision)) { | ||
precision <- max_precision | ||
} | ||
if (!(precision %in% names(precision_map))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Micro optimization: if (is.null(ret <- precision_map[[precision]]) { ...}
R/format_ISO8601.r
Outdated
stop("Invalid value for precision provided: ", precision) | ||
} | ||
if (nchar(precision) > nchar(max_precision)) { | ||
warning("More precision requested (", precision, ") than allowed (", max_precision, ") for this format. Using maximum allowed precision.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please split this line ?
#' "ymdhm" would show precision through minutes. When \code{NULL}, full | ||
#' precision for the object is shown. | ||
#' @param ... Additional arguments to methods. | ||
#' @return A character vector of ISO8601-formatted text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add @references
with wiki page for ISO8601 format?
You will also have to add S4 aliases, otherwise CRAN check complains. |
I think that what I just pushed addresses all of the suggestions (while Travis checks are pending). |
Thanks 👍 ! |
Fix #629