12 months (of differing lengths)
52 (and a bit) weeks
Most of these numbers need to be adjusted in leap years.
A k’th anniversary of a date is usually defined as the same date (month and day) k years later, thus the 10th anniversary of 17th May 1983 is 17th May 1993. However we can also define other types of `versaries’ – the 1 week-versary of 28th February 1984 is 6th March 1984.
If we define a convention of naming dates (and times if necessary) by specifying successively smaller periods separated by colons (that is as yyyy:mm:dd:hh:mm:ss) we can label the units using the same convention, that is y for years, d for days, w for weeks, h for hours, m for minutes and s for seconds (we cannot use months, they are too variable). We can then summarise the above examples as:
1983:5:17 + 10y -> 1993:5:17
1984:2:28 + 1w -> 1984:3:6
Note that the specification of an event has to be as least as precise (that is employ units at least as small) as the specification of the desired versary.
Write a program that will read in details of events and desired versaries and calculate the required date (and time if necessary). Bear in mind that a year is a leap year if it is divisible by 4 unless it is divisible by 100 as well, in which case it is only a leap year if it is divisible by 400; thus 1984 and 2000 are leap years, but 1900 is not.
1983:5:17 10 y 1984:2:28 1 w 1993:7:25:13:23 5 h 0
1983:5:17 + 10y -> 1993:5:17 1984:2:28 + 1w -> 1984:3:6 1993:7:25:13:23 + 5h -> 1993:7:25:18:23