diff --git a/docs/configuration.md b/docs/configuration.md
index 6f9d602..20156d7 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -1494,15 +1494,25 @@ Example:
```yaml
- type: calendar
+ start-sunday: false
```
Preview:

+#### Properties
+
+| Name | Type | Required | Default |
+| ---- | ---- | -------- | ------- |
+| start-sunday | boolean | no | false |
+
+##### `start-sunday`
+Whether calendar weeks start on Sunday or Monday.
+
> [!NOTE]
>
-> There is currently no customizability available for the calendar. Extra features will be added in the future.
+> There is currently little customizability available for the calendar. Extra features will be added in the future.
### Markets
Display a list of markets, their current value, change for the day and a small 21d chart. Data is taken from Yahoo Finance.
diff --git a/internal/assets/templates/calendar.html b/internal/assets/templates/calendar.html
index af15e5a..020d6ac 100644
--- a/internal/assets/templates/calendar.html
+++ b/internal/assets/templates/calendar.html
@@ -11,13 +11,18 @@
+ {{ if .StartSunday }}
+
Su
+ {{ end }}
Mo
Tu
We
Th
Fr
Sa
-
Su
+ {{ if not .StartSunday }}
+
Su
+ {{ end }}
diff --git a/internal/feed/calendar.go b/internal/feed/calendar.go
index f7ec5d4..a4beae3 100644
--- a/internal/feed/calendar.go
+++ b/internal/feed/calendar.go
@@ -3,9 +3,8 @@ package feed
import "time"
// TODO: very inflexible, refactor to allow more customizability
-// TODO: allow changing first day of week
// TODO: allow changing between showing the previous and next week and the entire month
-func NewCalendar(now time.Time) *Calendar {
+func NewCalendar(now time.Time, startSunday bool) *Calendar {
year, week := now.ISOWeek()
weekday := now.Weekday()
@@ -23,7 +22,11 @@ func NewCalendar(now time.Time) *Calendar {
previousMonthDays = daysInMonth(previousMonthNumber, year)
}
- startDaysFrom := now.Day() - int(weekday+6)
+ var offset time.Weekday = 6
+ if startSunday {
+ offset = 7
+ }
+ startDaysFrom := now.Day() - int(weekday+offset)
days := make([]int, 21)
diff --git a/internal/widget/calendar.go b/internal/widget/calendar.go
index a126353..5bfbf37 100644
--- a/internal/widget/calendar.go
+++ b/internal/widget/calendar.go
@@ -10,8 +10,9 @@ import (
)
type Calendar struct {
- widgetBase `yaml:",inline"`
- Calendar *feed.Calendar
+ widgetBase `yaml:",inline"`
+ Calendar *feed.Calendar
+ StartSunday bool `yaml:"start-sunday"`
}
func (widget *Calendar) Initialize() error {
@@ -21,7 +22,7 @@ func (widget *Calendar) Initialize() error {
}
func (widget *Calendar) Update(ctx context.Context) {
- widget.Calendar = feed.NewCalendar(time.Now())
+ widget.Calendar = feed.NewCalendar(time.Now(), widget.StartSunday)
widget.withError(nil).scheduleNextUpdate()
}