i made this with javascript
the javascript is horrid
the for loop, but not the actual loop, just the for part Show more
for ( let dayInMonth = 1 - (new Date (year, month - 1, 1).getDay() + 6) % 7, dayInWeek = 1, week = calendarBody.insertRow(), seasonIndex = +Object.entries(Array.from(seasons.values())).filter(( [ _, $ ] ) => month > $.startMonth || dayInMonth >= $.startDay).pop()[0], nextSeason = Array.from(seasons.values())[(seasonIndex + 1) % seasons.size] ; daysInThisMonth >= dayInMonth || dayInWeek % 7 != 1 ; dayInMonth++, dayInWeek = (dayInWeek + 1) % 7, week = dayInWeek == 1 ? calendarBody.insertRow() : week, !(nextSeason.startMonth > month || nextSeason.startDay > dayInMonth) ? ( seasonIndex = (seasonIndex + 1) % seasons.size, nextSeason = Array.from(seasons.values())[(seasonIndex + 1) % seasons.size] ) : void null )
re: the for loop, but not the actual loop, just the for part Show more
@Lady that sure is a way to write a loop
@aescling one might even say it is very loop-y
A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.
the for loop, but not the actual loop, just the for part
for (
let
dayInMonth = 1 - (new Date (year, month - 1, 1).getDay() + 6) % 7,
dayInWeek = 1,
week = calendarBody.insertRow(),
seasonIndex = +Object.entries(Array.from(seasons.values())).filter(( [ _, $ ] ) => month > $.startMonth || dayInMonth >= $.startDay).pop()[0],
nextSeason = Array.from(seasons.values())[(seasonIndex + 1) % seasons.size]
; daysInThisMonth >= dayInMonth || dayInWeek % 7 != 1
;
dayInMonth++,
dayInWeek = (dayInWeek + 1) % 7,
week = dayInWeek == 1 ? calendarBody.insertRow() : week,
!(nextSeason.startMonth > month || nextSeason.startDay > dayInMonth) ? (
seasonIndex = (seasonIndex + 1) % seasons.size,
nextSeason = Array.from(seasons.values())[(seasonIndex + 1) % seasons.size]
) : void null )