[SERVER-6456] Timezone support in server side javascript Created: 16/Jul/12  Updated: 17/Jul/12  Resolved: 17/Jul/12

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Leo Bergolth Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: date, timezone
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

According to the docs, dates should be stored as UTC in mongodb. (At least pymongo suggests that and implicitly converts timezone aware datetimes to UTC.)

However, in order to be able to group by days in a local timezone, some way to convert the Date() to a specific timezone in serverside javascript should be provided.

E.g. a grouping function like...
-------------------- 8< --------------------
function(d) {
return

{ 'date': new Date( d.uploadDate.getFullYear(), d.uploadDate.getMonth(), d.uploadDate.getDate()) }

;
};
-------------------- 8< --------------------
... won't work, if the timestamps are saved in UTC but grouping should be done by local days.



 Comments   
Comment by Scott Hernandez (Inactive) [ 16/Jul/12 ]

I don't know of any way to do this in javascript other than to apply the conversion yourself. Here is the help for the javascript Date object: http://www.w3schools.com/jsref/jsref_obj_date.asp

I'm sure there is a sample/library out there which does the conversion for you, but I don't know of the top of my head.

Generated at Thu Feb 08 03:11:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.