But you'll need to check for leap days (today!) If today is a leap day, then ten years from today ain't.ISO: %@eval[%_year + 10]-%_month-%_day
(or use your own style)
assuming you are not close enough to midnight of the last day of a month so the date might change between retrieving its various parts
So, 10 years from today is:
echo %@agedate[%@eval[%@makeage[%_date] + %@makeage[1/1/1611]]]
So 10 years from May 23, 1970 would be:I basically used @makeage to give a magic number that represents 10 years. Since @makeage[1/1/1601] returns 0, I figured 1/1/1611 would be 10 years.
Code:So, 10 years from today is: echo %@agedate[%@eval[%@makeage[%_date] + %@makeage[1/1/1611]]]
echo %@agedate[%@eval[%@makeage[1970-05-23] + %@makeage[1611-01-01]]]
I'm creating a digital certificate and I want the expiration date to be 10 years from today. I don't think a day plus or minus will matter much.So 10 years from May 23, 1970 would be:
10 years could be 3652 days, or 3653 days, or even (very rarely) 3651 days.Code:echo %@agedate[%@eval[%@makeage[1970-05-23] + %@makeage[1611-01-01]]]
Just like children born today - when will their birthdays be in non-leap-years? The problem is not the day count; it is specifying a leap day in a non-leap-year.I'm creating a digital certificate and I want the expiration date to be 10 years from today. I don't think a day plus or minus will matter much.
Using the @yearadd function from the FedUtils8 plugin, I get the following;What is the easiest way to compute a date that is 10 years from today?
echo %@yearadd[2012-02-29,10]
2/28/2022
When I first read that I did a double-take, and even after thinking about it it took me a while. I guess that 3651 probably isn't worth worrying about since it hasn't happened for over a hundred years and won't for another 80. Obviously for Scott's certificate expiry example then using 3652 days would seem a decent compromise but if you desire an 'accurate' result then the only way to be sure is to use the 'add ten to the year' method and cater for the special case of 29th Feb.10 years could be 3652 days, or 3653 days, or even (very rarely) 3651 days.