Skip to content

Commit fcccb21

Browse files
Merge pull request #8 from ellisvalentiner/v0.1.1
v0.1.1
2 parents b6171f2 + 925f9af commit fcccb21

24 files changed

+348
-36
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ README.Rmd
55
^_pkgdown\.yml$
66
^codecov\.yml$
77
^\.travis\.yml$
8+
^vignettes/*
9+
^CONDUCT\.md$
10+
^CONTRIBUTING\.md$

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ language: r
44
sudo: false
55
cache: packages
66
latex: false
7+
r_packages:
8+
- covr
79

810
env:
911
global:

CONDUCT.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# R Consortium and the R Community Code of Conduct
2+
3+
The R Consortium, like the R community as a whole, is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences great successes and continued growth.
4+
5+
Members of the R Consortium and their representatives are bound to follow this R Community Code of Conduct (which is based on the Python Community Code of Conduct). We encourage all members of the R community to likewise follow these guidelines which help steer our interactions and strive to keep R a positive, successful, and growing community.
6+
7+
# R Community Code of Conduct
8+
A member of the R Community is:
9+
10+
Open: Members of the community are open to collaboration, whether it's on projects, working groups, packages, problems, or otherwise. We're receptive to constructive comment and criticism, as the experiences and skill sets of other members contribute to the whole of our efforts. We're accepting of anyone who wishes to take part in our activities, fostering an environment where all can participate and everyone can make a difference.
11+
12+
Considerate: Members of the community are considerate of their peers — other R users. We're thoughtful when addressing the efforts of others, keeping in mind that oftentimes the labor was completed simply for the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.
13+
14+
Respectful: Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments, and their efforts. We're respectful of the volunteer efforts that permeate the R community. We're respectful of the processes set forth in the community, and we work within them. When we disagree, we are courteous in raising our issues.
15+
16+
Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.
17+
18+
Questions/comments/reports? Please write to the Code of Conduct address: conduct@r-consortium.org. (this will email the Board Chair and R Consortium Program manager). Include any available relevant information, including links to any publicly accessible material relating to the matter.

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing
2+
3+
lubridateExtras is an **Open Source** project and there are different ways to contribute.
4+
5+
Please, use [GitHub issues](https://github.com/ellisvalentiner/lubridateExtras/issues) to **report errors/bugs** or to **ask for new features**.
6+
7+
Contributions are welcome in the form of **pull requests**. Please follow these guidelines:
8+
9+
- Write code against the master branch but pull request against the dev branch.
10+
- By making a pull request, you're agreeing to license your code under a [MIT license](https://github.com/ellisvalentiner/lubridateExtras/blob/dev/LICENSE.md).
11+
- Code should be documented and tested.
12+
13+
## Style
14+
15+
### Function/variable naming & general syntax
16+
17+
* Use `snake_case` for function names.
18+
19+
* Avoid function names that conflict with base packages or other popular ones (e.g. `ggplot2`, `dplyr`, `magrittr`, `data.table`).
20+
21+
* Use an `object_verb()` naming scheme for functions that take a common data type or interact with a common API. `object` refers to the data/API and `verb` the primary action. This scheme helps avoid namespace conflicts with packages that may have similar verbs, and makes code readable and easy to auto-complete.
22+
23+
* Functions that manipulate an object/data and return an object/data of the same type, should accept the object/data as the first argument of the function so as to enhance compatibility with the pipe operator (`%>%`)
24+
25+
### Documentation
26+
27+
* All exported package functions should be fully documented with examples.
28+
29+
* When using `roxygen2`, add `#' @noRd` to internal functions.
30+
31+
### Testing
32+
33+
* Changes should pass `R CMD check`/`devtools::check()` on all major platforms.
34+
35+
## Conduct
36+
37+
We adhere to the [R Consortium and the R Community Code of Conduct](https://wiki.r-consortium.org/view/R_Consortium_and_the_R_Community_Code_of_Conduct).

DESCRIPTION

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: lubridateExtras
22
Type: Package
3-
Title: Convenience functions for the lubridate package
4-
Version: 0.1.0
3+
Title: Convenience Functions for Manipulating Datetimes
4+
Version: 0.1.1
55
Authors@R: c(
66
person("Ellis", "Valentiner", email = "ellis.valentiner@gmail.com", role = c("aut", "cre")),
77
person("Geoffrey", "Hannigan", email = "hanni035@umn.edu", role = c("ctb")))
@@ -10,11 +10,18 @@ Description: Provides extra functionality to lubridate. Largely consisting of
1010
License: MIT + file LICENSE
1111
Encoding: UTF-8
1212
LazyData: true
13+
Depends:
14+
R (>= 3.1.0)
1315
Imports:
14-
lubridate (>= 1.6.0)
16+
lubridate (>= 1.6.0),
17+
hms (>= 0.3)
1518
Suggests:
16-
knitr
19+
knitr (>= 1.17),
20+
testthat (>= 1.0.2)
1721
Remotes:
18-
tidyverse/lubridate
22+
tidyverse/lubridate,
23+
tidyverse/hms,
24+
yihui/knitr,
25+
r-lib/testthat
1926
VignetteBuilder: knitr
2027
RoxygenNote: 6.0.1

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export(days_ago)
44
export(days_hence)
5+
export(hms)
56
export(is.weekday)
67
export(is.weekend)
78
export(last_month)

R/instants.R

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#'
99
#' @examples
1010
#' yesterday()
11-
#' yesterday("GMT")
11+
#' yesterday("UTC")
1212
yesterday <- function(tzone = "") {
13-
as_date(now(tzone) - days(1))
13+
as_date(now(tzone = tzone) - days(1))
1414
}
1515

1616
#' The next day
@@ -23,9 +23,9 @@ yesterday <- function(tzone = "") {
2323
#'
2424
#' @examples
2525
#' tomorrow()
26-
#' tomorrow("GMT")
26+
#' tomorrow("UTC")
2727
tomorrow <- function(tzone = "") {
28-
as_date(now(tzone) + days(1))
28+
as_date(now(tzone = tzone) + days(1))
2929
}
3030

3131
#' The date x days ago
@@ -120,3 +120,15 @@ is.weekend <- function(x) {
120120
is.weekday <- function(x) {
121121
wday(x = as_date(x), label = FALSE, abbr = FALSE) %in% 2:6
122122
}
123+
124+
#' Extract time-of-day values
125+
#'
126+
#' @export hms
127+
#' @param x a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg,
128+
#' timeDate, xts, its, ti, jul, timeSeries, or fts object.
129+
#' @return hms object
130+
#' @examples
131+
#' hms("2017-10-22 15:01:00")
132+
hms <- function(x) {
133+
hms::as.hms(strftime(x, format="%H:%M:%S"))
134+
}

README.Rmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ knitr::opts_chunk$set(
1212
comment = "#>",
1313
fig.path = "README-"
1414
)
15-
options(tibble.print_min = 5, tibble.print_max = 5)
15+
options(
16+
tibble.print_min = 5,
17+
tibble.print_max = 5
18+
)
19+
Sys.setenv(TZ = "America/Detroit")
1620
```
1721

1822
# lubridateExtras <img src="man/figures/logo.svg" align="right" height="120" width="139" />
@@ -48,6 +52,8 @@ tomorrow()
4852
days_ago(7) # equivalent to lubridate::today() - lubridate::days(7)
4953
5054
days_hence(7) # equivalent to lubridate::today() + lubridate::days(7)
55+
56+
hms("2017-10-22 15:33:00") # extracts the time-of-day component
5157
```
5258

5359
## Why lubridateExtras?

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ Usage
3030
library(lubridateExtras)
3131

3232
yesterday()
33-
#> [1] "2017-10-11"
33+
#> [1] "2017-10-21"
3434

3535
tomorrow()
36-
#> [1] "2017-10-13"
36+
#> [1] "2017-10-23"
3737

3838
days_ago(7) # equivalent to lubridate::today() - lubridate::days(7)
39-
#> [1] "2017-10-05"
39+
#> [1] "2017-10-15"
4040

4141
days_hence(7) # equivalent to lubridate::today() + lubridate::days(7)
42-
#> [1] "2017-10-19"
42+
#> [1] "2017-10-29"
43+
44+
hms("2017-10-22 15:33:00") # extracts the time-of-day component
45+
#> 15:33:00
4346
```
4447

4548
Why lubridateExtras?

docs/articles/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/intro.html

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/days_ago.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/days_hence.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)