Skip to content

Commit 310fec9

Browse files
committed
code style: line length <= 80 characters
Signed-off-by: Stefan Widgren <stefan.widgren@gmail.com>
1 parent b29bacf commit 310fec9

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

R/time.R

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
##'
1919
##' The class \code{git_time} stores the time a Git object was created.
2020
##'
21-
##' The default is to use \code{tz = "GMT"} and \code{origin = "1970-01-01"}. To
22-
##' use your local timezone, set \code{tz = Sys.timezone()}.
21+
##' The default is to use \code{tz = "GMT"} and \code{origin =
22+
##' "1970-01-01"}. To use your local timezone, set \code{tz =
23+
##' Sys.timezone()}.
2324
##'
2425
##' @inheritParams base::as.POSIXct
2526
##' @inheritParams base::strptime
@@ -49,13 +50,16 @@ NULL
4950

5051
##' @rdname git_time
5152
##' @export
52-
as.character.git_time <- function(x, tz = "GMT", origin = "1970-01-01", usetz = TRUE, ...) {
53-
as.character(format(as.POSIXct(x, tz = tz, origin = origin), usetz = usetz), ...)
53+
as.character.git_time <- function(x, tz = "GMT", origin = "1970-01-01",
54+
usetz = TRUE, ...) {
55+
as.character(format(as.POSIXct(x, tz = tz, origin = origin),
56+
usetz = usetz), ...)
5457
}
5558

5659
##' @rdname git_time
5760
##' @export
58-
format.git_time <- function(x, tz = "GMT", origin = "1970-01-01", usetz = TRUE, ...) {
61+
format.git_time <- function(x, tz = "GMT", origin = "1970-01-01",
62+
usetz = TRUE, ...) {
5963
format(as.POSIXct(x, tz = tz, origin = origin), usetz = usetz, ...)
6064
}
6165

@@ -67,7 +71,9 @@ as.POSIXct.git_time <- function(x, tz = "GMT", origin = "1970-01-01", ...) {
6771

6872
##' @rdname git_time
6973
##' @export
70-
print.git_time <- function(x, tz = "GMT", origin = "1970-01-01", usetz = TRUE, ...) {
71-
cat(sprintf("%s\n", as.character(x, tz = tz, origin = origin, usetz = usetz, ...)))
74+
print.git_time <- function(x, tz = "GMT", origin = "1970-01-01",
75+
usetz = TRUE, ...) {
76+
cat(sprintf("%s\n", as.character(x, tz = tz, origin = origin,
77+
usetz = usetz, ...)))
7278
invisible(x)
7379
}

R/when.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## git2r, R bindings to the libgit2 library.
2-
## Copyright (C) 2013-2018 The git2r contributors
2+
## Copyright (C) 2013-2019 The git2r contributors
33
##
44
## This program is free software; you can redistribute it and/or modify
55
## it under the terms of the GNU General Public License, version 2,
@@ -46,14 +46,19 @@
4646
##' }
4747
when <- function(object, tz = "GMT", origin = "1970-01-01", usetz = TRUE) {
4848
if (inherits(object, "git_commit"))
49-
return(as.character(object$author$when, tz = tz, origin = origin, usetz = usetz))
49+
return(as.character(object$author$when, tz = tz, origin = origin,
50+
usetz = usetz))
5051
if (inherits(object, "git_signature"))
51-
return(as.character(object$when, tz = tz, origin = origin, usetz = usetz))
52+
return(as.character(object$when, tz = tz, origin = origin,
53+
usetz = usetz))
5254
if (inherits(object, "git_stash"))
53-
return(as.character(object$stasher$when, tz = tz, origin = origin, usetz = usetz))
55+
return(as.character(object$stasher$when, tz = tz, origin = origin,
56+
usetz = usetz))
5457
if (inherits(object, "git_tag"))
55-
return(as.character(object$tagger$when, tz = tz, origin = origin, usetz = usetz))
58+
return(as.character(object$tagger$when, tz = tz, origin = origin,
59+
usetz = usetz))
5660
if (inherits(object, "git_time"))
57-
return(as.character(object, tz = tz, origin = origin, usetz = usetz))
61+
return(as.character(object, tz = tz, origin = origin,
62+
usetz = usetz))
5863
stop("Invalid 'object'")
5964
}

tests/time.R

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## with this program; if not, write to the Free Software Foundation, Inc.,
1515
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1616

17-
library("git2r")
17+
library(git2r)
1818

1919
## For debugging
2020
sessionInfo()
@@ -31,21 +31,27 @@ stopifnot(identical(print(git_t), git_t))
3131
as.POSIXct(1395567947, origin = "1970-01-01", tz = "-03")
3232

3333
## Test that origin/tz can be passed to as.POSIXct
34-
stopifnot(identical(as.POSIXct(git_t, tz = "Europe/Stockholm", origin = "1980-02-02"),
35-
as.POSIXct(1395567947, tz = "Europe/Stockholm", origin = "1980-02-02")))
34+
stopifnot(identical(as.POSIXct(git_t, tz = "Europe/Stockholm",
35+
origin = "1980-02-02"),
36+
as.POSIXct(1395567947, tz = "Europe/Stockholm",
37+
origin = "1980-02-02")))
3638

3739
## Test that origin/tz can be passed to as.character
38-
stopifnot(identical(as.character(git_t, tz = "Europe/Stockholm", origin = "1980-02-02"),
40+
stopifnot(identical(as.character(git_t, tz = "Europe/Stockholm",
41+
origin = "1980-02-02"),
3942
"2024-04-23 11:45:47 CEST"))
40-
stopifnot(identical(as.character(git_t, tz = "Europe/Stockholm", origin = "1980-02-02", usetz = FALSE),
43+
stopifnot(identical(as.character(git_t, tz = "Europe/Stockholm",
44+
origin = "1980-02-02", usetz = FALSE),
4145
"2024-04-23 11:45:47"))
4246

4347
## Test that origin/tz can be passed to print
4448
stopifnot(identical(
45-
utils::capture.output(print(git_t, tz = "Europe/Stockholm", origin = "1980-02-02")),
49+
utils::capture.output(print(git_t, tz = "Europe/Stockholm",
50+
origin = "1980-02-02")),
4651
"2024-04-23 11:45:47 CEST"
4752
))
4853
stopifnot(identical(
49-
utils::capture.output(print(git_t, tz = "Europe/Stockholm", origin = "1980-02-02", usetz = FALSE)),
54+
utils::capture.output(print(git_t, tz = "Europe/Stockholm",
55+
origin = "1980-02-02", usetz = FALSE)),
5056
"2024-04-23 11:45:47"
5157
))

0 commit comments

Comments
 (0)