<div class="container-fluid">
<input id="theInputDate">
<div>
현재 날짜는 <b><span id="theInputDateOutput"></span></b>입니다.
</div>
</div>
xxxxxxxxxx
.wj-calendar {
max-width: 21em;
}
.wj-calendar .wj-header {
color: white;
background: #43AA8B;
}
.wj-calendar .date-holiday:not(.wj-state-selected) {
font-weight: bold;
color: #008f22;
background: #f0fff0;
outline: 2pt solid #577590;
}
.wj-calendar .date-weekend:not(.wj-state-selected) {
background-color: #F8961E;
}
@font-face {
font-family: 'S-CoreDream-3Light';
src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-3Light.woff') format('woff');
font-weight: normal;
font-style: normal;
}
body {
margin: 20px;
font-family: 'S-CoreDream-3Light';
}
.container-fluid{
background-color:#ededed;
padding:10px;
border-radius:10px;
}
xxxxxxxxxx
document.readyState === 'complete' ? init() : window.onload = init;
//
function init() {
// InputDate
let theInputDate = new wijmo.input.InputDate('#theInputDate', {
valueChanged: () => showCurrentDate(theInputDate),
itemValidator: (date) => (date.getDay() % 6 != 0) && !getHoliday(date)
});
showCurrentDate(theInputDate);
//
// InputDate의 달력 항목 형식 지정(주말 및 공휴일에 스타일 적용):
theInputDate.calendar.formatItem.addHandler((sender, e) => {
let weekday = e.data.getDay(), holiday = getHoliday(e.data);
//
wijmo.toggleClass(e.item, 'date-weekend', weekday == 0 || weekday == 6);
wijmo.toggleClass(e.item, 'date-holiday', holiday != null);
e.item.title = holiday || '';
});
//
//현재 선택된 날짜 표시
function showCurrentDate(ctrl) {
let el = document.querySelector('#theInputDateOutput');
el.textContent = wijmo.Globalize.format(ctrl.value, 'D');
}
}
let holidays = {
'1/1': 'New Year\'s Day',
'6/14': 'Flag Day',
'7/4': 'Independence Day',
'11/11': 'Veteran\'s Day',
'12/25': 'Christmas Day',
'1/3/1': 'Martin Luther King\'s Birthday',
'2/3/1': 'Washington\'s Birthday',
'5/3/6': 'Armed Forces Day',
'9/1/1': 'Labor Day',
'10/2/1': 'Columbus Day',
'11/4/4': 'Thanksgiving Day' // 11월 넷째 주 목요일
};
//
// 주어진 날짜에 대한 휴일 가져오기
function getHoliday(date) {
let day = date.getDate(), month = date.getMonth() + 1, holiday = holidays[month + '/' + day];
//
if (!holiday) {
let weekDay = date.getDay(), weekNum = Math.floor((day - 1) / 7) + 1;
//
holiday = holidays[month + '/' + weekNum + '/' + weekDay];
}
//
return holiday;
}