Skip to content

Instantly share code, notes, and snippets.

@trengrj
Created April 5, 2015 04:34
Show Gist options
  • Save trengrj/af8ebdee3e759cf5818b to your computer and use it in GitHub Desktop.
Save trengrj/af8ebdee3e759cf5818b to your computer and use it in GitHub Desktop.
var moment = require('moment');
var data = require('./one-week.json');
var t = {};
data.forEach(function(d) {
var segments = d.segments;
segments.forEach(function(s) {
var activities = s.activities;
activities.forEach(function(a) {
if (a.activity == "wlk") {
var timeStamp = moment.utc(a.startTime.replace(/[0-9]{4}Z/,''),"YYYYMMDDTHH").unix().toString();
if (a.steps) {
t[timeStamp] = (t[timeStamp]) ? t[timeStamp] + a.steps : a.steps;
}
}
});
});
});
console.log(JSON.stringify(t));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment