Skip to content

Instantly share code, notes, and snippets.

@stagas
Created April 10, 2011 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stagas/912197 to your computer and use it in GitHub Desktop.
Save stagas/912197 to your computer and use it in GitHub Desktop.
overwrite JSON.parse to deserialize dates
;(function() {
var parse = JSON.parse
JSON.parse = function(s, f) {
var ISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/
return parse(s, f ? f : function(key, value) {
return typeof value === 'string'
? ISO.exec(value) && new Date(value) || value
: value
})
}
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment