| Title: | Simple and Fast Date Manipulation on Character Strings |
| Version: | 1.1.0 |
| Description: | Provides simple and fast date manipulation functions operating on character strings in one of three formats: 'DD.MM.YYYY' (default), 'YYYY-MM-DD' or 'YYYYMMDD'. The format is chosen once per R session. Functions include extraction of day, month, and year components, computation of differences between two dates, and addition or subtraction of months. "DD" is ignored in the calculations, therefore a date like 31.02.2026 is a valid in- or output. That's why it is so fast. |
| License: | LGPL-3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-16 08:46:21 UTC; premluers |
| Author: | Prem Lueers |
| Maintainer: | Prem Lueers <prem@lueers.net> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-16 09:30:02 UTC |
dateAddMonths
Description
Adds or subtracts a number of whole months to or from a date. The day is left unchanged.
Usage
dateAddMonths(termin, monthsToBeAdded, format = .zustand$name)
Arguments
termin |
start date in the format of the flavour |
monthsToBeAdded |
number of whole months (positive: add, negative: subtract) |
format |
flavour; the default is the one set with |
Details
Invalid input, including NA and the empty string, is an error (version 1.0.0 returned NA).
Value
date in the format of the flavour
Examples
dateAddMonths("01.01.2000", -3 ) == "01.10.1999"
dateDiff
Description
Computes the difference between two dates in the format of the flavour. Returns the differences in years, months and total months as a named list.
Usage
dateDiff(frueher, spaeter, format = .zustand$name)
Arguments
frueher |
earlier date in the format of the flavour |
spaeter |
later date in the format of the flavour |
format |
flavour; the default is the one set with |
Details
Invalid input, including NA and the empty string, is an error (version 1.0.0 returned NA).
Value
list with diffJ (years), diffM (months), diffDauer (duration in fractional years), diffDauerM (total months)
Examples
dateDiff("01.01.2000", "01.12.1999")$diffDauerM == -1
flavour
Description
Returns the active flavour (date format) of the package theRefdate.
Usage
flavour()
Value
character string: "dmy" (DD.MM.YYYY), "iso" (YYYY-MM-DD) or
"iso_basic" (YYYYMMDD). The default is "dmy". Version 1.0.0 returned
"LP" for this format.
Examples
flavour() == "dmy"
Function 'jahr'
Description
Extracts the year from a date string as 'numeric'.
Usage
jahr(datumstring, format = .zustand$name)
Arguments
datumstring |
date string in the format of the flavour (default "DD.MM.YYYY") |
format |
flavour; the default is the one set with |
Details
Invalid input, including NA and the empty string, is an error (version 1.0.0 returned NA).
Value
numeric
Examples
jahr("02.02.2002") == 2002
Function 'monat'
Description
Extracts the month from a date string as 'numeric'.
Usage
monat(datumstring, format = .zustand$name)
Arguments
datumstring |
date string in the format of the flavour (default "DD.MM.YYYY") |
format |
flavour; the default is the one set with |
Details
Invalid input, including NA and the empty string, is an error (version 1.0.0 returned NA).
Value
numeric
Examples
monat("02.02.2000") == 2
setFlavour
Description
Sets the flavour (date format) used by all functions of the package as long as
they are called without their own argument format.
The setting is valid for the whole R session. Changing it to a different
flavour after it has been set once gives a warning.
If setFlavour is never called, the package works in the format
DD.MM.YYYY ("dmy") and returns the same results as version 1.0.0 for
every valid input.
Usage
setFlavour(flavour)
Arguments
flavour |
|
Value
the flavour that was set (invisibly)
Examples
setFlavour( "iso" )
jahr( "2002-02-02" ) == 2002
setFlavour( "dmy" )
Function 'tag'
Description
Extracts the day from a date string as 'numeric'.
Usage
tag(datumstring, format = .zustand$name)
Arguments
datumstring |
date string in the format of the flavour (default "DD.MM.YYYY") |
format |
flavour; the default is the one set with |
Details
Invalid input, including NA and the empty string, is an error (version 1.0.0 returned NA).
Value
numeric
Examples
tag("03.02.2000") == 3