use regex for date part parse

This commit is contained in:
brianc 2010-11-02 00:46:29 -05:00
parent 6841178ca2
commit 2c362250b3

View File

@ -225,12 +225,16 @@ var dateParser = function(isoDate) {
//TODO find some regexp help
//this method works but it's ooglay
var split = isoDate.split(' ');
var dateMatcher = /(\d{4})-(\d{2})-(\d{2})/;
var date = split[0];
var time = split[1];
var match = dateMatcher.exec(date);
var splitDate = date.split('-');
var year = (splitDate[0]);
var month = parseInt(splitDate[1])-1;
var day = (splitDate[2]);
var year = match[1];
var month = parseInt(match[2])-1;
var day = match[3];
var splitTime = time.split(':');
var hour = parseInt(splitTime[0]);
var min = splitTime[1];