poconsole.factory('dateConversion', function(){
    var sqliteDate = function(dString){
    	/**
    		* Takes a date string in the form YYYYMMDD_HHmmSS and returns it in SQLite format (YYYY-MM-DD HH:mm:SS)
    		* @param {String} dString
    		* @return {String} sqliteString
    	*/
    	var re = /(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})/;
    	var fd = re.exec(dString);
    	if (fd){
    		var sqliteString = "";
    		return sqliteString.concat(fd[1], "-", fd[2], "-", fd[3], " ", fd[4], ":", fd[5], ":", fd[6]);
    	} else {
    		return null;
    	}
    };

    var mysqlDate = function(d){
        var year = d.getFullYear().pad(4);
    	var month = (d.getMonth() + 1).pad(2);
    	var day = d.getDate().pad(2);
    	var hour = d.getHours().pad(2);
    	var min = d.getMinutes().pad(2);
    	var sec = d.getSeconds().pad(2);
        return "".concat(year, "-", month, "-", day, " ", hour, ":", min, ":", sec);
    };
    return {
        mysqlDate: mysqlDate,
        sqliteDate: sqliteDate
    };
});
