semantic-ui-calendar-react
Version:
date/time picker built from semantic-ui elements
85 lines (69 loc) • 1.57 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildTimeStringWithSuffix = buildTimeStringWithSuffix;
exports.isNextPageAvailable = isNextPageAvailable;
exports.isPrevPageAvailable = isPrevPageAvailable;
exports.getCurrentDate = getCurrentDate;
function buildTimeStringWithSuffix(hour
/*string*/
, minute
/*string*/
, timeFormat
/*string*/
) {
if (timeFormat === 'ampm') {
if (parseInt(hour) < 12) {
return "".concat(convertHourTo_12_Format(hour), ":").concat(minute, " am");
}
return "".concat(convertHourTo_12_Format(hour), ":").concat(minute, " pm");
}
if (timeFormat === 'AMPM') {
if (parseInt(hour) < 12) {
return "".concat(convertHourTo_12_Format(hour), ":").concat(minute, " AM");
}
return "".concat(convertHourTo_12_Format(hour), ":").concat(minute, " PM");
}
return "".concat(hour, ":").concat(minute);
}
function convertHourTo_12_Format(hour
/*string*/
) {
if (hour === '00' || hour === '12') {
return '12';
}
if (parseInt(hour) < 12) {
return hour;
}
var h = (parseInt(hour) - 12).toString();
if (h.length === 1) {
return '0' + h;
}
return h;
}
function isNextPageAvailable(date
/*Moment*/
, maxDate
/*Moment*/
) {
if (maxDate) {
return maxDate.isAfter(date, 'day');
}
return true;
}
function isPrevPageAvailable(date
/*Moment*/
, minDate
/*Moment*/
) {
if (minDate) {
return minDate.isBefore(date, 'day');
}
return true;
}
function getCurrentDate(date
/*Moment*/
) {
return date.format('MMMM DD, YYYY');
}
;