Skip to content

Commit

Permalink
Merge pull request #347 from marmelab/example_date
Browse files Browse the repository at this point in the history
[RFR] Fix date sent to json_server in blog example
  • Loading branch information
jeromemacias committed Mar 5, 2015
2 parents 10608f3 + f46956d commit 50129b8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/blog/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 50129b8

Please sign in to comment.