exact-scheduler 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,174 @@
1
+ // exact-scheduler: a month of days, with marked dates, chosen days, a range,
2
+ // and a year of months behind its title.
3
+ //
4
+ // The keyboard: one day is a Tab stop. The arrows move by a day or a week
5
+ // (Left and Right swapped right to left), Home and End to the week's ends,
6
+ // Page Up and Page Down by a month; Enter or Space presses the day. The app
7
+ // turns the page when `turnTo` asks.
8
+
9
+ use SchedulerNames, SchedulerStrings, SchedulerRules, SchedulerMark, SchedulerRange, SchedulerViewport from "./shapes.contract"
10
+ use monthDays, monthOf, yearOf, monthIndexOf, dateOf, addMonths, addDays, dayAllowed, monthAllowed, canTurn, clampDay, withinLimits, moveDay, inRange from "./days.contract"
11
+ use monthTitle, dayWords, localDigits, weekOf, weekWords, markOf, tintOf, named from "./text.contract"
12
+ use SchedulerBar, SchedulerWeekdays, pageMotion, swipeWay, schedulerForward, schedulerBackward, schedulerFade from "./parts.contract"
13
+
14
+ // The day Tab reaches in a month: the one the keyboard is on, else a chosen
15
+ // one, else today, else the month's first that the limits allow.
16
+ fn tabDay(month: string, active: string, selected: string[], range: SchedulerRange, today: string, rules: SchedulerRules): string = match first([active, range.start].concat(selected).concat([today]).filter(d => monthOf(d) == monthOf(month))) { case some(d) => d, case none => clampDay(rules, `${monthOf(month)}-01`) }
17
+ fn monthKey(year: number, m: number): string = `${year}-${m < 9 ? "0" : ""}${m + 1}`
18
+ fn isPicked(selected: string[], range: SchedulerRange, day: string): bool = selected.includes(day) or (day == range.start and range.start != "") or (day == range.end and range.end != "")
19
+
20
+ component MonthCalendar
21
+ props
22
+ id: string
23
+ month: string
24
+ today: string
25
+ selected: string[]
26
+ range: SchedulerRange
27
+ marks: SchedulerMark[]
28
+ rules: SchedulerRules
29
+ names: SchedulerNames
30
+ strings: SchedulerStrings
31
+ label: string
32
+ weekNumbers: bool
33
+ outsideDays: bool
34
+ rtl: bool
35
+ pick: action
36
+ turnTo: action
37
+ resource screen = exactViewport() as shape SchedulerViewport
38
+ state active = ""
39
+ state wanted = ""
40
+ state step = 0
41
+ state choosing = false
42
+ state fromX = 0
43
+ state fromY = 0
44
+ state swiped = false
45
+ state year = 0
46
+ derive still = screen.prefersReducedMotion
47
+ derive days = monthDays(month, names.firstDay)
48
+ derive stop = tabDay(month, active, selected, range, today, rules)
49
+
50
+ action turn(n: number)
51
+ let next = addMonths(`${monthOf(month)}-01`, n)
52
+ if canTurn(rules, monthOf(next), n)
53
+ step = n
54
+ active = ""
55
+ turnTo(next)
56
+ // A sideways drag turns the page, from a finger on a button too (a
57
+ // `swipeleft` leaves those to the button), so it is read from the pointer.
58
+ // The press that the same contact may end in is not one.
59
+ action down(e: PointerEvent)
60
+ fromX = e.clientX
61
+ fromY = e.clientY
62
+ swiped = false
63
+ action up(e: PointerEvent)
64
+ let way = swipeWay(e.clientX - fromX, e.clientY - fromY, rtl)
65
+ if way != 0
66
+ swiped = true
67
+ turn(way)
68
+ task settle when swiped
69
+ after(80, settled)
70
+ action settled
71
+ swiped = false
72
+ action press(day: string)
73
+ if not swiped and dayAllowed(rules, day)
74
+ active = day
75
+ if monthOf(day) != monthOf(month)
76
+ step = (day > month ? 1 : -1)
77
+ turnTo(`${monthOf(day)}-01`)
78
+ pick(day)
79
+ action gridKey(k: string)
80
+ let to = moveDay(k, stop, names.firstDay, rtl)
81
+ if to != ""
82
+ preventDefault()
83
+ let next = clampDay(rules, to)
84
+ active = next
85
+ wanted = next
86
+ if monthOf(next) != monthOf(month)
87
+ step = (next > month ? 1 : -1)
88
+ turnTo(`${monthOf(next)}-01`)
89
+ // The focus follows once the day is on the page.
90
+ task follow when wanted != "" key=`${wanted}/${monthOf(month)}`
91
+ after(1, land)
92
+ action land
93
+ if monthOf(wanted) == monthOf(month)
94
+ focus(`${id}-day-${wanted}`)
95
+ wanted = ""
96
+
97
+ action toggleYear
98
+ year = yearOf(month)
99
+ choosing = not choosing
100
+ action turnYear(n: number)
101
+ year = year + n
102
+ action chooseMonth(m: number)
103
+ let next = monthKey(year, m)
104
+ step = 0
105
+ active = ""
106
+ choosing = false
107
+ turnTo(`${next}-01`)
108
+
109
+ view
110
+ column gap=4 testId=id
111
+ // The months stand in the grid's place, as a date picker's do; they are
112
+ // not a screen.
113
+ // exact-accept lower-screen-by-state
114
+ if choosing
115
+ SchedulerBar(id=id, title=localDigits(names.digits, year), titleLabel=`${strings.chooseMonth}, ${localDigits(names.digits, year)}`, previousLabel=strings.previousYear, nextLabel=strings.nextYear, canPrevious=(rules.minDay == "" or year > yearOf(rules.minDay)), canNext=(rules.maxDay == "" or year < yearOf(rules.maxDay)), opens=true, expanded=true, previous=turnYear(-1), next=turnYear(1), open=toggleYear)
116
+ column gap=4 role="group" aria-label=strings.chooseMonth animation=(still ? "none" : "schedulerFade 160ms ease-out both") testId=`${id}-months`
117
+ for r in range(4) key=`${r}`
118
+ row gap=4
119
+ for c in range(3) key=`${c}`
120
+ button press=chooseMonth(r * 3 + c) disabled=(not monthAllowed(rules, monthKey(year, r * 3 + c))) aria-pressed=(monthKey(year, r * 3 + c) == monthOf(month)) aria-label=monthTitle(names, `${monthKey(year, r * 3 + c)}-01`) appearance="none" flex="1 1 0%" min-width=0 min-height=52 border-radius=12 display="flex" align-items="center" justify-content="center"
121
+ background-color=(monthKey(year, r * 3 + c) == monthOf(month) ? "AccentColor" : "-exact-tertiary-fill") opacity=(monthAllowed(rules, monthKey(year, r * 3 + c)) ? 1 : 0.35) testId=`${id}-month-${r * 3 + c + 1}`
122
+ text named(names.monthsShort, r * 3 + c) font="-exact-subheadline" text-align="center" color=(monthKey(year, r * 3 + c) == monthOf(month) ? "AccentColorText" : "-exact-label") aria-hidden=true
123
+ else
124
+ SchedulerBar(id=id, title=monthTitle(names, month), titleLabel=`${strings.chooseMonth}, ${monthTitle(names, month)}`, previousLabel=strings.previousMonth, nextLabel=strings.nextMonth, canPrevious=canTurn(rules, monthOf(addMonths(`${monthOf(month)}-01`, -1)), -1), canNext=canTurn(rules, monthOf(addMonths(`${monthOf(month)}-01`, 1)), 1), opens=true, expanded=false, previous=turn(-1), next=turn(1), open=toggleYear)
125
+ column role="grid" aria-label=`${label}, ${monthTitle(names, month)}` key=gridKey pointerdown=down pointerup=up touch-action="pan-y" testId=`${id}-grid`
126
+ SchedulerWeekdays(names=names, numbers=weekNumbers, short=(screen.width >= 640))
127
+ for page in [monthOf(month)] key=page
128
+ column animation=pageMotion(still, step, rtl)
129
+ for w in range(days.length / 7) key=`${w}`
130
+ row role="row" align-items="center" aria-label=weekWords(names, strings, days, w)
131
+ if weekNumbers
132
+ match days.at(w * 7)
133
+ case some(d)
134
+ view role="rowheader" aria-label=weekWords(names, strings, days, w) width=28
135
+ text localDigits(names.digits, weekOf(d)) font-size="min(-exact-caption2, 13px)" color="-exact-secondary-label" text-align="center" font-variant-numeric="tabular-nums" aria-hidden=true
136
+ case none
137
+ view width=28
138
+ for day in days.slice(w * 7, w * 7 + 7) key=day
139
+ if monthOf(day) == monthOf(month) or outsideDays
140
+ MonthDay(id=id, day=day, names=names, strings=strings, inside=(monthOf(day) == monthOf(month)), isToday=(day == today), isPicked=isPicked(selected, range, day), range=range, mark=markOf(marks, day), allowed=dayAllowed(rules, day), stop=(day == stop), still=still, press=press(day))
141
+ else
142
+ view role="gridcell" flex="1 1 0%" min-width=0 height=48
143
+
144
+
145
+ // A day: its number in a circle, the range's band behind it, its dots below.
146
+ component MonthDay
147
+ props
148
+ id: string
149
+ day: string
150
+ names: SchedulerNames
151
+ strings: SchedulerStrings
152
+ inside: bool
153
+ isToday: bool
154
+ isPicked: bool
155
+ range: SchedulerRange
156
+ mark: SchedulerMark
157
+ allowed: bool
158
+ stop: bool
159
+ still: bool
160
+ press: action
161
+ derive banded = inRange(range, day) and range.start != range.end
162
+ view
163
+ button id=`${id}-day-${day}` role="gridcell" press=press tabindex=(stop ? 0 : -1) aria-selected=(isPicked or inRange(range, day)) aria-disabled=(not allowed) aria-current=(isToday ? "date" : "false")
164
+ aria-label=dayWords(names, day, [(isToday ? strings.today : ""), (day == range.start and range.start != "" ? strings.rangeStart : ""), (day == range.end and range.end != "" ? strings.rangeEnd : ""), (allowed ? "" : strings.unavailable), mark.label])
165
+ appearance="none" background-color="transparent" position="relative" flex="1 1 0%" min-width=0 height=48 padding=0 border-radius=12 display="flex" flex-direction="column" align-items="center" testId=`${id}-day-${day}`
166
+ if banded
167
+ row position="absolute" top=2 left=0 right=0 height=36 pointer-events="none" aria-hidden=true
168
+ view flex=1 background-color=(day == range.start ? "transparent" : "-exact-secondary-fill")
169
+ view flex=1 background-color=(day == range.end ? "transparent" : "-exact-secondary-fill")
170
+ view position="relative" margin-top=2 width=36 height=36 border-radius=18 display="flex" align-items="center" justify-content="center" border-width=2 border-style="solid" box-sizing="border-box" border-color=(isToday and not isPicked ? "AccentColor" : "transparent") background-color=(isPicked ? "AccentColor" : "transparent") transition=(still ? "none" : "background-color 120ms ease-out") pointer-events="none" aria-hidden=true
171
+ text localDigits(names.digits, dateOf(day)) font-size="min(-exact-body, 20px)" font-weight=(isToday or isPicked ? 600 : 400) font-variant-numeric="tabular-nums" text-decoration-line=(allowed ? "none" : "line-through") color=(isPicked ? "AccentColorText" : (allowed and inside ? "-exact-label" : "-exact-secondary-label"))
172
+ row gap=3 height=6 margin-top=2 align-items="center" justify-content="center" pointer-events="none" aria-hidden=true
173
+ for tint, i in mark.tints.slice(0, 3) key=`${i}`
174
+ view width=5 height=5 border-radius=3 background-color=tintOf(tint)
@@ -0,0 +1,82 @@
1
+ // exact-scheduler: the pieces the views share: the title with its arrows,
2
+ // the weekday names, and an event's chip.
3
+
4
+ use SchedulerNames, SchedulerSegment from "./shapes.contract"
5
+ use tintOf, named, weekOrder from "./text.contract"
6
+
7
+ keyframes schedulerForward
8
+ from translate="16px 0px" opacity=0
9
+ keyframes schedulerBackward
10
+ from translate="-16px 0px" opacity=0
11
+ keyframes schedulerFade
12
+ from opacity=0
13
+
14
+ // How a page of days comes in: from the side it was asked from, in the
15
+ // screen's directions, or not at all under reduced motion.
16
+ fn pageMotion(still: bool, step: number, rtl: bool): string = (still or step == 0) ? "none" : (((step > 0) == (not rtl)) ? "schedulerForward 180ms ease-out both" : "schedulerBackward 180ms ease-out both")
17
+
18
+ // A title's direction and its side: its own direction, so a title cut short
19
+ // keeps its start; the view's start side, so a short one sits by the tint.
20
+ fn titleDirection(dir: string, rtl: bool): string = (dir == "rtl" or dir == "ltr") ? dir : (rtl ? "rtl" : "ltr")
21
+ fn titleSide(rtl: bool): string = rtl ? "right" : "left"
22
+
23
+ // The page a drag turns to: 1 the next, -1 the one before, 0 none. It is 64
24
+ // points or more, and twice as far sideways as down.
25
+ fn size(n: number): number = max(n, 0 - n)
26
+ fn swipeWay(dx: number, dy: number, rtl: bool): number = (size(dx) < 64 or size(dx) < 2 * size(dy)) ? 0 : (((dx < 0) == (not rtl)) ? 1 : -1)
27
+
28
+ // The title between its arrows. The title is a button when `open` does
29
+ // something (`opens`), with `expanded` its state.
30
+ component SchedulerBar
31
+ props
32
+ id: string
33
+ title: string
34
+ titleLabel: string
35
+ previousLabel: string
36
+ nextLabel: string
37
+ canPrevious: bool
38
+ canNext: bool
39
+ opens: bool
40
+ expanded: bool
41
+ previous: action
42
+ next: action
43
+ open: action
44
+ view
45
+ row align-items="center" gap=4 testId=`${id}-bar`
46
+ button press=previous disabled=(not canPrevious) aria-label=previousLabel appearance="none" background-color="transparent" min-width=44 min-height=44 display="flex" align-items="center" justify-content="center" border-radius=22 opacity=(canPrevious ? 1 : 0.35) testId=`${id}-previous`
47
+ // The next arrow turned round: `symbol:back` is an arrow with a shaft on Android.
48
+ image "symbol:forward-chevron" rotate=180 color="-exact-label" aria-hidden=true
49
+ if opens
50
+ button press=open aria-label=titleLabel aria-expanded=expanded appearance="none" background-color="transparent" flex=1 min-width=0 min-height=44 display="flex" align-items="center" justify-content="center" border-radius=22 testId=`${id}-title`
51
+ text title font="-exact-headline" color="-exact-label" text-align="center" overflow-wrap="anywhere" aria-hidden=true
52
+ else
53
+ text title role="heading" aria-level=2 font="-exact-headline" color="-exact-label" text-align="center" flex=1 min-width=0 overflow-wrap="anywhere" testId=`${id}-title`
54
+ button press=next disabled=(not canNext) aria-label=nextLabel appearance="none" background-color="transparent" min-width=44 min-height=44 display="flex" align-items="center" justify-content="center" border-radius=22 opacity=(canNext ? 1 : 0.35) testId=`${id}-next`
55
+ image "symbol:forward-chevron" color="-exact-label" aria-hidden=true
56
+
57
+ // The weekday names over a month's columns.
58
+ component SchedulerWeekdays
59
+ props
60
+ names: SchedulerNames
61
+ numbers: bool
62
+ short: bool
63
+ view
64
+ row role="row"
65
+ if numbers
66
+ view width=28 aria-hidden=true
67
+ for w in weekOrder(names.firstDay) key=`${w}`
68
+ view role="columnheader" aria-label=named(names.weekdays, w) flex="1 1 0%" min-width=0 padding="4px 0"
69
+ text (short ? named(names.weekdaysShort, w) : named(names.weekdaysNarrow, w)) font-size="min(-exact-caption1, 14px)" color="-exact-secondary-label" text-align="center" white-space="nowrap" overflow="hidden" aria-hidden=true
70
+
71
+ // An event as one line: its tint as a bar at the start and a wash behind.
72
+ component SchedulerChip
73
+ props
74
+ segment: SchedulerSegment
75
+ rtl: bool
76
+ press: action
77
+ testId: string
78
+ view
79
+ button press=press aria-label=[segment.title, segment.time, segment.detail].filter(s => s != "").join(", ") appearance="none" display="flex" flex-direction="row" align-items="stretch" position="relative" overflow="hidden" padding=0 min-height=24 min-width=0 width="100%" box-sizing="border-box" border-radius=5 background-color="transparent" testId=testId
80
+ view position="absolute" inset=0 background-color=tintOf(segment.tint) opacity=0.16 pointer-events="none" aria-hidden=true
81
+ view width=3 flex-shrink=0 background-color=tintOf(segment.tint) aria-hidden=true
82
+ text segment.title flex=1 min-width=0 padding="3px 4px" font-size="min(-exact-caption1, 14px)" line-height="18px" color="-exact-label" direction=titleDirection(segment.dir, rtl) text-align=titleSide(rtl) white-space="nowrap" overflow="hidden" text-overflow="ellipsis" aria-hidden=true
@@ -0,0 +1,53 @@
1
+ // exact-scheduler: a date picker and a date-range picker, a month calendar
2
+ // that turns its own pages. The app holds the value.
3
+
4
+ use SchedulerNames, SchedulerStrings, SchedulerRules, SchedulerMark, SchedulerRange from "./shapes.contract"
5
+ use nextRange, clampDay from "./days.contract"
6
+ use MonthCalendar from "./month.contract"
7
+
8
+ // With no value it opens at today, or the limit nearest to it.
9
+ fn opening(shown: string, value: string, today: string, rules: SchedulerRules): string = shown != "" ? shown : (value != "" ? value : clampDay(rules, today))
10
+
11
+ // One day. `change` hears the day pressed.
12
+ component DatePicker
13
+ props
14
+ id: string
15
+ value: string
16
+ today: string
17
+ marks: SchedulerMark[]
18
+ rules: SchedulerRules
19
+ names: SchedulerNames
20
+ strings: SchedulerStrings
21
+ label: string
22
+ rtl: bool
23
+ change: action
24
+ state shown = ""
25
+ action go(month: string)
26
+ shown = month
27
+ action choose(day: string)
28
+ change(day)
29
+ view
30
+ MonthCalendar(id=id, month=opening(shown, value, today, rules), today=today, selected=(value == "" ? [] : [value]), range=SchedulerRange(start="", end=""), marks=marks, rules=rules, names=names, strings=strings, label=label, weekNumbers=false, outsideDays=true, rtl=rtl, pick=choose, turnTo=go)
31
+
32
+ // A range of days. `change` hears a `SchedulerRange` at each press: first
33
+ // with no end, then with both.
34
+ component DateRangePicker
35
+ props
36
+ id: string
37
+ value: SchedulerRange
38
+ today: string
39
+ marks: SchedulerMark[]
40
+ rules: SchedulerRules
41
+ maxDays: number
42
+ names: SchedulerNames
43
+ strings: SchedulerStrings
44
+ label: string
45
+ rtl: bool
46
+ change: action
47
+ state shown = ""
48
+ action go(month: string)
49
+ shown = month
50
+ action choose(day: string)
51
+ change(nextRange(value, day, rules, maxDays))
52
+ view
53
+ MonthCalendar(id=id, month=opening(shown, value.start, today, rules), today=today, selected=[], range=value, marks=marks, rules=rules, names=names, strings=strings, label=label, weekNumbers=false, outsideDays=false, rtl=rtl, pick=choose, turnTo=go)
@@ -0,0 +1,98 @@
1
+ // exact-scheduler: the records the views read and send. A day is a key,
2
+ // "2026-11-24", in the app's own zone; a time of day is minutes since its
3
+ // midnight. Every word a person sees or hears is the app's
4
+ // (`SchedulerStrings`, `SchedulerNames`): the package has none of its own.
5
+
6
+ // One event on one day, as `exact-scheduler/data`'s `toSegments` answers it.
7
+ // `allDay` is drawn in the all-day row. `lane` of `lanes` is its share of
8
+ // the column beside the events it overlaps; `order` its place in the day.
9
+ // `before` and `after` say the event goes on from or into another day. `time` is
10
+ // its time as the person reads it. `tint` is a colour, "" the accent. `dir`
11
+ // is the title's own direction ("ltr", "rtl", or "" for the view's), so a
12
+ // title cut short keeps its start in a page written the other way.
13
+ shape SchedulerSegment
14
+ key: string
15
+ id: string
16
+ day: string
17
+ title: string
18
+ dir: string
19
+ detail: string
20
+ tint: string
21
+ allDay: bool
22
+ startMinute: number
23
+ endMinute: number
24
+ lane: number
25
+ lanes: number
26
+ order: number
27
+ before: bool
28
+ after: bool
29
+ time: string
30
+
31
+ // A marked day: its dots' colours ("" the accent) and what a screen reader
32
+ // hears after the date.
33
+ shape SchedulerMark
34
+ day: string
35
+ tints: string[]
36
+ label: string
37
+
38
+ // A locale's names, from `schedulerNames` in app.ts or the app's own tables.
39
+ // Weekday lists start on Sunday; `firstDay` and `weekend` count from it (0).
40
+ // `digits` is the ten digits in order, `hours` the 24 hour labels. The
41
+ // patterns hold {month}, {year}, {weekday}, {day}, {monthInDate},
42
+ // {monthShort} and {monthNumber}.
43
+ shape SchedulerNames
44
+ locale: string
45
+ months: string[]
46
+ monthsShort: string[]
47
+ monthsInDate: string[]
48
+ weekdays: string[]
49
+ weekdaysShort: string[]
50
+ weekdaysNarrow: string[]
51
+ firstDay: number
52
+ weekend: number[]
53
+ digits: string
54
+ hours: string[]
55
+ monthTitle: string
56
+ dayTitle: string
57
+ dayShort: string
58
+
59
+ // The views' words, all the app's (a `t("…")` each). `more` holds {count}.
60
+ shape SchedulerStrings
61
+ previousMonth: string
62
+ nextMonth: string
63
+ previousYear: string
64
+ nextYear: string
65
+ previousWeek: string
66
+ nextWeek: string
67
+ previousDay: string
68
+ nextDay: string
69
+ chooseMonth: string
70
+ today: string
71
+ allDay: string
72
+ week: string
73
+ more: string
74
+ noEvents: string
75
+ now: string
76
+ rangeStart: string
77
+ rangeEnd: string
78
+ unavailable: string
79
+ loading: string
80
+
81
+ // Which days may be chosen: on or after `minDay`, on or before `maxDay`
82
+ // ("" for no limit), not among `disabledDays`, not on a weekday (0 Sunday)
83
+ // in `disabledWeekdays`. The limits also stop the arrows.
84
+ shape SchedulerRules
85
+ minDay: string
86
+ maxDay: string
87
+ disabledDays: string[]
88
+ disabledWeekdays: number[]
89
+
90
+ // A range of days, both ends in it. "" is an end not chosen yet.
91
+ shape SchedulerRange
92
+ start: string
93
+ end: string
94
+
95
+ // What a view reads of the screen.
96
+ shape SchedulerViewport
97
+ prefersReducedMotion: bool
98
+ width: number
@@ -0,0 +1,31 @@
1
+ // exact-scheduler: a day, a week or a month in the app's names.
2
+
3
+ use SchedulerNames, SchedulerStrings, SchedulerMark from "./shapes.contract"
4
+ use yearOf, monthIndexOf, dateOf, weekdayOf, addDays, weekNumberOf from "./days.contract"
5
+
6
+ fn named(list: string[], i: number): string = match list.at(i) { case some(s) => s, case none => "" }
7
+ fn digitAt(digits: string, i: number): string = digits.slice(i, i + 1)
8
+ // A whole number in the locale's digits.
9
+ fn localDigits(digits: string, n: number): string = (digits == "" or digits == "0123456789") ? `${n}` : `${n}`.split("").map(c => (match parseNumber(c) { case some(d) => digitAt(digits, d), case none => c })).join("")
10
+
11
+ fn fill(pattern: string, names: SchedulerNames, day: string): string = pattern.replaceAll("{year}", localDigits(names.digits, yearOf(day))).replaceAll("{monthInDate}", named(names.monthsInDate, monthIndexOf(day))).replaceAll("{monthShort}", named(names.monthsShort, monthIndexOf(day))).replaceAll("{monthNumber}", localDigits(names.digits, monthIndexOf(day) + 1)).replaceAll("{month}", named(names.months, monthIndexOf(day))).replaceAll("{weekday}", named(names.weekdays, weekdayOf(day))).replaceAll("{day}", localDigits(names.digits, dateOf(day)))
12
+
13
+ // "November 2026", "Tuesday, November 24", "Nov 24".
14
+ fn monthTitle(names: SchedulerNames, day: string): string = fill(names.monthTitle, names, day)
15
+ fn dayTitle(names: SchedulerNames, day: string): string = fill(names.dayTitle, names, day)
16
+ fn dayShort(names: SchedulerNames, day: string): string = fill(names.dayShort, names, day)
17
+ // "Nov 22 – 28" is not every language's; the ends are written whole.
18
+ fn weekTitle(names: SchedulerNames, from: string, days: number): string = `${dayShort(names, from)} – ${dayShort(names, addDays(from, days - 1))}`
19
+
20
+ // The words of a day cell: the date, then what is true of it.
21
+ fn dayWords(names: SchedulerNames, day: string, extras: string[]): string = [dayTitle(names, day)].concat(extras.filter(s => s != "")).join(", ")
22
+
23
+ fn markOf(marks: SchedulerMark[], day: string): SchedulerMark = match first(marks.filter(m => m.day == day)) { case some(m) => m, case none => SchedulerMark(day=day, tints=[], label="") }
24
+ fn tintOf(tint: string): string = tint == "" ? "AccentColor" : tint
25
+ fn weekOrder(firstDay: number): number[] = range(7).map(i => (firstDay + i) % 7)
26
+ fn moreText(strings: SchedulerStrings, names: SchedulerNames, n: number): string = strings.more.replaceAll("{count}", localDigits(names.digits, n))
27
+
28
+ // The ISO number of the week a row of a month's grid is, by its fourth day,
29
+ // and its words.
30
+ fn weekOf(day: string): number = weekNumberOf(addDays(day, 3))
31
+ fn weekWords(names: SchedulerNames, strings: SchedulerStrings, days: string[], w: number): string = match days.at(w * 7) { case some(d) => `${strings.week} ${localDigits(names.digits, weekOf(d))}`, case none => strings.week }