10 years later #1

Merged
sthag merged 374 commits from development into main 2026-03-07 00:18:59 +01:00
Showing only changes of commit 10c71a3909 - Show all commits

View file

@ -40,7 +40,7 @@ tags:
this.addRing('minutes', .8, 6, this.options.h24 ? 24 : 12, `rgb(211, 10, 81)`);
this.addRing('dotweek', .7, 2, 7, `rgb(142, 31, 104)`);
this.addRing('dotmonth', .6, 12, this.getTime().daysMonth, `rgb(39, 63, 139)`);
this.addRing('dotyear', .5, 256, 365, `rgb(60, 87, 154)`);
this.addRing('dotyear', .5, 256, this.getTime().daysYear, `rgb(60, 87, 154)`);
this.addRing('week', .4, 10, this.getTime().weeksYear, `rgb(183, 224, 240)`);
this.addRing('month', .3, 10, 12, `rgb(107, 199, 217)`);
this.addRing('moon', .2, 4, 8, `rgb(82, 190, 209)`);
@ -49,6 +49,7 @@ tags:
window.addEventListener('resize', () => this.resize());
console.debug(this);
console.debug(this.getTime());
}
resize() {
@ -158,19 +159,39 @@ tags:
}
// TODO: Parameter für Wochenstart ergänzen
getNumericWeekday(date) {
getWeekday(date) {
const weekday = date.getDay(); // 0 (Sunday) to 6 (Saturday)
return (weekday === 0) ? 7 : weekday;
}
getNumericYearDay(date) {
getYearDay(date) {
const start = new Date(date.getFullYear(), 0, 0);
return Math.floor((date - start) / 86400000);
}
daysInMonth(month, year) {
isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
}
getDaysInYear(year) {
return this.isLeapYear(year) ? 366 : 365;
}
getYearInfo(date) {
const current = this.getYearDay(date);
const total = this.getDaysInYear(date.getFullYear());
const remaining = total - current;
return {
total: total,
current: current,
remaining: remaining
}
}
getDaysInMonth(month, year) {
return new Date(year, month, 0).getDate();
}
@ -179,9 +200,9 @@ tags:
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
const dayNum = d.getUTCDay() || 7;
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
const start = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
return Math.ceil((((d - start) / 86400000) + 1) / 7);
}
getISOWeeksInYear(year) {
@ -242,13 +263,14 @@ tags:
second: this.date.getSeconds(),
minute: this.date.getMinutes(),
hour: this.date.getHours(),
dayWeek: this.getNumericWeekday(this.date),
dayWeek: this.getWeekday(this.date),
dayMonth: this.date.getDate(),
dayYear: this.getNumericYearDay(this.date),
dayYear: this.getYearInfo(this.date).current,
daysYear: this.getYearInfo(this.date).total,
week: this.getISOWeekInfo(this.date).current,
weeksYear: this.getISOWeekInfo(this.date).weeksYear,
month: this.date.getMonth() + 1, // Get current month (0-11)
daysMonth: this.daysInMonth(this.date.getMonth() + 1, this.date.getFullYear()),
daysMonth: this.getDaysInMonth(this.date.getMonth() + 1, this.date.getFullYear()),
moon: this.getMoonPhase(this.date).phase
};
}