Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't replicate bad date format for tests #750

Merged
merged 1 commit into from
Jul 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions testing/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.get_cgm_record = function() {
var dateobj = new Date();
var datemil = dateobj.getTime();
var datesec = datemil / 1000;
var datestr = getDateString(dateobj);
var datestr = dateobj.toISOString();

// We put the time in a range from -1 to +1 for every thiry minute period
var range = (datesec % 1800) / 900 - 1.0;
Expand All @@ -26,47 +26,4 @@ exports.get_cgm_record = function() {
'direction': dir,
'dateString': datestr
};
};

//TODO: use moment
function getDateString(d) {

// How I wish js had strftime. This would be one line of code!

var month = d.getMonth();
var day = d.getDay();
var year = d.getFullYear();

if (month < 10) { month = '0' + month; }
if (day < 10) { day = '0' + day; }

var hour = d.getHours();
var min = d.getMinutes();
var sec = d.getSeconds();

var ampm = 'PM';
if (hour < 12) {
ampm = 'AM';
}

if (hour === 0) {
hour = 12;
}
if (hour > 12) {
hour = hour - 12;
}

if (hour < 10) {
hour = '0' + hour;
}

if (min < 10) {
min = '0' + min;
}

if (sec < 10) {
sec = '0' + sec;
}

return month + '/' + day + '/' + year + ' ' + hour + ':' + min + ':' + sec + ' ' + ampm;
}
};