-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ellisvalentiner/development
v0.1.0
- Loading branch information
Showing
46 changed files
with
3,075 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
README.Rmd | ||
^docs$ | ||
^_pkgdown\.yml$ | ||
^codecov\.yml$ | ||
^\.travis\.yml$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
||
# Session Data files | ||
.RData | ||
|
||
# Example code in package build process | ||
*-Ex.R | ||
|
||
# Output files from R CMD build | ||
/*.tar.gz | ||
|
||
# Output files from R CMD check | ||
/*.Rcheck/ | ||
|
||
# RStudio files | ||
.Rproj.user/ | ||
|
||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
|
||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
|
||
# knitr and R markdown default cache directories | ||
/*_cache/ | ||
/cache/ | ||
|
||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md | ||
.Rproj.user | ||
# macOS | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r | ||
|
||
language: r | ||
sudo: false | ||
cache: packages | ||
latex: false | ||
|
||
env: | ||
global: | ||
- _R_CHECK_FORCE_SUGGESTS_=false | ||
- MAKEFLAGS="-j 2" | ||
|
||
include: | ||
- r: release | ||
- r: oldrel | ||
- r: devel | ||
|
||
before_script: | ||
- mkdir -p ~/.R; echo 'PKG_CXXFLAGS := ${PKG_CXXFLAGS} -Wall -Wextra -pedantic -Werror' > ~/.R/Makevars | ||
|
||
after_success: | ||
- Rscript -e 'covr::codecov()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Package: lubridateExtras | ||
Type: Package | ||
Title: Convenience functions for the lubridate package | ||
Version: 0.1.0 | ||
Authors@R: person("Ellis", "Valentiner", email = "ellis.valentiner@gmail.com", | ||
role = c("aut", "cre")) | ||
Description: Provides extra functionality to lubridate. Largely consisting of | ||
convenience functions. | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
Imports: | ||
lubridate (>= 1.6.0) | ||
Remotes: | ||
tidyverse/lubridate | ||
RoxygenNote: 6.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(days_ago) | ||
export(days_hence) | ||
export(is.weekday) | ||
export(is.weekend) | ||
export(last_month) | ||
export(next_month) | ||
export(this_month) | ||
export(tomorrow) | ||
export(yesterday) | ||
import(lubridate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
# lubridateExtras 0.1.0 | ||
|
||
## 2017-09-24 | ||
|
||
* Initial release notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#' @import lubridate | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#' The previous day | ||
#' | ||
#' @export yesterday | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the previous date of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the previous date as a Date object | ||
#' | ||
#' @examples | ||
#' yesterday() | ||
#' yesterday("GMT") | ||
yesterday <- function(tzone = "") { | ||
as_date(now(tzone) - days(1)) | ||
} | ||
|
||
#' The next day | ||
#' | ||
#' @export tomorrow | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the previous date of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the previous date as a Date object | ||
#' | ||
#' @examples | ||
#' tomorrow() | ||
#' tomorrow("GMT") | ||
tomorrow <- function(tzone = "") { | ||
as_date(now(tzone) + days(1)) | ||
} | ||
|
||
#' The date x days ago | ||
#' | ||
#' @export days_ago | ||
#' @param days an integer specifying the number of days to subtract from the current | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the previous date of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the date, x days ago | ||
#' | ||
#' @examples | ||
#' days_ago(3) | ||
#' days_ago(1) == yesterday() | ||
days_ago <- function(days = 0, tzone = "") { | ||
as_date(today(tzone = tzone) - days(x = days)) | ||
} | ||
|
||
#' The date x days hence | ||
#' | ||
#' @export days_hence | ||
#' @param days an integer specifying the number of days to add from the current | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the previous date of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the date, x days hence | ||
#' | ||
#' @examples | ||
#' days_hence(3) | ||
#' days_hence(1) == tomorrow() | ||
days_hence <- function(days = 0, tzone = "") { | ||
as_date(today(tzone = tzone) + days(x = days)) | ||
} | ||
|
||
#' The current month | ||
#' | ||
#' @export this_month | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the current month of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the current month as a Date object | ||
this_month <- function(tzone = "") { | ||
floor_date(x = today(tzone = tzone), unit = "month") | ||
} | ||
|
||
#' The previous month | ||
#' | ||
#' @export last_month | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the previous month of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the previous month as a Date object | ||
last_month <- function(tzone = "") { | ||
floor_date(x = today(tzone = tzone), unit = "month") - months(1) | ||
} | ||
|
||
#' The next month | ||
#' | ||
#' @export next_month | ||
#' @param tzone a character vector specifying which time zone you would like to | ||
#' find the next month of. tzone defaults to the system time zone set on your | ||
#' computer. | ||
#' @return the next month as a Date object | ||
next_month <- function(tzone = "") { | ||
floor_date(x = today(tzone = tzone), unit = "month") + months(1) | ||
} | ||
|
||
#' Is x a weekend? | ||
#' | ||
#' @export is.weekend | ||
#' @param x a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, | ||
#' timeDate, xts, its, ti, jul, timeSeries, or fts object. | ||
#' @return boolean indicating whether x is a weekend | ||
#' | ||
#' @examples | ||
#' is.weekend("2017-08-29") # FALSE | ||
#' is.weekend("2017-09-02") # TRUE | ||
is.weekend <- function(x) { | ||
wday(x = as_date(x), label = FALSE, abbr = FALSE) %in% c(1, 7) | ||
} | ||
|
||
#' Is x a weekday? | ||
#' | ||
#' @export is.weekday | ||
#' @param x a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, | ||
#' timeDate, xts, its, ti, jul, timeSeries, or fts object. | ||
#' @return boolean indicating whether x is a weekday | ||
#' | ||
#' @examples | ||
#' is.weekend("2017-08-29") # FALSE | ||
#' is.weekend("2017-09-02") # TRUE | ||
is.weekday <- function(x) { | ||
wday(x = as_date(x), label = FALSE, abbr = FALSE) %in% 2:6 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
output: | ||
github_document: | ||
html_preview: false | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, echo = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "README-" | ||
) | ||
options(tibble.print_min = 5, tibble.print_max = 5) | ||
``` | ||
|
||
# lubridateExtras <img src="man/figures/logo.svg" align="right" height="120" width="139" /> | ||
|
||
Convenience functions for the lubridate package | ||
|
||
<!-- Placeholder for build status, CRAN status, and coverage status --> | ||
|
||
## Overview | ||
|
||
Lubridate makes it easier to work with date-time data in R and provides new capabilities. LubridateExtras builds on top of lubridate to provide a number of convenience functions, primarily focused on abstracting patterns in ways that improve code readability and reduce copying and pasting code. | ||
|
||
## Installation | ||
|
||
```{r, eval = FALSE} | ||
# lubridateExtras is not currently on CRAN | ||
# Please install the development version from GitHub: | ||
# install.packages("devtools") | ||
devtools::install_github("ellisvalentiner/lubridateExtras") | ||
``` | ||
|
||
If you encounter a clear bug, please file a minimal reproducible example on [github](https://github.com/ellisvalentiner/lubridateExtras/issues). | ||
|
||
## Usage | ||
|
||
```{r} | ||
library(lubridateExtras) | ||
yesterday() | ||
tomorrow() | ||
days_ago(7) # equivalent to lubridate::today() - lubridate::days(7) | ||
days_hence(7) # equivalent to lubridate::today() + lubridate::days(7) | ||
``` | ||
|
||
## Why lubridateExtras? | ||
|
||
Some people are probably asking the question: why lubridateExtras? | ||
|
||
lubridateExtras does not do anything that you cannot do with lubridate but similarly you don't need lubridate at all to work with date/times in R! If you like the syntactic sugar of lubridateExtras then use it, otherwise stick with what works for you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
# lubridateExtras | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
lubridateExtras <img src="man/figures/logo.svg" align="right" height="120" width="139" /> | ||
========================================================================================= | ||
|
||
Convenience functions for the lubridate package | ||
|
||
<!-- Placeholder for build status, CRAN status, and coverage status --> | ||
Overview | ||
-------- | ||
|
||
Lubridate makes it easier to work with date-time data in R and provides new capabilities. LubridateExtras builds on top of lubridate to provide a number of convenience functions, primarily focused on abstracting patterns in ways that improve code readability and reduce copying and pasting code. | ||
|
||
Installation | ||
------------ | ||
|
||
``` r | ||
# lubridateExtras is not currently on CRAN | ||
# Please install the development version from GitHub: | ||
# install.packages("devtools") | ||
devtools::install_github("ellisvalentiner/lubridateExtras") | ||
``` | ||
|
||
If you encounter a clear bug, please file a minimal reproducible example on [github](https://github.com/ellisvalentiner/lubridateExtras/issues). | ||
|
||
Usage | ||
----- | ||
|
||
``` r | ||
library(lubridateExtras) | ||
|
||
yesterday() | ||
#> [1] "2017-09-23" | ||
|
||
tomorrow() | ||
#> [1] "2017-09-25" | ||
|
||
days_ago(7) # equivalent to lubridate::today() - lubridate::days(7) | ||
#> [1] "2017-09-17" | ||
|
||
days_hence(7) # equivalent to lubridate::today() + lubridate::days(7) | ||
#> [1] "2017-10-01" | ||
``` | ||
|
||
Why lubridateExtras? | ||
-------------------- | ||
|
||
Some people are probably asking the question: why lubridateExtras? | ||
|
||
lubridateExtras does not do anything that you cannot do with lubridate but similarly you don't need lubridate at all to work with date/times in R! If you like the syntactic sugar of lubridateExtras then use it, otherwise stick with what works for you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
url: https://ellisvalentiner.github.com/lubridateExtras | ||
|
||
template: | ||
params: | ||
bootswatch: lumen | ||
|
||
home: | ||
strip_header: true | ||
|
||
navbar: | ||
type: default | ||
left: | ||
- text: Intro | ||
href: articles/intro.html | ||
- text: Reference | ||
href: reference/index.html | ||
- text: News | ||
href: news/index.html | ||
right: | ||
- icon: fa-github fa-lg | ||
href: https://github.com/ellisvalentiner/lubridateExtras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
comment: false | ||
|
||
coverage: | ||
status: | ||
patch: | ||
default: | ||
target: 0 | ||
threshold: 100 | ||
project: | ||
default: | ||
target: 70 | ||
threshold: 100 |
Oops, something went wrong.