-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseasonalhours.js
171 lines (165 loc) · 3.65 KB
/
seasonalhours.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// @see https://github.com/sgwilym/seasonal-hours-clock/
/**
* This concept originated in [Twodays Crossing](https://github.com/earthstar-project/twodays-crossing), an Earthstar chat app.
* This clock was created by [@cinnamon-bun](https://github.com/cinnamon-bun). We miss you.
*/
/*
Pretend that each 24 hour period is actually an entire year with seasons.
UTC hour 0 is Jan 1, winter.
UTC hour 6 is the first day of spring, etc.
Give each of these hours a pretty name related to the season it's in.
These "seasonal hours" will be synchronized for everyone around the world
because they use UTC time.
Hour names were brainstormed in this spreadsheet
https://docs.google.com/spreadsheets/d/1uEnIJp2FFQYr2VexcZvJhKOMe898lOUDCrXZX2VlzDQ/edit?usp=sharing
*/
const hourTable = {
0: {
season: "winter",
shortName: "candle",
longName: "candle hour",
emoji: "🕯"
},
1: {
season: "winter",
shortName: "ice",
longName: "hour of ice",
emoji: "❄️"
},
2: {
season: "winter",
shortName: "comet",
longName: "hour of the comet",
emoji: "☄️"
},
3: { season: "winter", shortName: "owl", longName: "owl hour", emoji: "🦉" },
4: {
season: "winter",
shortName: "yarn",
longName: "yarn hour",
emoji: "🧶"
},
5: {
season: "winter",
shortName: "mist",
longName: "hour of mist",
emoji: "🌫"
},
6: {
season: "spring",
shortName: "sprout",
longName: "sprout hour",
emoji: "🌱"
},
7: {
season: "spring",
shortName: "rainbow",
longName: "rainbow hour",
emoji: "🌈"
},
8: {
season: "spring",
shortName: "worm",
longName: "worm hour",
emoji: "🪱"
},
9: {
season: "spring",
shortName: "rabbit",
longName: "rabbit hour",
emoji: "🐇"
},
10: {
season: "spring",
shortName: "blossom",
longName: "blossom hour",
emoji: "🌸"
},
11: {
season: "spring",
shortName: "nest",
longName: "nest hour",
emoji: "🪺"
},
12: {
season: "summer",
shortName: "coral",
longName: "coral hour",
emoji: "🪸"
},
13: {
season: "summer",
shortName: "cherry",
longName: "cherry hour",
emoji: "🍒"
},
14: { season: "summer", shortName: "bee", longName: "bee hour", emoji: "🐝" },
15: {
season: "summer",
shortName: "melon",
longName: "melon hour",
emoji: "🍉"
},
16: {
season: "summer",
shortName: "seashell",
longName: "seashell hour",
emoji: "🐚"
},
17: {
season: "summer",
shortName: "dragon",
longName: "hour of the dragon",
emoji: "🐉"
},
18: {
season: "autumn",
shortName: "chestnut",
longName: "chestnut hour",
emoji: "🌰"
},
19: {
season: "autumn",
shortName: "kite",
longName: "hour of the kite",
emoji: "🪁"
},
20: {
season: "autumn",
shortName: "mushroom",
longName: "mushroom hour",
emoji: "🍄"
},
21: {
season: "autumn",
shortName: "lightning",
longName: "lightning hour",
emoji: "⚡️"
},
22: {
season: "autumn",
shortName: "mountain",
longName: "hour of the mountain",
emoji: "⛰"
},
23: {
season: "autumn",
shortName: "lantern",
longName: "lantern hour",
emoji: "🏮"
}
}
function getUtcHour() {
// Return the current hour of the day in UTC time,
// including fractional hours.
// Example: 03:20 --> 3.33333
// Range: 0 to 23.99999
let now = new Date()
return (
now.getUTCHours() + now.getUTCMinutes() / 60 + now.getUTCSeconds() / 60 / 60
)
}
function getHourOf() {
let intHour = Math.floor(getUtcHour())
return hourTable[intHour]
}