tp_common 0.4.4 → 0.4.5
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.
- checksums.yaml +4 -4
- data/gemfiles/rails_4.gemfile.lock +1 -1
- data/gemfiles/rails_5.gemfile.lock +1 -1
- data/gemfiles/rails_6.gemfile.lock +1 -1
- data/gemfiles/rails_latest.gemfile.lock +1 -1
- data/lib/tp_common/timezones/config/reversed.yml +438 -0
- data/lib/tp_common/timezones/config.rb +79 -14
- data/lib/tp_common/timezones/reversed.rb +21 -0
- data/lib/tp_common/version.rb +1 -1
- data/lib/tp_common.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af8aaa21db2a61c260558fe333fe1db9d29b96a4fb3410d043c3be19577c58f7
|
|
4
|
+
data.tar.gz: 51062a668dc17c2c1f4a5c4195d762886269e9acdfa7f39e02067ebd6534c575
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f10a2016b475dcb09ca667f25dd7849fc1b209f27d3aa9e4284b96fe63a2f4cf5861ca15ec0520cdc9979b22b14a74c0e8ab1753a616e96611da6a4a7b4d5d3
|
|
7
|
+
data.tar.gz: bde140d5e8392976c738004fcf4f2d34b2d17821a9e10c64d4e8232b763f92955752033bb814bbbef2b5e47e67bd874865981d7f85a6556c3f75f0331df06444
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
gmt-12: &gmt-12
|
|
2
|
+
GMT_M1200:
|
|
3
|
+
- 'Etc/GMT+12'
|
|
4
|
+
- 'GMT-12'
|
|
5
|
+
|
|
6
|
+
gmt-11: &gmt-11
|
|
7
|
+
GMT_M1100:
|
|
8
|
+
- 'Etc/GMT+11'
|
|
9
|
+
- 'GMT-11'
|
|
10
|
+
GMT_M1100+1:
|
|
11
|
+
- 'American Samoa'
|
|
12
|
+
GMT_M1100+2:
|
|
13
|
+
- 'International Date Line West'
|
|
14
|
+
GMT_M1100+3:
|
|
15
|
+
- 'Midway Island'
|
|
16
|
+
|
|
17
|
+
gmt-10: &gmt-10
|
|
18
|
+
GMT_M1000:
|
|
19
|
+
- 'Etc/GMT+10'
|
|
20
|
+
- 'GMT-10'
|
|
21
|
+
GMT_M1000+1:
|
|
22
|
+
- 'Hawaii'
|
|
23
|
+
|
|
24
|
+
gmt-9: &gmt-9
|
|
25
|
+
GMT_M0900:
|
|
26
|
+
- 'Etc/GMT+9'
|
|
27
|
+
- 'GMT-9'
|
|
28
|
+
GMT_M0900+1:
|
|
29
|
+
- 'Alaska'
|
|
30
|
+
|
|
31
|
+
gmt-8: &gmt-8
|
|
32
|
+
GMT_M0800:
|
|
33
|
+
- 'Etc/GMT+8'
|
|
34
|
+
- 'GMT-8'
|
|
35
|
+
GMT_M0800+1:
|
|
36
|
+
- 'Pacific Time (US & Canada)'
|
|
37
|
+
- 'Pacific Time'
|
|
38
|
+
- PST
|
|
39
|
+
- PDT
|
|
40
|
+
- PT
|
|
41
|
+
GMT_M0800+2:
|
|
42
|
+
- 'Tijuana'
|
|
43
|
+
|
|
44
|
+
gmt-7: &gmt-7
|
|
45
|
+
GMT_M0700:
|
|
46
|
+
- 'Etc/GMT+7'
|
|
47
|
+
- 'GMT-7'
|
|
48
|
+
GMT_M0700+1:
|
|
49
|
+
- 'Arizona'
|
|
50
|
+
GMT_M0700+2:
|
|
51
|
+
- 'Chihuahua'
|
|
52
|
+
GMT_M0700+3:
|
|
53
|
+
- 'Mazatlan'
|
|
54
|
+
GMT_M0700+4:
|
|
55
|
+
- 'Mountain Time (US & Canada)'
|
|
56
|
+
- 'Mountain Time'
|
|
57
|
+
- MST
|
|
58
|
+
- MDT
|
|
59
|
+
- MT
|
|
60
|
+
|
|
61
|
+
gmt-6: &gmt-6
|
|
62
|
+
GMT_M0600:
|
|
63
|
+
- 'Etc/GMT+6'
|
|
64
|
+
- 'GMT-6'
|
|
65
|
+
GMT_M0600+1:
|
|
66
|
+
- 'Central America'
|
|
67
|
+
GMT_M0600+2:
|
|
68
|
+
- 'Central Time (US & Canada)'
|
|
69
|
+
- 'Central Time'
|
|
70
|
+
- CST
|
|
71
|
+
- CDT
|
|
72
|
+
- CT
|
|
73
|
+
GMT_M0600+3:
|
|
74
|
+
- 'Guadalajara'
|
|
75
|
+
GMT_M0600+4:
|
|
76
|
+
- 'Mexico City'
|
|
77
|
+
GMT_M0600+5:
|
|
78
|
+
- 'Monterrey'
|
|
79
|
+
GMT_M0600+6:
|
|
80
|
+
- 'Saskatchewan'
|
|
81
|
+
|
|
82
|
+
gmt-5: &gmt-5
|
|
83
|
+
GMT_M0500:
|
|
84
|
+
- 'Etc/GMT+5'
|
|
85
|
+
- 'GMT-5'
|
|
86
|
+
GMT_M0500+1:
|
|
87
|
+
- 'Bogota'
|
|
88
|
+
GMT_M0500+2:
|
|
89
|
+
- 'Eastern Time (US & Canada)'
|
|
90
|
+
- 'Eastern Time'
|
|
91
|
+
- EST
|
|
92
|
+
- EDT
|
|
93
|
+
- ET
|
|
94
|
+
GMT_M0500+3:
|
|
95
|
+
- 'Indiana (East)'
|
|
96
|
+
- 'Indiana'
|
|
97
|
+
GMT_M0500+4:
|
|
98
|
+
- 'Lima'
|
|
99
|
+
GMT_M0500+5:
|
|
100
|
+
- 'Quito'
|
|
101
|
+
|
|
102
|
+
gmt-4: &gmt-4
|
|
103
|
+
GMT_M0400:
|
|
104
|
+
- 'Etc/GMT+4'
|
|
105
|
+
- 'GMT-4'
|
|
106
|
+
GMT_M0400+1:
|
|
107
|
+
- 'Atlantic Time (Canada)'
|
|
108
|
+
- 'Atlantic Time'
|
|
109
|
+
GMT_M0400+2:
|
|
110
|
+
- 'Caracas'
|
|
111
|
+
GMT_M0400+3:
|
|
112
|
+
- 'Georgetown'
|
|
113
|
+
GMT_M0400+4:
|
|
114
|
+
- 'La Paz'
|
|
115
|
+
GMT_M0400+5:
|
|
116
|
+
- 'Santiago'
|
|
117
|
+
|
|
118
|
+
gmt-3: &gmt-3
|
|
119
|
+
GMT_M0300:
|
|
120
|
+
- 'Etc/GMT+3'
|
|
121
|
+
- 'GMT-3'
|
|
122
|
+
GMT_M0300+1:
|
|
123
|
+
- 'Brasilia'
|
|
124
|
+
GMT_M0300+2:
|
|
125
|
+
- 'Buenos Aires'
|
|
126
|
+
GMT_M0300+3:
|
|
127
|
+
- 'Greenland'
|
|
128
|
+
GMT_M0300+4:
|
|
129
|
+
- 'Montevideo'
|
|
130
|
+
|
|
131
|
+
gmt-2: &gmt-2
|
|
132
|
+
GMT_M0200:
|
|
133
|
+
- 'Etc/GMT+2'
|
|
134
|
+
- 'GMT-2'
|
|
135
|
+
GMT_M0200+1:
|
|
136
|
+
- 'Mid-Atlantic'
|
|
137
|
+
|
|
138
|
+
gmt-1: &gmt-1
|
|
139
|
+
GMT_M0100:
|
|
140
|
+
- 'Etc/GMT+1'
|
|
141
|
+
- 'GMT-1'
|
|
142
|
+
GMT_M0100+1:
|
|
143
|
+
- 'Azores'
|
|
144
|
+
GMT_M0100+2:
|
|
145
|
+
- 'Cape Verde Is.'
|
|
146
|
+
- 'Cape Verde'
|
|
147
|
+
|
|
148
|
+
gmt-0: &gmt-0
|
|
149
|
+
GMT_M0000:
|
|
150
|
+
- 'Etc/GMT+0'
|
|
151
|
+
- 'GMT-0'
|
|
152
|
+
GMT_M0000+1:
|
|
153
|
+
- 'Casablanca'
|
|
154
|
+
GMT_M0000+2:
|
|
155
|
+
- 'Dublin'
|
|
156
|
+
GMT_M0000+3:
|
|
157
|
+
- 'Edinburgh'
|
|
158
|
+
GMT_M0000+4:
|
|
159
|
+
- 'Lisbon'
|
|
160
|
+
GMT_M0000+5:
|
|
161
|
+
- 'London'
|
|
162
|
+
GMT_M0000+6:
|
|
163
|
+
- 'Monrovia'
|
|
164
|
+
GMT_M0000+7:
|
|
165
|
+
- 'UTC'
|
|
166
|
+
|
|
167
|
+
gmt1: &gmt1
|
|
168
|
+
GMT_P0100:
|
|
169
|
+
- 'Etc/GMT-1'
|
|
170
|
+
- 'GMT+1'
|
|
171
|
+
GMT_P0100+1:
|
|
172
|
+
- 'Amsterdam'
|
|
173
|
+
GMT_P0100+2:
|
|
174
|
+
- 'Belgrade'
|
|
175
|
+
GMT_P0100+3:
|
|
176
|
+
- 'Berlin'
|
|
177
|
+
GMT_P0100+4:
|
|
178
|
+
- 'Bern'
|
|
179
|
+
GMT_P0100+5:
|
|
180
|
+
- 'Bratislava'
|
|
181
|
+
GMT_P0100+6:
|
|
182
|
+
- 'Brussels'
|
|
183
|
+
GMT_P0100+7:
|
|
184
|
+
- 'Budapest'
|
|
185
|
+
GMT_P0100+8:
|
|
186
|
+
- 'Copenhagen'
|
|
187
|
+
GMT_P0100+9:
|
|
188
|
+
- 'Ljubljana'
|
|
189
|
+
GMT_P0100+10:
|
|
190
|
+
- 'Madrid'
|
|
191
|
+
GMT_P0100+11:
|
|
192
|
+
- 'Paris'
|
|
193
|
+
GMT_P0100+12:
|
|
194
|
+
- 'Prague'
|
|
195
|
+
GMT_P0100+13:
|
|
196
|
+
- 'Rome'
|
|
197
|
+
GMT_P0100+14:
|
|
198
|
+
- 'Sarajevo'
|
|
199
|
+
GMT_P0100+15:
|
|
200
|
+
- 'Skopje'
|
|
201
|
+
GMT_P0100+16:
|
|
202
|
+
- 'Stockholm'
|
|
203
|
+
GMT_P0100+17:
|
|
204
|
+
- 'Vienna'
|
|
205
|
+
GMT_P0100+18:
|
|
206
|
+
- 'Warsaw'
|
|
207
|
+
GMT_P0100+19:
|
|
208
|
+
- 'West Central Africa'
|
|
209
|
+
GMT_P0100+20:
|
|
210
|
+
- 'Zagreb'
|
|
211
|
+
|
|
212
|
+
gmt2: &gmt2
|
|
213
|
+
GMT_P0200:
|
|
214
|
+
- 'Etc/GMT-2'
|
|
215
|
+
- 'GMT+2'
|
|
216
|
+
GMT_P0200+1:
|
|
217
|
+
- 'Athens'
|
|
218
|
+
GMT_P0200+2:
|
|
219
|
+
- 'Bucharest'
|
|
220
|
+
GMT_P0200+3:
|
|
221
|
+
- 'Cairo'
|
|
222
|
+
GMT_P0200+4:
|
|
223
|
+
- 'Harare'
|
|
224
|
+
GMT_P0200+5:
|
|
225
|
+
- 'Helsinki'
|
|
226
|
+
GMT_P0200+6:
|
|
227
|
+
- 'Jerusalem'
|
|
228
|
+
GMT_P0200+7:
|
|
229
|
+
- 'Kaliningrad'
|
|
230
|
+
GMT_P0200+8:
|
|
231
|
+
- 'Kyiv'
|
|
232
|
+
GMT_P0200+9:
|
|
233
|
+
- 'Pretoria'
|
|
234
|
+
GMT_P0200+10:
|
|
235
|
+
- 'Riga'
|
|
236
|
+
GMT_P0200+11:
|
|
237
|
+
- 'Sofia'
|
|
238
|
+
GMT_P0200+12:
|
|
239
|
+
- 'Tallinn'
|
|
240
|
+
GMT_P0200+13:
|
|
241
|
+
- 'Vilnius'
|
|
242
|
+
|
|
243
|
+
gmt3: &gmt3
|
|
244
|
+
GMT_P0300:
|
|
245
|
+
- 'Etc/GMT-3'
|
|
246
|
+
- 'GMT+3'
|
|
247
|
+
GMT_P0300+1:
|
|
248
|
+
- 'Baghdad'
|
|
249
|
+
GMT_P0300+2:
|
|
250
|
+
- 'Istanbul'
|
|
251
|
+
GMT_P0300+3:
|
|
252
|
+
- 'Kuwait'
|
|
253
|
+
GMT_P0300+4:
|
|
254
|
+
- 'Minsk'
|
|
255
|
+
GMT_P0300+5:
|
|
256
|
+
- 'Moscow'
|
|
257
|
+
GMT_P0300+6:
|
|
258
|
+
- 'Nairobi'
|
|
259
|
+
GMT_P0300+7:
|
|
260
|
+
- 'Riyadh'
|
|
261
|
+
GMT_P0300+8:
|
|
262
|
+
- 'St. Petersburg'
|
|
263
|
+
GMT_P0300+9:
|
|
264
|
+
- 'Volgograd'
|
|
265
|
+
|
|
266
|
+
gmt4: &gmt4
|
|
267
|
+
GMT_P0400:
|
|
268
|
+
- 'Etc/GMT-4'
|
|
269
|
+
- 'GMT+4'
|
|
270
|
+
GMT_P0400+1:
|
|
271
|
+
- 'Abu Dhabi'
|
|
272
|
+
GMT_P0400+2:
|
|
273
|
+
- 'Baku'
|
|
274
|
+
GMT_P0400+3:
|
|
275
|
+
- 'Muscat'
|
|
276
|
+
GMT_P0400+4:
|
|
277
|
+
- 'Samara'
|
|
278
|
+
GMT_P0400+5:
|
|
279
|
+
- 'Tbilisi'
|
|
280
|
+
GMT_P0400+6:
|
|
281
|
+
- 'Yerevan'
|
|
282
|
+
|
|
283
|
+
gmt5: &gmt5
|
|
284
|
+
GMT_P0500:
|
|
285
|
+
- 'Etc/GMT-5'
|
|
286
|
+
- 'GMT+5'
|
|
287
|
+
- 'GMT+5.5'
|
|
288
|
+
GMT_P0500+1:
|
|
289
|
+
- 'Ekaterinburg'
|
|
290
|
+
GMT_P0500+2:
|
|
291
|
+
- 'Islamabad'
|
|
292
|
+
GMT_P0500+3:
|
|
293
|
+
- 'Karachi'
|
|
294
|
+
GMT_P0500+4:
|
|
295
|
+
- 'Tashkent'
|
|
296
|
+
|
|
297
|
+
gmt6: &gmt6
|
|
298
|
+
GMT_P0600:
|
|
299
|
+
- 'Etc/GMT-6'
|
|
300
|
+
- 'GMT+6'
|
|
301
|
+
GMT_P0600+1:
|
|
302
|
+
- 'Almaty'
|
|
303
|
+
GMT_P0600+2:
|
|
304
|
+
- 'Astana'
|
|
305
|
+
GMT_P0600+3:
|
|
306
|
+
- 'Dhaka'
|
|
307
|
+
GMT_P0600+4:
|
|
308
|
+
- 'Urumqi'
|
|
309
|
+
|
|
310
|
+
gmt7: &gmt7
|
|
311
|
+
GMT_P0700:
|
|
312
|
+
- 'Etc/GMT-7'
|
|
313
|
+
- 'GMT+7'
|
|
314
|
+
GMT_P0700+1:
|
|
315
|
+
- 'Bangkok'
|
|
316
|
+
GMT_P0700+2:
|
|
317
|
+
- 'Hanoi'
|
|
318
|
+
GMT_P0700+3:
|
|
319
|
+
- 'Jakarta'
|
|
320
|
+
GMT_P0700+4:
|
|
321
|
+
- 'Krasnoyarsk'
|
|
322
|
+
GMT_P0700+5:
|
|
323
|
+
- 'Novosibirsk'
|
|
324
|
+
|
|
325
|
+
gmt8: &gmt8
|
|
326
|
+
GMT_P0800:
|
|
327
|
+
- 'Etc/GMT-8'
|
|
328
|
+
- 'GMT+8'
|
|
329
|
+
GMT_P0800+1:
|
|
330
|
+
- 'Beijing'
|
|
331
|
+
GMT_P0800+2:
|
|
332
|
+
- 'Chongqing'
|
|
333
|
+
GMT_P0800+3:
|
|
334
|
+
- 'Hong Kong'
|
|
335
|
+
GMT_P0800+4:
|
|
336
|
+
- 'Irkutsk'
|
|
337
|
+
GMT_P0800+5:
|
|
338
|
+
- 'Kuala Lumpur'
|
|
339
|
+
GMT_P0800+6:
|
|
340
|
+
- 'Perth'
|
|
341
|
+
GMT_P0800+7:
|
|
342
|
+
- 'Singapore'
|
|
343
|
+
GMT_P0800+8:
|
|
344
|
+
- 'Taipei'
|
|
345
|
+
GMT_P0800+9:
|
|
346
|
+
- 'Ulaanbaatar'
|
|
347
|
+
|
|
348
|
+
gmt9: &gmt9
|
|
349
|
+
GMT_P0900:
|
|
350
|
+
- 'Etc/GMT-9'
|
|
351
|
+
- 'GMT+9'
|
|
352
|
+
GMT_P0900+1:
|
|
353
|
+
- 'Osaka'
|
|
354
|
+
GMT_P0900+2:
|
|
355
|
+
- 'Sapporo'
|
|
356
|
+
GMT_P0900+3:
|
|
357
|
+
- 'Seoul'
|
|
358
|
+
GMT_P0900+4:
|
|
359
|
+
- 'Tokyo'
|
|
360
|
+
GMT_P0900+5:
|
|
361
|
+
- 'Yakutsk'
|
|
362
|
+
|
|
363
|
+
gmt10: &gmt10
|
|
364
|
+
GMT_P1000:
|
|
365
|
+
- 'Etc/GMT-10'
|
|
366
|
+
- 'GMT+10'
|
|
367
|
+
GMT_P1000+1:
|
|
368
|
+
- 'Brisbane'
|
|
369
|
+
GMT_P1000+2:
|
|
370
|
+
- 'Canberra'
|
|
371
|
+
GMT_P1000+3:
|
|
372
|
+
- 'Guam'
|
|
373
|
+
GMT_P1000+4:
|
|
374
|
+
- 'Hobart'
|
|
375
|
+
GMT_P1000+5:
|
|
376
|
+
- 'Melbourne'
|
|
377
|
+
GMT_P1000+6:
|
|
378
|
+
- 'Port Moresby'
|
|
379
|
+
GMT_P1000+7:
|
|
380
|
+
- 'Sydney'
|
|
381
|
+
GMT_P1000+8:
|
|
382
|
+
- 'Vladivostok'
|
|
383
|
+
|
|
384
|
+
gmt11: &gmt11
|
|
385
|
+
GMT_P1100:
|
|
386
|
+
- 'Etc/GMT-11'
|
|
387
|
+
- 'GMT+11'
|
|
388
|
+
GMT_P1100+1:
|
|
389
|
+
- 'Magadan'
|
|
390
|
+
GMT_P1100+2:
|
|
391
|
+
- 'New Caledonia'
|
|
392
|
+
GMT_P1100+3:
|
|
393
|
+
- 'Solomon Is.'
|
|
394
|
+
GMT_P1100+4:
|
|
395
|
+
- 'Srednekolymsk'
|
|
396
|
+
|
|
397
|
+
gmt12: &gmt12
|
|
398
|
+
GMT_P1200:
|
|
399
|
+
- 'Etc/GMT-12'
|
|
400
|
+
- 'GMT+12'
|
|
401
|
+
GMT_P1200+1:
|
|
402
|
+
- 'Auckland'
|
|
403
|
+
GMT_P1200+2:
|
|
404
|
+
- 'Fiji'
|
|
405
|
+
GMT_P1200+3:
|
|
406
|
+
- 'Kamchatka'
|
|
407
|
+
GMT_P1200+4:
|
|
408
|
+
- 'Marshall Is.'
|
|
409
|
+
- 'Marshall'
|
|
410
|
+
GMT_P1200+5:
|
|
411
|
+
- 'Wellington'
|
|
412
|
+
|
|
413
|
+
all_zones: &default
|
|
414
|
+
<<: *gmt-12
|
|
415
|
+
<<: *gmt-11
|
|
416
|
+
<<: *gmt-10
|
|
417
|
+
<<: *gmt-9
|
|
418
|
+
<<: *gmt-8
|
|
419
|
+
<<: *gmt-7
|
|
420
|
+
<<: *gmt-6
|
|
421
|
+
<<: *gmt-5
|
|
422
|
+
<<: *gmt-4
|
|
423
|
+
<<: *gmt-3
|
|
424
|
+
<<: *gmt-2
|
|
425
|
+
<<: *gmt-1
|
|
426
|
+
<<: *gmt-0
|
|
427
|
+
<<: *gmt1
|
|
428
|
+
<<: *gmt2
|
|
429
|
+
<<: *gmt3
|
|
430
|
+
<<: *gmt4
|
|
431
|
+
<<: *gmt5
|
|
432
|
+
<<: *gmt6
|
|
433
|
+
<<: *gmt7
|
|
434
|
+
<<: *gmt8
|
|
435
|
+
<<: *gmt9
|
|
436
|
+
<<: *gmt10
|
|
437
|
+
<<: *gmt11
|
|
438
|
+
<<: *gmt12
|
|
@@ -4,21 +4,54 @@ module TpCommon
|
|
|
4
4
|
# Try to load TpCommon::Timezones::LIST_ZONES in config/timezones.yml from rails app.
|
|
5
5
|
# if not, load the default in timezones/config/timezones.yml
|
|
6
6
|
def self.config
|
|
7
|
+
config_list_zones
|
|
8
|
+
config_reversed_list_zones
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.config_list_zones
|
|
7
12
|
return if TpCommon::Timezones.const_defined?("LIST_ZONES")
|
|
8
|
-
if defined?(::Rails::Railtie)
|
|
9
|
-
begin
|
|
10
|
-
TpCommon::Timezones.const_set("LIST_ZONES", Rails.application.config_for(:timezones))
|
|
11
|
-
puts "[TpCommon::Timezones::Config] Message-3: Use custom timezones in project config/timezones.yml"
|
|
12
|
-
return
|
|
13
|
-
rescue NameError, NoMethodError
|
|
14
|
-
puts "[TpCommon::Timezones::Config] Message-1: Use default timezones in tp_common/timezones/config/timezones.yml"
|
|
15
|
-
rescue StandardError
|
|
16
|
-
puts "[TpCommon::Timezones::Config] Message-2: Use default timezones in tp_common/timezones/config/timezones.yml"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
13
|
|
|
14
|
+
return if defined?(::Rails::Railtie) && load_rails_time_zones
|
|
20
15
|
TpCommon::Timezones.const_set("LIST_ZONES", load_default_timezones)
|
|
21
16
|
end
|
|
17
|
+
private_class_method :config_list_zones
|
|
18
|
+
|
|
19
|
+
def self.config_reversed_list_zones
|
|
20
|
+
return if TpCommon::Timezones.const_defined?("REVERSED_LIST_ZONES")
|
|
21
|
+
|
|
22
|
+
return if defined?(::Rails::Railtie) && load_rails_reversed_time_zones
|
|
23
|
+
TpCommon::Timezones.const_set("REVERSED_LIST_ZONES",
|
|
24
|
+
reversed_time_zone_lookup_table(load_default_reversed_timezones))
|
|
25
|
+
end
|
|
26
|
+
private_class_method :config_reversed_list_zones
|
|
27
|
+
|
|
28
|
+
# Private
|
|
29
|
+
def self.load_rails_time_zones
|
|
30
|
+
begin
|
|
31
|
+
TpCommon::Timezones.const_set("LIST_ZONES", Rails.application.config_for(:timezones))
|
|
32
|
+
Rails.logger.debug "[TpCommon::Timezones::Config] Message-3: Use custom timezones in project config/timezones.yml"
|
|
33
|
+
return true
|
|
34
|
+
rescue NameError, NoMethodError
|
|
35
|
+
Rails.logger.debug "[TpCommon::Timezones::Config] Message-1: Use default timezones in tp_common/timezones/config/timezones.yml"
|
|
36
|
+
rescue StandardError
|
|
37
|
+
Rails.logger.debug "[TpCommon::Timezones::Config] Message-2: Use default timezones in tp_common/timezones/config/timezones.yml"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
false
|
|
41
|
+
end
|
|
42
|
+
private_class_method :load_rails_time_zones
|
|
43
|
+
|
|
44
|
+
def self.load_rails_reversed_time_zones
|
|
45
|
+
begin
|
|
46
|
+
TpCommon::Timezones.const_set("REVERSED_LIST_ZONES",
|
|
47
|
+
reversed_time_zone_lookup_table(Rails.application.config_for(:reversed)))
|
|
48
|
+
return true
|
|
49
|
+
rescue NameError, NoMethodError, StandardError
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
false
|
|
53
|
+
end
|
|
54
|
+
private_class_method :load_rails_time_zones
|
|
22
55
|
|
|
23
56
|
# Private
|
|
24
57
|
# Load the default TpCommon::Timezones::LIST_ZONES in timezones/config/timezones.yml
|
|
@@ -35,11 +68,43 @@ module TpCommon
|
|
|
35
68
|
raise "Could not load configuration. No such file - #{yaml}"
|
|
36
69
|
end
|
|
37
70
|
rescue Psych::SyntaxError => e
|
|
38
|
-
raise
|
|
39
|
-
|
|
40
|
-
|
|
71
|
+
raise <<~ERRMSG
|
|
72
|
+
YAML syntax error occurred while parsing #{yaml}.
|
|
73
|
+
Please note that YAML must be consistently indented using spaces. Tabs are not allowed.
|
|
74
|
+
Error: #{e.message}
|
|
75
|
+
ERRMSG
|
|
41
76
|
end
|
|
42
77
|
private_class_method :load_default_timezones
|
|
78
|
+
|
|
79
|
+
def self.load_default_reversed_timezones
|
|
80
|
+
file_path = File.join(File.dirname(__FILE__),"config/reversed.yml")
|
|
81
|
+
yaml = Pathname.new(file_path)
|
|
82
|
+
|
|
83
|
+
if yaml.exist?
|
|
84
|
+
require "erb"
|
|
85
|
+
(YAML.load(ERB.new(yaml.read).result) || {})["all_zones"] || {}
|
|
86
|
+
else
|
|
87
|
+
raise "Could not load configuration. No such file - #{yaml}"
|
|
88
|
+
end
|
|
89
|
+
rescue Psych::SyntaxError => e
|
|
90
|
+
raise <<~ERRMSG
|
|
91
|
+
YAML syntax error occurred while parsing #{yaml}.
|
|
92
|
+
Please note that YAML must be consistently indented using spaces. Tabs are not allowed.
|
|
93
|
+
Error: #{e.message}
|
|
94
|
+
ERRMSG
|
|
95
|
+
end
|
|
96
|
+
private_class_method :load_default_reversed_timezones
|
|
97
|
+
|
|
98
|
+
def self.reversed_time_zone_lookup_table(data_config)
|
|
99
|
+
data_config.inject({}) do |carry, (zone_key, list_zone)|
|
|
100
|
+
zone_key = zone_key.to_sym
|
|
101
|
+
list_zone.each do |zone_name|
|
|
102
|
+
carry[zone_name.downcase.to_sym] = zone_key
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
carry
|
|
106
|
+
end
|
|
107
|
+
end
|
|
43
108
|
end
|
|
44
109
|
end
|
|
45
110
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module TpCommon
|
|
2
|
+
module Timezones
|
|
3
|
+
module Reversed
|
|
4
|
+
def self.[](zone_name)
|
|
5
|
+
TpCommon::Timezones::REVERSED_LIST_ZONES[similar_key(zone_name).to_sym]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.similar_key(zone_name)
|
|
9
|
+
zone_name = zone_name.to_s.downcase
|
|
10
|
+
if zone_name =~ /^(gmt[-\+]\d+)\.\d+$/
|
|
11
|
+
zone_name.split('.').first
|
|
12
|
+
else
|
|
13
|
+
zone_name
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
private_class_method :similar_key
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# TpCommon::Timezones::Reversed['American Samoa']
|
data/lib/tp_common/version.rb
CHANGED
data/lib/tp_common.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tp_common
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TINYpulse Devops
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-09-
|
|
11
|
+
date: 2019-09-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -247,7 +247,9 @@ files:
|
|
|
247
247
|
- lib/tp_common/railtie.rb
|
|
248
248
|
- lib/tp_common/timezones.rb
|
|
249
249
|
- lib/tp_common/timezones/config.rb
|
|
250
|
+
- lib/tp_common/timezones/config/reversed.yml
|
|
250
251
|
- lib/tp_common/timezones/config/timezones.yml
|
|
252
|
+
- lib/tp_common/timezones/reversed.rb
|
|
251
253
|
- lib/tp_common/timezones/zone.rb
|
|
252
254
|
- lib/tp_common/version.rb
|
|
253
255
|
- tp_common.gemspec
|