Closed jhollway closed 2 years ago
I think arithmetic functions such as the ability to add 3 days to a range of dates is important.
To start with, we might consider +
, -
, and maybe /
?
I have added arithmetic operations to add and subtract from messydates including ranges, negative dates, uncertain dates and sets of dates. @jhollway could you please take a look at the operate script in messydates and let me know if this is what you expected? Thank you.
Thanks @henriquesposito, looks good. What I had in mind was to use the add/subtract operators, similar to in lubridate. Should be just a matter of setting some additional methods, and maybe reexporting the year()
, month()
, day()
functions from {lubridate}
?
@jhollway Thank you for the feedback! I will try and adapt the code to use operators but still work with ranges, sets of dates, negative dates, and uncertain dates.
As "messydt" is a character based class, binary operations with operators it become more complicated as we are dealing with both numeric (Date) class and messydt (character).
If we resolve the messydates before adding or subtracting a date or numeric values, there would be no issue at all and we could incorporate operators easily (we would not even need to set methods for these operations). However, this might defeat the purpose of adding operators as calculations for ranges and sets of dates would be impossible...
I am trying to, though, set methods for these operators that override base and allow for these operations. This will just take a bit more time than planned, but I think we can get there.
Why not make the method first resolve/expand, then operate on the dates, and then convert/contract back into messydates?
I have started to look into this issue, but I have a few questions.
@jhollway and @jaeltan what do you think? Thank you!