react-material-time-picker
Version:
TimePicker is a user interface component that allows the user to easily select a specific time. It provides an analog clock interface that is easy to use and intuitive. TimePicker can be easily integrated into other user interface components, making it a
26 lines (25 loc) • 758 B
JavaScript
function decode(time){
if(time === -1 || time === 0 ) return {hour: '00', minute: '00'};
let t = time.toString();
return {
hour: t.slice(0,2),
minute: t.slice(2)
}
}
function normalize( time ) {
time = parseInt(time)
if(time < 10) {
return '0'+time;
}else{
return time;
}
}
function hexToRGB(hex){
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? `${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}` : null;
}
export {decode,normalize,hexToRGB}