Created
April 18, 2012 00:24
-
-
Save kconragan/2410086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i = 0; i < results.length; i++) { | |
var row = results[i]; | |
// construct timestamp for raw results | |
// YYYY-MM-DD H:H ZZ | |
// Sample: 2012-04-13 00:10 +0000 | |
var t =row[0] + "-" + row[1] + "-" + row[2] + ' ' + row[3] + ":" + row[4] + ' +0000' | |
// TODO | |
// format date an respect timezone | |
// documentation says this method is slow | |
// http://momentjs.com/docs/#/parsing/string-format/ | |
// | |
// also, time appears to be getting rounded even though | |
// I'm forcing UTC time by appending +0000 to string | |
// see output of console.log below | |
var timestamp = moment(t, "YYYY-MM-DD HH ZZ"); | |
// this is faster, but ugly and some values are indexed at 0 | |
var foo = moment([ | |
row[0], // YYYY | |
row[1] - 1, // MM | |
row[2], // DD | |
row[3], // HH | |
row[4] // H | |
]) | |
console.log('original', t, 'format', timestamp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment