]> gitweb.hhaalo.de Git - calender.git/commitdiff
change date with year and fix weekday
authorBastian Dehn <hhaalo@arcor.de>
Sat, 18 Dec 2021 11:04:23 +0000 (12:04 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 18 Dec 2021 11:04:23 +0000 (12:04 +0100)
cal.js
stripcalender.mjs

diff --git a/cal.js b/cal.js
index fdbdcea5b430a874198dfe2f971b9dafcb22fcde..906aaf5b939e5e1df71c3ae5981f6b6fe257ff29 100644 (file)
--- a/cal.js
+++ b/cal.js
@@ -4,7 +4,7 @@ function calender()
 {
        let cal = document.getElementById("cal");
        let table = document.createElement("table");
-       let calender = new StripCalender((new Date()).getYear());
+       let calender = new StripCalender(new Date());
 
        table.appendChild(calender.createMonthHeader(3, 1));
        table.appendChild(calender.createMonthDaysHeader());
index 0bd94daec2e59b4382aabacf6ec6cdd6908e8c6c..8b80ace001decc9027c966210f1e4722a902921a 100644 (file)
@@ -1,8 +1,8 @@
 export class StripCalender
 {
-       constructor(year)
+       constructor(date)
        {
-               this._date = new Date(year);
+               this._date = date;
        }
 
        createMonthHeader(cornerSpanRow = 0, cornerSpanCol = 0)
@@ -27,7 +27,8 @@ export class StripCalender
                        attr = document.createAttribute("colspan");
                        attr.value = this._date.getDate();
                        th.setAttributeNode(attr);
-                       th.innerText = monthnames[i - 1];
+                       th.innerText = monthnames[i - 1] + " "
+                               + this._date.getFullYear();
                        tr.appendChild(th);
                }
 
@@ -82,7 +83,8 @@ export class StripCalender
 
                for (let i = 1; i <= 12; i++) {
                        this._date.setMonth(i, 0);
-                       this.appendOneMonthWeekdayHeader(tr, this._date.getDate());
+                       this.appendOneMonthWeekdayHeader(tr,
+                               this._date.getDate());
                }
 
                return tr;
@@ -91,7 +93,7 @@ export class StripCalender
        appendOneMonthWeekdayHeader(tr, days)
        {
                let th = null;
-               const weekday = [ "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ]
+               const weekday = [ "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa" ]
 
                for (let i = 1; i <= days; i++) {
                        this._date.setDate(i);