| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
- function getMeetingDateText(startDate) {
- let nextMeeting = new Date(startDate);
- if(nextMeeting.getMonth() == 0) {
- // No meeting in January
- nextMeeting.setDate(1);
- nextMeeting.setMonth(nextMeeting.getMonth() + 1);
- return getMeetingDateText(nextMeeting);
- }
-
- const currentWeekday = nextMeeting.getDay();
- if(currentWeekday != 2) {
- nextMeeting.setDate(nextMeeting.getDate() + (currentWeekday > 2 ? 9 - currentWeekday : 2 - currentWeekday));
- }
- if(nextMeeting.getDate() <= 7) {
- nextMeeting.setDate(nextMeeting.getDate() + 7);
- }
- if(nextMeeting.getDate() > 14) {
- // We have passed the meeting for this month
- nextMeeting.setDate(1);
- nextMeeting.setMonth(nextMeeting.getMonth() + 1);
- return getMeetingDateText(nextMeeting);
- }
-
- return nextMeeting.toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
- }
- function setNextMeetingText() {
- const text = getMeetingDateText(new Date());
- document.getElementById("nextMeeting").innerHTML = text;
- }
- window.addEventListener("load", () => {
- setNextMeetingText();
- });
-
- // @license-end
|