Skip to content

Commit

Permalink
feat: ✨ fix start date except for during course
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunes5thmoon committed Sep 9, 2024
1 parent 3844eb5 commit ac42b1f
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions assets/js/calendar.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
document.addEventListener('DOMContentLoaded', function () {
var calendarEl = document.getElementById('calendar');
var startDate = new Date('2024-08-21');
var endDate = new Date('2024-09-05');
function getInitialView() {
if (window.innerWidth < 768) {
return 'list';
} else {
return 'timeGrid8Day';
}
};
function getInitalDate() {
var startDate = new Date('2024-08-24');
var currentDate = new Date();
console.log(currentDate);
if (currentDate > startDate) {
return currentDate;
} else {
return startDate;
}
};
function beforeStart() {
var startDate = new Date('2024-08-24');

function duringCourse() {
var currentDate = new Date();
if (currentDate > startDate) {
if ((currentDate < startDate) || (currentDate > endDate)) {
return false;
} else {
return true;
Expand All @@ -29,7 +21,7 @@ document.addEventListener('DOMContentLoaded', function () {
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'America/New_York',
initialView: getInitialView(),
initialDate: getInitalDate(), //this should work but is broken
initialDate: startDate, //this should work but is broken
contentHeight: 'auto',
slotMinTime: '08:00:00',
slotMaxTime: '23:00:00',
Expand Down Expand Up @@ -147,7 +139,7 @@ document.addEventListener('DOMContentLoaded', function () {
return { domNodes: arrayOfDomNodes }
}
});
if (!beforeStart()) {
if (duringCourse()) {
calendar.today();
}
calendar.render();
Expand Down

0 comments on commit ac42b1f

Please sign in to comment.