These operations allow users to add or subtract dates messydate objects. Messydate objects include incomplete or uncertain dates, ranges of dates, negative dates, and date sets.

# S3 method for mdate
+(e1, e2)

# S3 method for mdate
-(e1, e2)

Arguments

e1

An mdate or date object.

e2

An mdate, date, or numeric object. Must be a scalar.

Value

A messydates vector

Examples

# \donttest{
d <- as_messydate(c("2008-03-25", "-2012-02-27", "2001-01?", "~2001",
"2001-01-01..2001-02-02", "{2001-01-01,2001-02-02}",
"2008-XX-31", "..2002-02-03", "2001-01-03..", "28 BC"))
tibble::tibble(date = d, add = d + 1, subtract = d - 1)
#> # A tibble: 10 × 3
#>    date                    add                     subtract               
#>    <mdate>                 <mdate>                 <mdate>                
#>  1 2008-03-25              2008-03-26              2008-03-24             
#>  2 -2012-02-27             -2012-02-26             -2012-02-28            
#>  3 2001-01?                2001-01-02..2001-02-01  2000-12-31..2001-01-30 
#>  4 ~2001                   2001-01-02..2002-01-01  2000-12-31..2001-12-30 
#>  5 2001-01-01..2001-02-02  2001-01-02..2001-02-03  2000-12-31..2001-02-01 
#>  6 {2001-01-01,2001-02-02} {2001-01-02,2001-02-03} {2000-12-31,2001-02-01}
#>  7 2008-XX-31              2008-02-01              2008-XX-30             
#>  8 ..2002-02-03            ..2002-02-04            ..2002-02-02           
#>  9 2001-01-03..            2001-01-04..            2001-01-02..           
#> 10 -0028                   -27-12-31..-28-12-30    -28-01-02..-29-01-01   
tibble::tibble(date = d, add = d + "1 year", subtract = d - "1 year")
#> # A tibble: 10 × 3
#>    date                    add                     subtract               
#>    <mdate>                 <mdate>                 <mdate>                
#>  1 2008-03-25              2009-03-25              2007-03-26             
#>  2 -2012-02-27             -2011-02-27             -2013-02-26            
#>  3 2001-01?                2002-01                 2000-01-02..2000-02-01 
#>  4 ~2001                   2002                    2000-01-02..2000-12-31 
#>  5 2001-01-01..2001-02-02  2002-01-01..2002-02-02  2000-01-02..2000-02-03 
#>  6 {2001-01-01,2001-02-02} {2002-01-01,2002-02-02} {2000-01-02,2000-02-03}
#>  7 2008-XX-31              2009-XX-30              2007-XX-31             
#>  8 ..2002-02-03            ..2003-02-03            ..2001-02-03           
#>  9 2001-01-03..            2002-01-03..            2000-01-04..           
#> 10 -0028                   -27-01-01..-28-01-01    -28-12-31..-29-12-31   
as_messydate("2001-01-01") + as_messydate("2001-01-02..2001-01-04")
#>  'mdate' chr "2001-01-01..2001-01-04"
as_messydate("2001-01-01") + as_messydate("2001-01-03")
#>  'mdate' chr "{2001-01-01,2001-01-03}"
as_messydate("2001-01-01..2001-01-04") - as_messydate("2001-01-02")
#> [[1]]
#>  'mdate' chr "{2001-01-01,2001-01-03..2001-01-04}"
#> 
#as_messydate("2001-01-01") - as_messydate("2001-01-03")
# }