-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.js
More file actions
46 lines (40 loc) · 1.45 KB
/
Copy pathModel.js
File metadata and controls
46 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Clock-label helpers. Calendar-specific data handling stays in
// CalendarModel.js so the bar host follows Omarchy's clock structure.
var CLOCK_FORMATS = [
"dddd HH:mm",
"HH:mm",
"ddd d MMM HH:mm",
"d MMMM 'W'ww yyyy",
"yyyy-MM-dd HH:mm"
]
var VERTICAL_CLOCK_FORMATS = [
"HH\n—\nmm",
"dd\nMMM\n'W'ww\n''yy",
"HH\nmm"
]
function clockFormats(vertical) {
return vertical ? VERTICAL_CLOCK_FORMATS.slice() : CLOCK_FORMATS.slice()
}
function clockFormatRing(configured, configuredAlt, presets) {
var ring = []
var candidates = (presets || []).concat([configuredAlt, configured])
for (var i = 0; i < candidates.length; i++) {
var format = String(candidates[i] === undefined || candidates[i] === null ? "" : candidates[i])
if (format === "" || ring.indexOf(format) !== -1) continue
ring.push(format)
}
return ring.length > 0 ? ring : ["HH:mm"]
}
function nextClockFormat(ring, current) {
if (!ring || ring.length === 0) return ""
var index = ring.indexOf(String(current === undefined || current === null ? "" : current))
return ring[(index + 1) % ring.length]
}
function isoWeekLiteral(year, month, day) {
var date = new Date(Date.UTC(year, month, day))
var weekday = date.getUTCDay() || 7
date.setUTCDate(date.getUTCDate() + 4 - weekday)
var yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1))
var week = Math.ceil(((date.getTime() - yearStart.getTime()) / 86400000 + 1) / 7)
return (week < 10 ? "0" : "") + week
}