ISO 8601 declares duration format as P[n]Y[n]M[n]DT[n]H[n]M[n]S
. For example, P3Y0.5MT6M
means "3 years, half of the month and 3 minutes".
There are various ways to convert it to unixtime/chrono::duration/whatever, but all solutions I found uses average month and year duration in seconds, which is not correct according to the standard. Instead, it should depend on the date, for example 01 Feb + P1M
should be 01 Mar
(+28 days), while 01 Mar + P1M
should be 01 Apr
(+31 days).
Which way could I implement this? Do I have any better choise than manual implementation with all these leap-years and other nasty things handling?