tags:

views:

56

answers:

1

Can anyone advise on how to convert a timespan or int to an ISO8601 duration string?

1hour and 30 minutes would result to PT1H30M

e.g. int duration = 90; string isoString = duration.ToIsoDuration();

http://en.wikipedia.org/wiki/ISO_8601#Durations

+3  A: 

found the solution myself, so I thought I'd share:

   TimeSpan timeSpan = new TimeSpan(0, value, 0);
   return XmlConvert.ToString(timeSpan);
garpunkal