Roundtripping SoapDuration and TimeSpan

Clemens Vasters writes about XSD duration and its relationship with the .NET Timespan Type.

Another quirk I have found with usage of these types is the fact that the conversion to the SoapDuration Type was not what I originally expected. It turns out that a Timespan that features a period of "about a year" highlights the issue.

In fact, the conversion to SoapDuration assumes a year to contain 360 days (a month is considered to be 30 days). Therefore, a Timespan of 365 days yields a SoapDuration of "P1Y0M5D", suggesting 365 days = 1 year and 5 days.

The algorithm is based on the standard ISO 8601.

1 Comment

Comments have been disabled for this content.