Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created July 23, 2014 23:32
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 jonathantneal/43153e0920973404b1cb to your computer and use it in GitHub Desktop.
Save jonathantneal/43153e0920973404b1cb to your computer and use it in GitHub Desktop.
$http.get('/events.json').then(parseDates);
function parseDates(response) {
response.data.forEach(function (object) {
Object.keys(object).forEach(function (key) {
var
value = object[key],
isDate = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\dZ$/.test(value);
if (isDate) {
object[key] = new Date(value);
}
});
});
// uh, return a promise
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment