I have a problem with a persisted AdvancedCriteria w/r Date fields and different browser timezones when using DATE_CONSTRUCTOR encoding of the criteria.
I was using the XML_SCHEMA form of encoding the AdvancedCriteria and since I have specific format/parsing (which handles round-tripping the dates) there was no problem with different browser TimeZones since dates were stored as "yyyy-MM-dd" (except BETWEEN operator see this forum post http://forums.smartclient.com/showthread.php?t=30392)
So now Date field criteria is stored as like this:
This Date equates to 2014-06-01 and since I created the AdvancedCriteria in Eastern TimeZone the exact date it equates to is 2014-06-01 00:00:00 -0400 in TimeZone US/Eastern
The problem comes when the browser is in Pacific Time and loads that filter up in the UI. Since the encoding has the Date object, and since that Date value in Pacific time is 2014-05-31 21:00:00 -0700 in TimeZone US/Pacific it now shows 2014-05-31 even though this is a Date field and not a DateTime field.
If I use that same Date field in a record set to June 1st, then the framework handles the transition of the Date object being sent from the server to the client so that no matter what TimeZone the browser is in, it always the same date.
For example the same record that has the server-side database date value saved as 2014-06-01 when retrieved in the Eastern TZ browser receives the value in the DS response as tdate:new Date(1401638400000) and when that same record is retrieved in the Pacific TZ browser, it gets tdate:new Date(1401649200000) which each of those date values equate to 1401638400000 = 2014-06-01 12:00:00 -0400 in TimeZone US/Eastern and
1401649200000 = 2014-06-01 12:00:00 -0700 in TimeZone US/Pacific respectively so all that works very nice.
Is there anything I need to do to make the AdvancedCriteria persistence behave the same way?
The field is defined as type Date (not DateTime
Attached is screen capture of the same filter loaded up in Eastern TZ and in Pacific TZ systems.
I was using the XML_SCHEMA form of encoding the AdvancedCriteria and since I have specific format/parsing (which handles round-tripping the dates) there was no problem with different browser TimeZones since dates were stored as "yyyy-MM-dd" (except BETWEEN operator see this forum post http://forums.smartclient.com/showthread.php?t=30392)
So now Date field criteria is stored as like this:
Code:
{ "fieldName":"tdate", "operator":"equals", "value":new Date(1401595200000) }
The problem comes when the browser is in Pacific Time and loads that filter up in the UI. Since the encoding has the Date object, and since that Date value in Pacific time is 2014-05-31 21:00:00 -0700 in TimeZone US/Pacific it now shows 2014-05-31 even though this is a Date field and not a DateTime field.
If I use that same Date field in a record set to June 1st, then the framework handles the transition of the Date object being sent from the server to the client so that no matter what TimeZone the browser is in, it always the same date.
For example the same record that has the server-side database date value saved as 2014-06-01 when retrieved in the Eastern TZ browser receives the value in the DS response as tdate:new Date(1401638400000) and when that same record is retrieved in the Pacific TZ browser, it gets tdate:new Date(1401649200000) which each of those date values equate to 1401638400000 = 2014-06-01 12:00:00 -0400 in TimeZone US/Eastern and
1401649200000 = 2014-06-01 12:00:00 -0700 in TimeZone US/Pacific respectively so all that works very nice.
Is there anything I need to do to make the AdvancedCriteria persistence behave the same way?
The field is defined as type Date (not DateTime
Code:
<field name="tdate" type="date" required="true"/>
Comment