Google's server-side java library requires that all DateValue objects
added to a table be expressed in GMT. However, the rendered JSON sent
to the client contains no timezone information, and the client-side
response.getDataTable() call constructs new javascript Date objects
using the local timezone.
A simple fix would be to have the JSON renderer generate a Date
constructor that uses milliseconds past epoch instead of
year,month,day,hour,minute,second. Not only would doing so resolve
timezone discrepancies, but it would also significantly reduce the
amount of text marshaled and de-marshaled.
For example, in
com.google.visualization.datasource.render.JsonRenderer.appendCellJson(),
use
case DATETIME:
calendar = ((DateTimeValue) value).getCalendar();
valueJson.append("new Date(");
valueJson.append(calendar.getTimeInMillis());
valueJson.append(")");
break;
instead of
case DATETIME:
calendar = ((DateTimeValue) value).getCalendar();
valueJson.append("new Date(");
valueJson.append(calendar.get(GregorianCalendar.YEAR)).append(",");
valueJson.append(calendar.get(GregorianCalendar.MONTH)).append(",");
valueJson.append(calendar.get(GregorianCalendar.DAY_OF_MONTH));
valueJson.append(",");
valueJson.append(calendar.get(GregorianCalendar.HOUR_OF_DAY));
valueJson.append(",");
valueJson.append(calendar.get(GregorianCalendar.MINUTE)).append(",");
valueJson.append(calendar.get(GregorianCalendar.SECOND));
valueJson.append(")");
break;
Chris
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.