Last active
August 29, 2015 14:19
-
-
Save egorvinogradov/c2bf1370853a386780fe to your computer and use it in GitHub Desktop.
Handle classes for https://github.com/egorvinogradov/registration-system
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
var daysMapping = { | |
'M': 'Mon', | |
'T': 'Tue', | |
'W': 'Wed', | |
'Th': 'Thu', | |
'F': 'Fri', | |
'Sat': 'Sat', | |
'Sun': 'Sun', | |
}; | |
classes = LU.classes.map(function(item){ | |
var days = item.days | |
.split(/\s+&\s+/) | |
.map(function(day){ | |
return daysMapping[day]; | |
}); | |
item.days = days; | |
return item; | |
}); | |
//// | |
classesTime = LU.classes.map(function(item){ | |
item.time = item.time.split(' – ').map(handleTime).join(' – '); | |
return item; | |
}); | |
function handleTime(str){ | |
var num = str.split(':'); | |
var dig = +num[0]; | |
if (dig < 10) { | |
dig = '0' + dig | |
} | |
return dig + ':' + num[1]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment