- View SourceHello,
As there is no JSON standard for serializing the .net TimeSpan type, are there any suggestions?
We could do the following:
1. TimeSpan -> long value representing the ticks
2. TimeSpan -> string value like "ddd.HH:mm:ss.nnn"
- View SourceYou might want to take a look at ISO 8061: http://en.m.wikipedia.org/wiki/ISO_8601. I don't know about .Net, but many languages have straightforward ways of converting to and from compliant strings.
On 9 Jun 2011, at 07:12, "mehdigholam@..." <mgholam@...> wrote:
> As there is no JSON standard for serializing the .net TimeSpan type, are there any suggestions?
> We could do the following:
> 1. TimeSpan -> long value representing the ticks
> 2. TimeSpan -> string value like "ddd.HH:mm:ss.nnn"
[Non-text portions of this message have been removed]
- View Sourcemehdigholam@... scripsit:
> 2. TimeSpan -> string value like "ddd.HH:mm:ss.nnn"The ISO 8601 standard represents a duration in days, hours, minutes,
and seconds thus: "PnnnDTnnHnnMnn.nnnS". "P" indicates a duration and
is mandatory. The nnnD, nnH, nnM, and nn.nnnS parts can be omitted if
they are zero, and you do not need to zero-pad the numeric values. "T"
separates the date part from the time part, and is mandatory unless all
time values are omitted.
So P1D is one day, PT15H2S is fifteen hours and two seconds,
P1DT2H5M6.55S is one day, two hours, six minutes, and 6.550 seconds.
ISO 8601 has lots more bells and whistles, but this suffices for TimeSpan.
What asininity could I have uttered John Cowan <cowan@...>
that they applaud me thus? http://www.ccil.org/~cowan
--Phocion, Greek orator