From f46956d22698cdc9c3cfa9cb7b508d3bdef043c5 Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Thu, 5 Mar 2015 08:34:53 +0100 Subject: [PATCH] Fix date sent to json_server (closes #345) --- examples/blog/config.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/blog/config.js b/examples/blog/config.js index 232e3114..51f0fa69 100644 --- a/examples/blog/config.js +++ b/examples/blog/config.js @@ -162,7 +162,15 @@ nga.field('created_at', 'date') .label('Posted') .attributes({'placeholder': 'Filter by date'}) - .format('yyyy-MM-dd'), + .format('yyyy-MM-dd') + .parse(function(date) { + // the backend is dumb and doesn't interpret date objects + // so we convert the date to a string without timezone + var dateObject = date instanceof Date ? date : new Date(date); + dateObject.setMinutes(dateObject.getMinutes() - dateObject.getTimezoneOffset()); + var dateString = dateObject.toJSON(); + return dateString ? dateString.substr(0,10) : null; + }), nga.field('today', 'boolean').map(function() { var now = new Date(), year = now.getFullYear(),