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
39 lines (38 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.decode = decode;
exports.hexToRGB = hexToRGB;
exports.normalize = normalize;
require("core-js/modules/es.regexp.to-string.js");
require("core-js/modules/es.parse-int.js");
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.string.replace.js");
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 ? "".concat(parseInt(result[1], 16), ", ").concat(parseInt(result[2], 16), ", ").concat(parseInt(result[3], 16)) : null;
}