From 95c81a70c181192f61b8966db8dcac13caf27709 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Tue, 22 Aug 2017 14:54:06 -0400 Subject: [PATCH 1/7] Add yesterday function --- .Rbuildignore | 2 ++ .gitignore | 1 + DESCRIPTION | 16 ++++++++++++++++ NAMESPACE | 4 ++++ R/imports.R | 2 ++ R/instants.R | 14 ++++++++++++++ README.Rmd | 35 +++++++++++++++++++++++++++++++++++ lubridateExtras.Rproj | 20 ++++++++++++++++++++ man/yesterday.Rd | 23 +++++++++++++++++++++++ 9 files changed, 117 insertions(+) create mode 100644 .Rbuildignore create mode 100644 DESCRIPTION create mode 100644 NAMESPACE create mode 100644 R/imports.R create mode 100644 R/instants.R create mode 100644 README.Rmd create mode 100644 lubridateExtras.Rproj create mode 100644 man/yesterday.Rd diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..91114bf --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore index fcff087..886732b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ vignettes/*.pdf # Temporary files created by R markdown *.utf8.md *.knit.md +.Rproj.user diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..6331cf4 --- /dev/null +++ b/DESCRIPTION @@ -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 diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..a0d2465 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,4 @@ +# Generated by roxygen2: do not edit by hand + +export(yesterday) +import(lubridate) diff --git a/R/imports.R b/R/imports.R new file mode 100644 index 0000000..a762875 --- /dev/null +++ b/R/imports.R @@ -0,0 +1,2 @@ +#' @import lubridate +NULL diff --git a/R/instants.R b/R/instants.R new file mode 100644 index 0000000..8ea0768 --- /dev/null +++ b/R/instants.R @@ -0,0 +1,14 @@ +#' 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)) +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..fe0ed56 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,35 @@ +--- +output: + github_document: + html_preview: false +--- + + + +```{r, echo = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "README-" +) +options(tibble.print_min = 5, tibble.print_max = 5) +``` + +# lubridateExtras + + + +## Overview + +## 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 diff --git a/lubridateExtras.Rproj b/lubridateExtras.Rproj new file mode 100644 index 0000000..b512aa3 --- /dev/null +++ b/lubridateExtras.Rproj @@ -0,0 +1,20 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: XeLaTeX + +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/man/yesterday.Rd b/man/yesterday.Rd new file mode 100644 index 0000000..d8459de --- /dev/null +++ b/man/yesterday.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{yesterday} +\alias{yesterday} +\title{The previous day} +\usage{ +yesterday(tzone = "") +} +\arguments{ +\item{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.} +} +\value{ +the previous date as a Date object +} +\description{ +The previous day +} +\examples{ +yesterday() +yesterday("GMT") +} From b9b6df37d32ec81dfd803b7c614e6a77fe2e9f80 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Fri, 25 Aug 2017 21:05:02 -0400 Subject: [PATCH 2/7] Add tomorrow --- R/instants.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/R/instants.R b/R/instants.R index 8ea0768..162d001 100644 --- a/R/instants.R +++ b/R/instants.R @@ -12,3 +12,18 @@ 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)) +} From 573cbf0da8b129970e543c91be7a29825308b9eb Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Tue, 29 Aug 2017 11:10:06 -0400 Subject: [PATCH 3/7] Add is.weekend function Update NAMESPACE exports Update R Documentation --- NAMESPACE | 2 ++ R/instants.R | 15 +++++++++++++++ man/is.weekend.Rd | 22 ++++++++++++++++++++++ man/tomorrow.Rd | 23 +++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 man/is.weekend.Rd create mode 100644 man/tomorrow.Rd diff --git a/NAMESPACE b/NAMESPACE index a0d2465..6b8b242 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(is.weekend) +export(tomorrow) export(yesterday) import(lubridate) diff --git a/R/instants.R b/R/instants.R index 162d001..44b9b11 100644 --- a/R/instants.R +++ b/R/instants.R @@ -27,3 +27,18 @@ yesterday <- function(tzone = "") { tomorrow <- function(tzone = "") { as_date(now(tzone) + days(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 = TRUE, abbr = FALSE) %in% c("Saturday", "Sunday") +} + diff --git a/man/is.weekend.Rd b/man/is.weekend.Rd new file mode 100644 index 0000000..b2bfdca --- /dev/null +++ b/man/is.weekend.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{is.weekend} +\alias{is.weekend} +\title{Is x a weekend?} +\usage{ +is.weekend(x) +} +\arguments{ +\item{x}{a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, +timeDate, xts, its, ti, jul, timeSeries, or fts object.} +} +\value{ +boolean indicating whether x is a weekend +} +\description{ +Is x a weekend? +} +\examples{ +is.weekend("2017-08-29") # FALSE +is.weekend("2017-09-02") # TRUE +} diff --git a/man/tomorrow.Rd b/man/tomorrow.Rd new file mode 100644 index 0000000..67c282d --- /dev/null +++ b/man/tomorrow.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{tomorrow} +\alias{tomorrow} +\title{The next day} +\usage{ +tomorrow(tzone = "") +} +\arguments{ +\item{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.} +} +\value{ +the previous date as a Date object +} +\description{ +The next day +} +\examples{ +tomorrow() +tomorrow("GMT") +} From 40a2417097fbabb8f0d8a0fe2e07961c5b1d2ee4 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Tue, 29 Aug 2017 13:31:07 -0400 Subject: [PATCH 4/7] Add logo SVG Begin pkgdown site --- .Rbuildignore | 3 ++ README.Rmd | 8 +++-- README.md | 25 +++++++++++++++- man/figures/logo.svg | 69 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 man/figures/logo.svg diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..99d5597 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,5 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +README.Rmd +^docs$ +^_pkgdown\.yml$ diff --git a/README.Rmd b/README.Rmd index fe0ed56..c2efd14 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,12 +15,16 @@ knitr::opts_chunk$set( options(tibble.print_min = 5, tibble.print_max = 5) ``` -# lubridateExtras +# lubridateExtras + +Convenience functions for the lubridate package ## 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 + ## Installation ```{r, eval = FALSE} @@ -31,5 +35,3 @@ 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 diff --git a/README.md b/README.md index 3972150..f2c2e58 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# lubridateExtras \ No newline at end of file + + +lubridateExtras +========================================================================================= + +Convenience functions for the lubridate package + + +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 + +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). diff --git a/man/figures/logo.svg b/man/figures/logo.svg new file mode 100644 index 0000000..251e9de --- /dev/null +++ b/man/figures/logo.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + RStudio_Hex 2016 v7 outlines + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lubridate + Extras + \ No newline at end of file From 373dfe9518cc64cfbfaffe0a5f647fc8919edcfc Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Tue, 29 Aug 2017 13:31:23 -0400 Subject: [PATCH 5/7] Add pkgdown yaml --- _pkgdown.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 _pkgdown.yml diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..2df9daa --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,5 @@ +url: https://ellisvalentiner.github.com/lubridateExtras + +template: + params: + bootswatch: lumen From 5afb8b7c5916e68014512fd324e69698d4a97df3 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Thu, 21 Sep 2017 16:31:08 -0400 Subject: [PATCH 6/7] Add days_ago and days_hence functions Add travis yaml Add codecov yaml Rebuild pkgdown site Rebuild documentation files --- .Rbuildignore | 2 + .gitignore | 11 +- .travis.yml | 22 ++++ NAMESPACE | 6 ++ R/instants.R | 80 +++++++++++++- README.Rmd | 14 ++- README.md | 15 ++- _pkgdown.yml | 16 +++ codecov.yml | 12 +++ docs/LICENSE.html | 127 ++++++++++++++++++++++ docs/authors.html | 111 +++++++++++++++++++ docs/index.html | 123 +++++++++++++++++++++ docs/jquery.sticky-kit.min.js | 9 ++ docs/link.svg | 12 +++ docs/pkgdown.css | 163 ++++++++++++++++++++++++++++ docs/pkgdown.js | 45 ++++++++ docs/pkgdown.yml | 5 + docs/reference/days_ago.html | 141 ++++++++++++++++++++++++ docs/reference/days_hence.html | 141 ++++++++++++++++++++++++ docs/reference/figures/logo.svg | 69 ++++++++++++ docs/reference/index.html | 185 ++++++++++++++++++++++++++++++++ docs/reference/is.weekday.html | 136 +++++++++++++++++++++++ docs/reference/is.weekend.html | 136 +++++++++++++++++++++++ docs/reference/last_month.html | 133 +++++++++++++++++++++++ docs/reference/next_month.html | 133 +++++++++++++++++++++++ docs/reference/this_month.html | 133 +++++++++++++++++++++++ docs/reference/tomorrow.html | 137 +++++++++++++++++++++++ docs/reference/yesterday.html | 137 +++++++++++++++++++++++ man/days_ago.Rd | 25 +++++ man/days_hence.Rd | 25 +++++ man/is.weekday.Rd | 22 ++++ man/last_month.Rd | 19 ++++ man/next_month.Rd | 19 ++++ man/this_month.Rd | 19 ++++ 34 files changed, 2371 insertions(+), 12 deletions(-) create mode 100644 .travis.yml create mode 100644 codecov.yml create mode 100644 docs/LICENSE.html create mode 100644 docs/authors.html create mode 100644 docs/index.html create mode 100644 docs/jquery.sticky-kit.min.js create mode 100644 docs/link.svg create mode 100644 docs/pkgdown.css create mode 100644 docs/pkgdown.js create mode 100644 docs/pkgdown.yml create mode 100644 docs/reference/days_ago.html create mode 100644 docs/reference/days_hence.html create mode 100644 docs/reference/figures/logo.svg create mode 100644 docs/reference/index.html create mode 100644 docs/reference/is.weekday.html create mode 100644 docs/reference/is.weekend.html create mode 100644 docs/reference/last_month.html create mode 100644 docs/reference/next_month.html create mode 100644 docs/reference/this_month.html create mode 100644 docs/reference/tomorrow.html create mode 100644 docs/reference/yesterday.html create mode 100644 man/days_ago.Rd create mode 100644 man/days_hence.Rd create mode 100644 man/is.weekday.Rd create mode 100644 man/last_month.Rd create mode 100644 man/next_month.Rd create mode 100644 man/this_month.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 99d5597..8de87b9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,5 @@ README.Rmd ^docs$ ^_pkgdown\.yml$ +^codecov\.yml$ +^\.travis\.yml$ diff --git a/.gitignore b/.gitignore index 886732b..ea614de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7dea3a1 --- /dev/null +++ b/.travis.yml @@ -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()' diff --git a/NAMESPACE b/NAMESPACE index 6b8b242..cb8c51d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +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) diff --git a/R/instants.R b/R/instants.R index 44b9b11..d67a41f 100644 --- a/R/instants.R +++ b/R/instants.R @@ -28,6 +28,71 @@ 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 @@ -39,6 +104,19 @@ tomorrow <- function(tzone = "") { #' is.weekend("2017-08-29") # FALSE #' is.weekend("2017-09-02") # TRUE is.weekend <- function(x) { - wday(x = as_date(x), label = TRUE, abbr = FALSE) %in% c("Saturday", "Sunday") + wday(x = as_date(x), label = FALSE, abbr = FALSE) %in% 6: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% 1:5 +} diff --git a/README.Rmd b/README.Rmd index c2efd14..47ad105 100644 --- a/README.Rmd +++ b/README.Rmd @@ -23,7 +23,7 @@ Convenience functions for the lubridate package ## 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 +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 @@ -35,3 +35,15 @@ 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) + +days_ago(7) # equivalent to lubridate::today() - lubridate::days(7) + +days_hence(7) # equivalent to lubridate::today() + lubridate::days(7) +``` + + diff --git a/README.md b/README.md index f2c2e58..b6685fb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Convenience functions for the lubridate package 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 +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 ------------ @@ -22,3 +22,16 @@ 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) + +days_ago(7) # equivalent to lubridate::today() - lubridate::days(7) +#> [1] "2017-09-14" + +days_hence(7) # equivalent to lubridate::today() + lubridate::days(7) +#> [1] "2017-09-28" +``` diff --git a/_pkgdown.yml b/_pkgdown.yml index 2df9daa..78fc6b5 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -3,3 +3,19 @@ url: https://ellisvalentiner.github.com/lubridateExtras template: params: bootswatch: lumen + +home: + strip_header: true + +navbar: + type: default + left: + - text: Intro + href: lubridateExtras.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 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..7568e9e --- /dev/null +++ b/codecov.yml @@ -0,0 +1,12 @@ +comment: false + +coverage: + status: + patch: + default: + target: 0 + threshold: 100 + project: + default: + target: 70 + threshold: 100 diff --git a/docs/LICENSE.html b/docs/LICENSE.html new file mode 100644 index 0000000..5b7bc16 --- /dev/null +++ b/docs/LICENSE.html @@ -0,0 +1,127 @@ + + + + + + + + +License • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
MIT License
+
+Copyright (c) 2017 Ellis Valentiner
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+ +
+ +
+ + +
+ + +
+

Site built with pkgdown.

+
+ +
+
+ + + diff --git a/docs/authors.html b/docs/authors.html new file mode 100644 index 0000000..57f22fc --- /dev/null +++ b/docs/authors.html @@ -0,0 +1,111 @@ + + + + + + + + +Authors • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
    +
  • +

    Ellis Valentiner. Author, maintainer. +

    +
  • +
+ +
+ +
+ + +
+ + +
+

Site built with pkgdown.

+
+ +
+
+ + + diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..b6749e1 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,123 @@ + + + + + + + +Convenience functions for the lubridate package • lubridateExtras + + + + + + +
+
+ + + +
+
+ + + + +
+ +
+ +

Convenience functions for the lubridate package

+ +
+

+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

+
# 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.

+
+
+

+Usage

+
library(lubridateExtras)
+
+days_ago(7)  # equivalent to lubridate::today() - lubridate::days(7)
+#> [1] "2017-09-14"
+
+days_hence(7)  # equivalent to lubridate::today() + lubridate::days(7)
+#> [1] "2017-09-28"
+
+
+
+
+ + + +
+ + +
+ +
+

Site built with pkgdown.

+
+ +
+
+ + + diff --git a/docs/jquery.sticky-kit.min.js b/docs/jquery.sticky-kit.min.js new file mode 100644 index 0000000..e2a3c6d --- /dev/null +++ b/docs/jquery.sticky-kit.min.js @@ -0,0 +1,9 @@ +/* + Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net +*/ +(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); +if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, +u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}), +a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", +y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n + + + + + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..209ce57 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,163 @@ +/* Sticker footer */ +body > .container { + display: flex; + padding-top: 60px; + min-height: calc(100vh); + flex-direction: column; +} + +body > .container .row { + flex: 1; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +img { + max-width: 100%; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + margin-left: -30px; + display:inline-block; + width: 30px; + height: 30px; + visibility: hidden; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +.hasAnchor:hover a.anchor { + visibility: visible; +} + +@media (max-width: 767px) { + .hasAnchor:hover a.anchor { + visibility: hidden; + } +} + + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -60px; +} + +/* Static header placement on mobile devices */ +@media (max-width: 767px) { + .navbar-fixed-top { + position: absolute; + } + .navbar { + padding: 0; + } +} + + +/* Sidebar --------------------------*/ + +#sidebar { + margin-top: 30px; +} +#sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#sidebar h2:first-child { + margin-top: 0; +} + +#sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} +.ref-index h2 {font-size: 20px;} + +.ref-index td {vertical-align: top;} +.ref-index .alias {width: 40%;} +.ref-index .title {width: 60%;} + +.ref-index .alias {width: 40%;} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; +} + +pre, code { + background-color: #f8f8f8; + color: #333; +} + +pre .img { + margin: 5px 0; +} + +pre .img img { + background-color: #fff; + display: block; + height: auto; +} + +code a, pre a { + color: #375f84; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} + diff --git a/docs/pkgdown.js b/docs/pkgdown.js new file mode 100644 index 0000000..4b81713 --- /dev/null +++ b/docs/pkgdown.js @@ -0,0 +1,45 @@ +$(function() { + $("#sidebar").stick_in_parent({offset_top: 40}); + $('body').scrollspy({ + target: '#sidebar', + offset: 60 + }); + + var cur_path = paths(location.pathname); + $("#navbar ul li a").each(function(index, value) { + if (value.text == "Home") + return; + if (value.getAttribute("href") === "#") + return; + + var path = paths(value.pathname); + if (is_prefix(cur_path, path)) { + // Add class to parent
  • , and enclosing
  • if in dropdown + var menu_anchor = $(value); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); +}); + +function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); +} + +function is_prefix(needle, haystack) { + if (needle.length > haystack.lengh) + return(false); + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(false); + } + + return(true); +} diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..82187a8 --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,5 @@ +urls: + reference: https://ellisvalentiner.github.com/lubridateExtras/reference + article: https://ellisvalentiner.github.com/lubridateExtras/articles +articles: {} + diff --git a/docs/reference/days_ago.html b/docs/reference/days_ago.html new file mode 100644 index 0000000..365fd68 --- /dev/null +++ b/docs/reference/days_ago.html @@ -0,0 +1,141 @@ + + + + + + + + +The date x days ago — days_ago • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The date x days ago

    + + +
    days_ago(days = 0, tzone = "")
    + +

    Arguments

    + + + + + + + + + + +
    days

    an integer specifying the number of days to subtract from the current

    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.

    + +

    Value

    + +

    the date, x days ago

    + + +

    Examples

    +
    days_ago(3)
    #> [1] "2017-09-18"
    days_ago(1) == yesterday()
    #> [1] TRUE
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/days_hence.html b/docs/reference/days_hence.html new file mode 100644 index 0000000..b3137cb --- /dev/null +++ b/docs/reference/days_hence.html @@ -0,0 +1,141 @@ + + + + + + + + +The date x days hence — days_hence • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The date x days hence

    + + +
    days_hence(days = 0, tzone = "")
    + +

    Arguments

    + + + + + + + + + + +
    days

    an integer specifying the number of days to add from the current

    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.

    + +

    Value

    + +

    the date, x days hence

    + + +

    Examples

    +
    days_hence(3)
    #> [1] "2017-09-24"
    days_hence(1) == tomorrow()
    #> [1] TRUE
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/figures/logo.svg b/docs/reference/figures/logo.svg new file mode 100644 index 0000000..251e9de --- /dev/null +++ b/docs/reference/figures/logo.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + RStudio_Hex 2016 v7 outlines + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lubridate + Extras + \ No newline at end of file diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..426d4db --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,185 @@ + + + + + + + + +Function reference • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    days_ago

    +

    The date x days ago

    +

    days_hence

    +

    The date x days hence

    +

    is.weekday

    +

    Is x a weekday?

    +

    is.weekend

    +

    Is x a weekend?

    +

    last_month

    +

    The previous month

    +

    next_month

    +

    The next month

    +

    this_month

    +

    The current month

    +

    tomorrow

    +

    The next day

    +

    yesterday

    +

    The previous day

    +
    +
    + + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/is.weekday.html b/docs/reference/is.weekday.html new file mode 100644 index 0000000..b02a785 --- /dev/null +++ b/docs/reference/is.weekday.html @@ -0,0 +1,136 @@ + + + + + + + + +Is x a weekday? — is.weekday • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    Is x a weekday?

    + + +
    is.weekday(x)
    + +

    Arguments

    + + + + + + +
    x

    a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, +timeDate, xts, its, ti, jul, timeSeries, or fts object.

    + +

    Value

    + +

    boolean indicating whether x is a weekday

    + + +

    Examples

    +
    is.weekend("2017-08-29") # FALSE
    #> [1] FALSE
    is.weekend("2017-09-02") # TRUE
    #> [1] TRUE
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/is.weekend.html b/docs/reference/is.weekend.html new file mode 100644 index 0000000..6c7b618 --- /dev/null +++ b/docs/reference/is.weekend.html @@ -0,0 +1,136 @@ + + + + + + + + +Is x a weekend? — is.weekend • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    Is x a weekend?

    + + +
    is.weekend(x)
    + +

    Arguments

    + + + + + + +
    x

    a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, +timeDate, xts, its, ti, jul, timeSeries, or fts object.

    + +

    Value

    + +

    boolean indicating whether x is a weekend

    + + +

    Examples

    +
    is.weekend("2017-08-29") # FALSE
    #> [1] FALSE
    is.weekend("2017-09-02") # TRUE
    #> [1] TRUE
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/last_month.html b/docs/reference/last_month.html new file mode 100644 index 0000000..25a5ce2 --- /dev/null +++ b/docs/reference/last_month.html @@ -0,0 +1,133 @@ + + + + + + + + +The previous month — last_month • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The previous month

    + + +
    last_month(tzone = "")
    + +

    Arguments

    + + + + + + +
    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.

    + +

    Value

    + +

    the previous month as a Date object

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/next_month.html b/docs/reference/next_month.html new file mode 100644 index 0000000..52c738b --- /dev/null +++ b/docs/reference/next_month.html @@ -0,0 +1,133 @@ + + + + + + + + +The next month — next_month • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The next month

    + + +
    next_month(tzone = "")
    + +

    Arguments

    + + + + + + +
    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.

    + +

    Value

    + +

    the next month as a Date object

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/this_month.html b/docs/reference/this_month.html new file mode 100644 index 0000000..8626ab9 --- /dev/null +++ b/docs/reference/this_month.html @@ -0,0 +1,133 @@ + + + + + + + + +The current month — this_month • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The current month

    + + +
    this_month(tzone = "")
    + +

    Arguments

    + + + + + + +
    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.

    + +

    Value

    + +

    the current month as a Date object

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/tomorrow.html b/docs/reference/tomorrow.html new file mode 100644 index 0000000..ce2a653 --- /dev/null +++ b/docs/reference/tomorrow.html @@ -0,0 +1,137 @@ + + + + + + + + +The next day — tomorrow • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The next day

    + + +
    tomorrow(tzone = "")
    + +

    Arguments

    + + + + + + +
    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.

    + +

    Value

    + +

    the previous date as a Date object

    + + +

    Examples

    +
    tomorrow()
    #> [1] "2017-09-22"
    tomorrow("GMT")
    #> [1] "2017-09-22"
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/reference/yesterday.html b/docs/reference/yesterday.html new file mode 100644 index 0000000..edd9b92 --- /dev/null +++ b/docs/reference/yesterday.html @@ -0,0 +1,137 @@ + + + + + + + + +The previous day — yesterday • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + +

    The previous day

    + + +
    yesterday(tzone = "")
    + +

    Arguments

    + + + + + + +
    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.

    + +

    Value

    + +

    the previous date as a Date object

    + + +

    Examples

    +
    yesterday()
    #> [1] "2017-09-20"
    yesterday("GMT")
    #> [1] "2017-09-20"
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/man/days_ago.Rd b/man/days_ago.Rd new file mode 100644 index 0000000..c5a70c1 --- /dev/null +++ b/man/days_ago.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{days_ago} +\alias{days_ago} +\title{The date x days ago} +\usage{ +days_ago(days = 0, tzone = "") +} +\arguments{ +\item{days}{an integer specifying the number of days to subtract from the current} + +\item{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.} +} +\value{ +the date, x days ago +} +\description{ +The date x days ago +} +\examples{ +days_ago(3) +days_ago(1) == yesterday() +} diff --git a/man/days_hence.Rd b/man/days_hence.Rd new file mode 100644 index 0000000..41ce087 --- /dev/null +++ b/man/days_hence.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{days_hence} +\alias{days_hence} +\title{The date x days hence} +\usage{ +days_hence(days = 0, tzone = "") +} +\arguments{ +\item{days}{an integer specifying the number of days to add from the current} + +\item{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.} +} +\value{ +the date, x days hence +} +\description{ +The date x days hence +} +\examples{ +days_hence(3) +days_hence(1) == tomorrow() +} diff --git a/man/is.weekday.Rd b/man/is.weekday.Rd new file mode 100644 index 0000000..c3c8ed4 --- /dev/null +++ b/man/is.weekday.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{is.weekday} +\alias{is.weekday} +\title{Is x a weekday?} +\usage{ +is.weekday(x) +} +\arguments{ +\item{x}{a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, +timeDate, xts, its, ti, jul, timeSeries, or fts object.} +} +\value{ +boolean indicating whether x is a weekday +} +\description{ +Is x a weekday? +} +\examples{ +is.weekend("2017-08-29") # FALSE +is.weekend("2017-09-02") # TRUE +} diff --git a/man/last_month.Rd b/man/last_month.Rd new file mode 100644 index 0000000..9faabdc --- /dev/null +++ b/man/last_month.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{last_month} +\alias{last_month} +\title{The previous month} +\usage{ +last_month(tzone = "") +} +\arguments{ +\item{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.} +} +\value{ +the previous month as a Date object +} +\description{ +The previous month +} diff --git a/man/next_month.Rd b/man/next_month.Rd new file mode 100644 index 0000000..f3dfa55 --- /dev/null +++ b/man/next_month.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{next_month} +\alias{next_month} +\title{The next month} +\usage{ +next_month(tzone = "") +} +\arguments{ +\item{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.} +} +\value{ +the next month as a Date object +} +\description{ +The next month +} diff --git a/man/this_month.Rd b/man/this_month.Rd new file mode 100644 index 0000000..e5127e5 --- /dev/null +++ b/man/this_month.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/instants.R +\name{this_month} +\alias{this_month} +\title{The current month} +\usage{ +this_month(tzone = "") +} +\arguments{ +\item{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.} +} +\value{ +the current month as a Date object +} +\description{ +The current month +} From b0cb75fbc12dadd10a2aa37ae145a8008cdd2a5f Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Sun, 24 Sep 2017 22:13:26 -0400 Subject: [PATCH 7/7] Add more written documentation for pkgdown site --- NEWS.md | 6 ++ R/instants.R | 4 +- README.Rmd | 8 ++ README.md | 17 ++++- _pkgdown.yml | 2 +- docs/LICENSE.html | 2 +- docs/articles/index.html | 110 ++++++++++++++++++++++++++++ docs/articles/intro.html | 112 ++++++++++++++++++++++++++++ docs/authors.html | 2 +- docs/index.html | 18 ++++- docs/news/index.html | 126 ++++++++++++++++++++++++++++++++ docs/pkgdown.yml | 3 +- docs/reference/days_ago.html | 4 +- docs/reference/days_hence.html | 4 +- docs/reference/figures/logo.svg | 7 -- docs/reference/index.html | 2 +- docs/reference/is.weekday.html | 2 +- docs/reference/is.weekend.html | 2 +- docs/reference/last_month.html | 2 +- docs/reference/next_month.html | 2 +- docs/reference/this_month.html | 2 +- docs/reference/tomorrow.html | 4 +- docs/reference/yesterday.html | 4 +- man/figures/logo.svg | 7 -- vignettes/intro.Rmd | 36 +++++++++ 25 files changed, 449 insertions(+), 39 deletions(-) create mode 100644 NEWS.md create mode 100644 docs/articles/index.html create mode 100644 docs/articles/intro.html create mode 100644 docs/news/index.html create mode 100644 vignettes/intro.Rmd diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..b2c22fc --- /dev/null +++ b/NEWS.md @@ -0,0 +1,6 @@ + +# lubridateExtras 0.1.0 + +## 2017-09-24 + +* Initial release notes diff --git a/R/instants.R b/R/instants.R index d67a41f..ac0d75b 100644 --- a/R/instants.R +++ b/R/instants.R @@ -104,7 +104,7 @@ next_month <- function(tzone = "") { #' 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% 6:7 + wday(x = as_date(x), label = FALSE, abbr = FALSE) %in% c(1, 7) } #' Is x a weekday? @@ -118,5 +118,5 @@ is.weekend <- function(x) { #' 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% 1:5 + wday(x = as_date(x), label = FALSE, abbr = FALSE) %in% 2:6 } diff --git a/README.Rmd b/README.Rmd index 47ad105..91daa79 100644 --- a/README.Rmd +++ b/README.Rmd @@ -41,9 +41,17 @@ If you encounter a clear bug, please file a minimal reproducible example on [git ```{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. diff --git a/README.md b/README.md index b6685fb..e4f9fc4 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,22 @@ 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-14" +#> [1] "2017-09-17" days_hence(7) # equivalent to lubridate::today() + lubridate::days(7) -#> [1] "2017-09-28" +#> [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. diff --git a/_pkgdown.yml b/_pkgdown.yml index 78fc6b5..87f04d4 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -11,7 +11,7 @@ navbar: type: default left: - text: Intro - href: lubridateExtras.html + href: articles/intro.html - text: Reference href: reference/index.html - text: News diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 5b7bc16..cd44d67 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -52,7 +52,7 @@
  • diff --git a/docs/news/index.html b/docs/news/index.html new file mode 100644 index 0000000..1007797 --- /dev/null +++ b/docs/news/index.html @@ -0,0 +1,126 @@ + + + + + + + + +All news • lubridateExtras + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    + +
    + + +
    +
    +

    +lubridateExtras 0.1.0

    +
    +

    +2017-09-24

    +
      +
    • Initial release notes
    • +
    +
    +
    +
    +
    + + + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 82187a8..3fe767b 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,5 +1,6 @@ urls: reference: https://ellisvalentiner.github.com/lubridateExtras/reference article: https://ellisvalentiner.github.com/lubridateExtras/articles -articles: {} +articles: + intro: intro.html diff --git a/docs/reference/days_ago.html b/docs/reference/days_ago.html index 365fd68..d3fce2a 100644 --- a/docs/reference/days_ago.html +++ b/docs/reference/days_ago.html @@ -52,7 +52,7 @@