couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Leeds <randall.le...@gmail.com>
Subject Re: json date representations
Date Wed, 06 Jul 2011 19:44:27 GMT
On Wed, Jul 6, 2011 at 12:08, Mark J. Reed <markjreed@gmail.com> wrote:
> On Wed, Jul 6, 2011 at 2:12 PM, Mark Hahn <mark@boutiquing.com> wrote:
>
>> Who decided months should be zero-based but not days?
>>
>
> Not sure who the author was, but the motivation is that the month (and
> weekday) number is expected to be used to index into an array of names, and
> arrays are 0-based.  The day of the month is not an index into a list, so it
> survives unmolested.

Not true in a lot of languages (notably here: Erlang).

>
> We're also ignoring the fact that the year is internally stored less 1900;
> the get[UTC]FullYear()  method hides that, and the constructor uses a
> heuristic to decide whether or not to add 1900 to its first argument.
>
>
>
>> On Wed, Jul 6, 2011 at 8:15 AM, Mark J. Reed <markjreed@gmail.com> wrote:
>> > It's all about the use case, right?   In a couchdb app, your map
>> functions
>> > can convert readily among formats, but it probably makes sense to use the
>> > form that requires the least work from your most commonly-used views.
>> >
>> > When using JSON as a serialization format, something that constructs an
>> > actual JavaScript Date object would often be preferable to something that
>> > requires extra code to process the objects later.  But something like
>> "new
>> > Date(1310000000000)" loses the benefit of JSON being human-readable.  The
>> > multiple-argument constructor forms, as in "new
>> > Date(Date.UTC(2011,6,7,0,53,20))", would be a nice compromise were it not
>> > for the use of 0-based month numbers (that's July, not June).
>> >
>> > On Wed, Jul 6, 2011 at 10:53 AM, Juan Jose Comellas <juanjo@comellas.org
>> >wrote:
>> >
>> >> We use CouchDB for a telephony application where we sometimes need
>> >> subsecond
>> >> precision, so we store timestamps as floating point numbers, where the
>> >> integer part corresponds to the seconds and the decimal part to the
>> >> {milli,micro,nano}seconds since the Unix epoch (Jan 1, 1970). The nice
>> >> thing
>> >> about this format is that it can be used both for absolute (a date) and
>> >> relative (the offset at which an event occurred) timestamps and you can
>> >> easily perform arithmetic operations between them.
>> >>
>> >>
>> >> 2011/7/5 Rudi Benkovič <rudib@whiletrue.com>
>> >>
>> >> > Hi,
>> >> >
>> >> > I'm writing a little CouchDB administration utility and would like
to
>> >> > find out how most of you store data values in JSON. From .NET via
>> >> > Newtonsoft's JSON serializer, dates end up in the ISO 8601 as a
>> >> > string, like this:
>> >> >
>> >> > { Timestamp": "2011-05-12T20:52:02.3774261Z" }
>> >> >
>> >> > Let me know what other formats are used, as I'd like to cover as much
>> >> > of them as possible - hopefully the Javascript view code will be able
>> >> > to detect them automatically.
>> >> >
>> >> > Thanks!
>> >> >
>> >> > Rudi
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > Mark J. Reed <markjreed@gmail.com>
>> >
>>
>
>
>
> --
> Mark J. Reed <markjreed@gmail.com>
>

Mime
View raw message