Skip to content

Commit e347f95

Browse files
committed
Including timezones API in configuration endpoint
refs #6406 - endpoint configuration/timezones refers to timezones.json file in data - added route for endpoint in api.js to use method read in configuration.js
1 parent f4cdf4d commit e347f95

File tree

3 files changed

+340
-0
lines changed

3 files changed

+340
-0
lines changed

core/server/api/configuration.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ function labsFlag(key) {
1313
};
1414
}
1515

16+
function fetchAvailableTimezones() {
17+
var timezones = require('../data/timezones.json');
18+
return timezones;
19+
}
20+
1621
function getAboutConfig() {
1722
return {
1823
version: config.ghostVersion,
@@ -58,6 +63,11 @@ configuration = {
5863
return Promise.resolve({configuration: [getAboutConfig()]});
5964
}
6065

66+
// Timezone endpoint
67+
if (options.key === 'timezones') {
68+
return Promise.resolve({configuration: [fetchAvailableTimezones()]});
69+
}
70+
6171
return Promise.resolve({configuration: []});
6272
}
6373
};

core/server/data/timezones.json

Lines changed: 329 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
{
2+
"timezones": [
3+
{
4+
"name": "Pacific/Samoa",
5+
"label": "(GMT -11:00) Midway Island, Samoa",
6+
"offset": -660
7+
},
8+
{
9+
"name": "Pacific/Honolulu",
10+
"label": "(GMT -10:00) Hawaii",
11+
"offset": -600
12+
},
13+
{
14+
"name": "US/Alaska",
15+
"label": "(GMT -9:00) Alaska",
16+
"offset": -540
17+
},
18+
{
19+
"name": "Mexico/BajaNorte",
20+
"label": "(GMT -8:00) Chihuahua, La Paz, Mazatlan",
21+
"offset": -480
22+
},
23+
{
24+
"name": "US/Pacific",
25+
"label": "(GMT -8:00) Pacific Time (US & Canada); Tijuana",
26+
"offset": -480
27+
},
28+
{
29+
"name": "US/Arizona",
30+
"label": "(GMT -7:00) Arizona",
31+
"offset": -420
32+
},
33+
{
34+
"name": "US/Mountain",
35+
"label": "(GMT -7:00) Mountain Time (US & Canada)",
36+
"offset": -420
37+
},
38+
{
39+
"name": "America/Costa_Rica",
40+
"label": "(GMT -6:00) Central America",
41+
"offset": -360
42+
},
43+
{
44+
"name": "US/Central",
45+
"label": "(GMT -6:00) Central Time (US & Canada)",
46+
"offset": -360
47+
},
48+
{
49+
"name": "Mexico/General",
50+
"label": "(GMT -6:00) Guadalajara, Mexico City, Monterrey",
51+
"offset": -360
52+
},
53+
{
54+
"name": "Canada/Saskatchewan",
55+
"label": "(GMT -6:00) Saskatchewan",
56+
"offset": -360
57+
},
58+
{
59+
"name": "America/Bogota",
60+
"label": "(GMT -5:00) Bogota, Lima, Quito",
61+
"offset": -300
62+
},
63+
{
64+
"name": "US/Eastern",
65+
"label": "(GMT -5:00) Eastern Time (US & Canada)",
66+
"offset": -300
67+
},
68+
{
69+
"name": "US/East-Indiana",
70+
"label": "(GMT -5:00) Indiana (East)",
71+
"offset": -300
72+
},
73+
{
74+
"name": "America/Caracas",
75+
"label": "(GMT -4:30) Caracas, La Paz",
76+
"offset": -270
77+
},
78+
{
79+
"name": "Canada/Atlantic",
80+
"label": "(GMT -4:00) Atlantic Time (Canada); Brasilia, Greenland",
81+
"offset": -240
82+
},
83+
{
84+
"name": "Canada/Newfoundland",
85+
"label": "(GMT -3:30) Newfoundland",
86+
"offset": -210
87+
},
88+
{
89+
"name": "America/Buenos_Aires",
90+
"label": "(GMT -3:00) Buenos Aires, Georgetown",
91+
"offset": -180
92+
},
93+
{
94+
"name": "America/Santiago",
95+
"label": "(GMT -3:00) Santiago",
96+
"offset": -180
97+
},
98+
{
99+
"name": "America/Noronha",
100+
"label": "(GMT -2:00) Fernando de Noronha",
101+
"offset": -120
102+
},
103+
{
104+
"name": "Atlantic/Azores",
105+
"label": "(GMT -1:00) Azores",
106+
"offset": -60
107+
},
108+
{
109+
"name": "Atlantic/Cape_Verde",
110+
"label": "(GMT -1:00) Cape Verde Is.",
111+
"offset": -60
112+
},
113+
{
114+
"name": "Africa/Casablanca",
115+
"label": "(GMT) Casablanca, Monrovia",
116+
"offset": 0
117+
},
118+
{
119+
"name": "Europe/Dublin",
120+
"label": "(GMT) Greenwich Mean Time : Dublin, Edinburgh, London",
121+
"offset": 0
122+
},
123+
{
124+
"name": "Europe/Amsterdam",
125+
"label": "(GMT +1:00) Amsterdam, Berlin, Rome, Stockholm, Vienna",
126+
"offset": 60
127+
},
128+
{
129+
"name": "Europe/Prague",
130+
"label": "(GMT +1:00) Belgrade, Bratislava, Budapest, Prague",
131+
"offset": 60
132+
},
133+
{
134+
"name": "Europe/Paris",
135+
"label": "(GMT +1:00) Brussels, Copenhagen, Madrid, Paris",
136+
"offset": 60
137+
},
138+
{
139+
"name": "Europe/Warsaw",
140+
"label": "(GMT +1:00) Sarajevo, Skopje, Warsaw, Zagreb",
141+
"offset": 60
142+
},
143+
{
144+
"name": "Africa/Bangui",
145+
"label": "(GMT +1:00) West Central Africa",
146+
"offset": 60
147+
},
148+
{
149+
"name": "Europe/Istanbul",
150+
"label": "(GMT +2:00) Athens, Beirut, Bucharest, Istanbul",
151+
"offset": 120
152+
},
153+
{
154+
"name": "Africa/Cairo",
155+
"label": "(GMT +2:00) Cairo, Egypt",
156+
"offset": 120
157+
},
158+
{
159+
"name": "Africa/Harare",
160+
"label": "(GMT +2:00) Harare",
161+
"offset": 120
162+
},
163+
{
164+
"name": "Europe/Kiev",
165+
"label": "(GMT +2:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius",
166+
"offset": 120
167+
},
168+
{
169+
"name": "Asia/Jerusalem",
170+
"label": "(GMT +2:00) Jerusalem",
171+
"offset": 120
172+
},
173+
{
174+
"name": "Africa/Johannesburg",
175+
"label": "(GMT +2:00) Pretoria",
176+
"offset": 120
177+
},
178+
{
179+
"name": "Asia/Baghdad",
180+
"label": "(GMT +3:00) Baghdad",
181+
"offset": 180
182+
},
183+
{
184+
"name": "Asia/Riyadh",
185+
"label": "(GMT +3:00) Kuwait, Nairobi, Riyadh",
186+
"offset": 180
187+
},
188+
{
189+
"name": "Asia/Tehran",
190+
"label": "(GMT +3:30) Tehran",
191+
"offset": 210
192+
},
193+
{
194+
"name": "Asia/Muscat",
195+
"label": "(GMT +4:00) Abu Dhabi, Muscat",
196+
"offset": 240
197+
},
198+
{
199+
"name": "Asia/Baku",
200+
"label": "(GMT +4:00) Baku, Tbilisi, Yerevan",
201+
"offset": 240
202+
},
203+
{
204+
"name": "Europe/Moscow",
205+
"label": "(GMT +4:00) Moscow, St. Petersburg, Volgograd",
206+
"offset": 240
207+
},
208+
{
209+
"name": "Asia/Kabul",
210+
"label": "(GMT +4:30) Kabul",
211+
"offset": 270
212+
},
213+
{
214+
"name": "Asia/Karachi",
215+
"label": "(GMT +5:00) Islamabad, Karachi, Tashkent",
216+
"offset": 300
217+
},
218+
{
219+
"name": "Asia/Calcutta",
220+
"label": "(GMT +5:30) Chennai, Calcutta, Mumbai, New Delhi",
221+
"offset": 330
222+
},
223+
{
224+
"name": "Asia/Katmandu",
225+
"label": "(GMT +5:45) Katmandu",
226+
"offset": 345
227+
},
228+
{
229+
"name": "Asia/Almaty",
230+
"label": "(GMT +6:00) Almaty, Novosibirsk",
231+
"offset": 360
232+
},
233+
{
234+
"name": "Asia/Dhaka",
235+
"label": "(GMT +6:00) Astana, Dhaka, Sri Jayawardenepura",
236+
"offset": 360
237+
},
238+
{
239+
"name": "Asia/Yekaterinburg",
240+
"label": "(GMT +6:00) Yekaterinburg",
241+
"offset": 360
242+
},
243+
{
244+
"name": "Asia/Rangoon",
245+
"label": "(GMT +6:30) Rangoon",
246+
"offset": 390
247+
},
248+
{
249+
"name": "Asia/Bangkok",
250+
"label": "(GMT +7:00) Bangkok, Hanoi, Jakarta",
251+
"offset": 420
252+
},
253+
{
254+
"name": "Asia/Hong_Kong",
255+
"label": "(GMT +8:00) Beijing, Chongqing, Hong Kong, Urumqi",
256+
"offset": 480
257+
},
258+
{
259+
"name": "Asia/Krasnoyarsk",
260+
"label": "(GMT +8:00) Krasnoyarsk",
261+
"offset": 480
262+
},
263+
{
264+
"name": "Asia/Singapore",
265+
"label": "(GMT +8:00) Kuala Lumpur, Perth, Singapore, Taipei",
266+
"offset": 480
267+
},
268+
{
269+
"name": "Asia/Irkutsk",
270+
"label": "(GMT +9:00) Irkutsk, Ulaan Bataar",
271+
"offset": 540
272+
},
273+
{
274+
"name": "Asia/Tokyo",
275+
"label": "(GMT +9:00) Osaka, Sapporo, Tokyo",
276+
"offset": 540
277+
},
278+
{
279+
"name": "Asia/Seoul",
280+
"label": "(GMT +9:00) Seoul",
281+
"offset": 540
282+
},
283+
{
284+
"name": "Australia/Darwin",
285+
"label": "(GMT +9:30) Darwin",
286+
"offset": 570
287+
},
288+
{
289+
"name": "Australia/Brisbane",
290+
"label": "(GMT +10:00) Brisbane, Guam, Port Moresby",
291+
"offset": 600
292+
},
293+
{
294+
"name": "Asia/Yakutsk",
295+
"label": "(GMT +10:00) Yakutsk",
296+
"offset": 600
297+
},
298+
{
299+
"name": "Australia/Adelaide",
300+
"label": "(GMT +10:30) Adelaide",
301+
"offset": 630
302+
},
303+
{
304+
"name": "Australia/Canberra",
305+
"label": "(GMT +11:00) Canberra, Hobart, Melbourne, Sydney, Vladivostok",
306+
"offset": 660
307+
},
308+
{
309+
"name": "Pacific/Fiji",
310+
"label": "(GMT +12:00) Fiji, Kamchatka, Marshall Is.",
311+
"offset": 720
312+
},
313+
{
314+
"name": "Pacific/Kwajalein",
315+
"label": "(GMT +12:00) International Date Line West",
316+
"offset": 720
317+
},
318+
{
319+
"name": "Asia/Magadan",
320+
"label": "(GMT +12:00) Magadan, Soloman Is., New Caledonia",
321+
"offset": 720
322+
},
323+
{
324+
"name": "Pacific/Auckland",
325+
"label": "(GMT +13:00) Auckland, Wellington",
326+
"offset": 780
327+
}
328+
]
329+
}

core/server/routes/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ apiRoutes = function apiRoutes(middleware) {
2424
// ## Configuration
2525
router.get('/configuration', authenticatePrivate, api.http(api.configuration.read));
2626
router.get('/configuration/:key', authenticatePrivate, api.http(api.configuration.read));
27+
router.get('/configuration/timezones', authenticatePrivate, api.http(api.configuration.read));
2728

2829
// ## Posts
2930
router.get('/posts', authenticatePublic, api.http(api.posts.browse));

0 commit comments

Comments
 (0)