Skip to content

Conversation

jdblischak
Copy link
Contributor

This PR is to address Issue #407. It was difficult for me to investigate the time issue because 1) print.git_time removed the timezone, 2) as.POSIXct.git_time hard-coded the timezone, and 3) the git_time class wasn't documented.

This PR 1) includes the timezone by default when coercing a git_time object, with the option to remove it with usetz = FALSE, 2) enables as.POSIXct.git_time and the other coercing functions to accept user input for tz and origin, and 3) creates a man page for ?git_time.

Signed-off-by: John Blischak <jdblischak@gmail.com>
Signed-off-by: John Blischak <jdblischak@gmail.com>
Signed-off-by: John Blischak <jdblischak@gmail.com>
Signed-off-by: John Blischak <jdblischak@gmail.com>
Signed-off-by: John Blischak <jdblischak@gmail.com>
@lintr-bot
Copy link

R/checkout.R:160:1: style: functions should have cyclomatic complexity of less than 15, this has 21.

checkout <- function(object = NULL, ^

R/config.R:56:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

config <- function(repo = NULL, global = FALSE, user.name, user.email, ...) { ^

R/time.R:52:1: style: Lines should not be more than 80 characters.

as.character.git_time <- function(x, tz = "GMT", origin = "1970-01-01", usetz = TRUE, ...) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/time.R:53:1: style: Lines should not be more than 80 characters.

​ as.character(format(as.POSIXct(x, tz = tz, origin = origin), usetz = usetz), ...) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/time.R:58:1: style: Lines should not be more than 80 characters.

format.git_time <- function(x, tz = "GMT", origin = "1970-01-01", usetz = TRUE, ...) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/time.R:70:1: style: Lines should not be more than 80 characters.

print.git_time <- function(x, tz = "GMT", origin = "1970-01-01", usetz = TRUE, ...) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/time.R:71:1: style: Lines should not be more than 80 characters.

​ cat(sprintf("%s\n", as.character(x, tz = tz, origin = origin, usetz = usetz, ...))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/when.R:49:1: style: Lines should not be more than 80 characters.

return(as.character(object$author$when, tz = tz, origin = origin, usetz = usetz)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/when.R:51:1: style: Lines should not be more than 80 characters.

return(as.character(object$when, tz = tz, origin = origin, usetz = usetz)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/when.R:53:1: style: Lines should not be more than 80 characters.

return(as.character(object$stasher$when, tz = tz, origin = origin, usetz = usetz)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/when.R:55:1: style: Lines should not be more than 80 characters.

return(as.character(object$tagger$when, tz = tz, origin = origin, usetz = usetz)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/time.R:34:1: style: Lines should not be more than 80 characters.

​stopifnot(identical(as.POSIXct(git_t, tz = "Europe/Stockholm", origin = "1980-02-02"), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/time.R:35:1: style: Lines should not be more than 80 characters.

​ as.POSIXct(1395567947, tz = "Europe/Stockholm", origin = "1980-02-02"))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/time.R:38:1: style: Lines should not be more than 80 characters.

​stopifnot(identical(as.character(git_t, tz = "Europe/Stockholm", origin = "1980-02-02"), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/time.R:40:1: style: Lines should not be more than 80 characters.

​stopifnot(identical(as.character(git_t, tz = "Europe/Stockholm", origin = "1980-02-02", usetz = FALSE), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/time.R:45:1: style: Lines should not be more than 80 characters.

utils::capture.output(print(git_t, tz = "Europe/Stockholm", origin = "1980-02-02")), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/time.R:49:1: style: Lines should not be more than 80 characters.

utils::capture.output(print(git_t, tz = "Europe/Stockholm", origin = "1980-02-02", usetz = FALSE)), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 81.276% when pulling 8cea769 on jdblischak:git_time into 71ff6ce on ropensci:master.

@stewid stewid merged commit b29bacf into ropensci:master Nov 18, 2019
@stewid
Copy link
Member

stewid commented Nov 18, 2019

Thanks for all your work to fix the git_time issue and improving the documentation 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants