Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 0e99c27

Browse files
committed
Update cetoffset() and cettime().
This should fix sstime()
1 parent 7534be0 commit 0e99c27

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/General.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,24 @@ end
213213
* CET timezone.
214214
*
215215
* @since 0.1.0
216+
* @updated 1.3.1
216217
*
217218
* @returns {number} - CET offset in seconds
218219
--]]
219220
function cetoffset()
220-
return utcoffset() - tern(math.abs(os.date('*t').yday - 187) < 46, 7200, 3600)
221+
-- List taken from http://www.timeanddate.com/time/zone/germany/frankfurt
222+
local daylightDates = {
223+
[2013] = {90, 300},
224+
[2014] = {89, 299},
225+
[2015] = {88, 298},
226+
[2016] = {87, 304},
227+
[2017] = {85, 302}
228+
}
229+
230+
local now = os.date('!*t')
231+
local daylightDate = daylightDates[now.year]
232+
233+
return utcoffset() + tern(now.yday >= daylightDate[1] and now.yday <= daylightDate[2], 7200, 3600)
221234
end
222235

223236
--[[
@@ -235,12 +248,12 @@ end
235248
* Returns the current time of day, in seconds, on CET timezone.
236249
*
237250
* @since 0.1.0
238-
* @modified 1.0.2
251+
* @updated 1.3.1
239252
*
240253
* @returns {number} - CET time of day in seconds
241254
--]]
242255
function cettime()
243-
return tosec(os.date('!%X')) + tern(math.abs(os.date('*t').yday - 187) < 46, 7200, 3600)
256+
return utctime() - utcoffset() + cetoffset()
244257
end
245258

246259
--[[

0 commit comments

Comments
 (0)