Skip to content

automatic date parsing ... is this really good? #11

Closed
@kaiko

Description

@kaiko

At some point it can be good to convert timestamp values to natural Date javascript objects, but currently it will bring problems more than joy.
Easier is to bring example than describe it:

q = workerDB.query('select '
  + ' current_timestamp AS d1,'
  + ' current_timestamp::timestamp(0) AS d2,'
  + ' current_timestamp :: text AS t');
q.on('row', function (r) {
   util.puts(JSON.stringify(r, null, 3));
   util.puts(r.d1.valueOf());
   util.puts(r.d2.valueOf());
   util.puts(r.d1.toString());
   util.puts(r.d2.toString());
 });

Will output:
{
"d1": "2011-01-21T22:59:45.424Z",
"d2": "2011-01-22T00:59:45.000Z",
"t": "2011-01-22 00:59:45.424245+02"
}
1295650785424
1295657985000
Sat Jan 22 2011 00:59:45 GMT+0200 (EET)
Sat Jan 22 2011 02:59:45 GMT+0200 (EET)
2011-01-22 00:59:45.424245+02

As you can see -- time can change depending in what timezone you are.
Don't get me wrong -- I really like this feature but I put system in live without checking enough and ... boom :)
I think using Date object should be configurable and default should be off (and should be very clearly documentated).
Or turned on ONLY with timestamps with timezones but then it is confusing for user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions