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

Add format_ISO8601 with methods #700

Merged
merged 2 commits into from
Jul 27, 2018
Merged

Conversation

billdenney
Copy link
Contributor

Fix #629

Copy link
Member

@vspinu vspinu left a 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.

#' 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",
Copy link
Member

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.

if (is.null(precision)) {
precision <- max_precision
}
if (!(precision %in% names(precision_map))) {
Copy link
Member

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]]) { ...}

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.")
Copy link
Member

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.
Copy link
Member

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?

@vspinu
Copy link
Member

vspinu commented Jul 26, 2018

You will also have to add S4 aliases, otherwise CRAN check complains.

@billdenney
Copy link
Contributor Author

I think that what I just pushed addresses all of the suggestions (while Travis checks are pending).

@vspinu
Copy link
Member

vspinu commented Jul 27, 2018

Thanks 👍 !

@vspinu vspinu merged commit a62d089 into tidyverse:master Jul 27, 2018
@billdenney billdenney deleted the format_ISO8601 branch February 24, 2022 14:09
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

Successfully merging this pull request may close these issues.

2 participants