From 1d47e3aa120539e053ffa41293f3f756b9d07844 Mon Sep 17 00:00:00 2001 From: mattkae Date: Sun, 16 Jan 2022 18:32:50 -0500 Subject: Successful beginnings of the winter theme --- themes/dist/output.js | 103 +++++++++++++++++++++++++++++++++++++++++++++--- themes/dist/output.wasm | Bin 66787 -> 82223 bytes 2 files changed, 97 insertions(+), 6 deletions(-) (limited to 'themes/dist') diff --git a/themes/dist/output.js b/themes/dist/output.js index 9a83997..9eb0f70 100644 --- a/themes/dist/output.js +++ b/themes/dist/output.js @@ -1835,6 +1835,82 @@ var ASM_CONSTS = { return demangleAll(js); } + function _tzset_impl() { + var currentYear = new Date().getFullYear(); + var winter = new Date(currentYear, 0, 1); + var summer = new Date(currentYear, 6, 1); + var winterOffset = winter.getTimezoneOffset(); + var summerOffset = summer.getTimezoneOffset(); + + // Local standard timezone offset. Local standard time is not adjusted for daylight savings. + // This code uses the fact that getTimezoneOffset returns a greater value during Standard Time versus Daylight Saving Time (DST). + // Thus it determines the expected output during Standard Time, and it compares whether the output of the given date the same (Standard) or less (DST). + var stdTimezoneOffset = Math.max(winterOffset, summerOffset); + + // timezone is specified as seconds west of UTC ("The external variable + // `timezone` shall be set to the difference, in seconds, between + // Coordinated Universal Time (UTC) and local standard time."), the same + // as returned by stdTimezoneOffset. + // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html + HEAP32[((__get_timezone())>>2)] = stdTimezoneOffset * 60; + + HEAP32[((__get_daylight())>>2)] = Number(winterOffset != summerOffset); + + function extractZone(date) { + var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/); + return match ? match[1] : "GMT"; + }; + var winterName = extractZone(winter); + var summerName = extractZone(summer); + var winterNamePtr = allocateUTF8(winterName); + var summerNamePtr = allocateUTF8(summerName); + if (summerOffset < winterOffset) { + // Northern hemisphere + HEAP32[((__get_tzname())>>2)] = winterNamePtr; + HEAP32[(((__get_tzname())+(4))>>2)] = summerNamePtr; + } else { + HEAP32[((__get_tzname())>>2)] = summerNamePtr; + HEAP32[(((__get_tzname())+(4))>>2)] = winterNamePtr; + } + } + function _tzset() { + // TODO: Use (malleable) environment variables instead of system settings. + if (_tzset.called) return; + _tzset.called = true; + _tzset_impl(); + } + function _localtime_r(time, tmPtr) { + _tzset(); + var date = new Date(HEAP32[((time)>>2)]*1000); + HEAP32[((tmPtr)>>2)] = date.getSeconds(); + HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes(); + HEAP32[(((tmPtr)+(8))>>2)] = date.getHours(); + HEAP32[(((tmPtr)+(12))>>2)] = date.getDate(); + HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth(); + HEAP32[(((tmPtr)+(20))>>2)] = date.getFullYear()-1900; + HEAP32[(((tmPtr)+(24))>>2)] = date.getDay(); + + var start = new Date(date.getFullYear(), 0, 1); + var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0; + HEAP32[(((tmPtr)+(28))>>2)] = yday; + HEAP32[(((tmPtr)+(36))>>2)] = -(date.getTimezoneOffset() * 60); + + // Attention: DST is in December in South, and some regions don't have DST at all. + var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset(); + var winterOffset = start.getTimezoneOffset(); + var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0; + HEAP32[(((tmPtr)+(32))>>2)] = dst; + + var zonePtr = HEAP32[(((__get_tzname())+(dst ? 4 : 0))>>2)]; + HEAP32[(((tmPtr)+(40))>>2)] = zonePtr; + + return tmPtr; + } + function ___localtime_r(a0,a1 + ) { + return _localtime_r(a0,a1); + } + function _abort() { abort('native code called abort()'); } @@ -3017,6 +3093,10 @@ var ASM_CONSTS = { GLctx.currentProgram = program; } + function _glVertexAttribDivisor(index, divisor) { + GLctx['vertexAttribDivisor'](index, divisor); + } + function _glVertexAttribPointer(index, size, type, normalized, stride, ptr) { var cb = GL.currentContext.clientBuffers[index]; if (!GLctx.currentArrayBufferBinding) { @@ -3083,6 +3163,7 @@ function intArrayToString(array) { var asmLibraryArg = { + "__localtime_r": ___localtime_r, "abort": _abort, "emscripten_get_element_css_size": _emscripten_get_element_css_size, "emscripten_memcpy_big": _emscripten_memcpy_big, @@ -3130,6 +3211,7 @@ var asmLibraryArg = { "glShaderSource": _glShaderSource, "glUniformMatrix4fv": _glUniformMatrix4fv, "glUseProgram": _glUseProgram, + "glVertexAttribDivisor": _glVertexAttribDivisor, "glVertexAttribPointer": _glVertexAttribPointer, "setTempRet0": _setTempRet0, "time": _time @@ -3141,12 +3223,27 @@ var ___wasm_call_ctors = Module["___wasm_call_ctors"] = createExportWrapper("__w /** @type {function(...*):?} */ var _main = Module["_main"] = createExportWrapper("main"); +/** @type {function(...*):?} */ +var _free = Module["_free"] = createExportWrapper("free"); + +/** @type {function(...*):?} */ +var _malloc = Module["_malloc"] = createExportWrapper("malloc"); + /** @type {function(...*):?} */ var ___errno_location = Module["___errno_location"] = createExportWrapper("__errno_location"); /** @type {function(...*):?} */ var _fflush = Module["_fflush"] = createExportWrapper("fflush"); +/** @type {function(...*):?} */ +var __get_tzname = Module["__get_tzname"] = createExportWrapper("_get_tzname"); + +/** @type {function(...*):?} */ +var __get_daylight = Module["__get_daylight"] = createExportWrapper("_get_daylight"); + +/** @type {function(...*):?} */ +var __get_timezone = Module["__get_timezone"] = createExportWrapper("_get_timezone"); + /** @type {function(...*):?} */ var stackSave = Module["stackSave"] = createExportWrapper("stackSave"); @@ -3171,12 +3268,6 @@ var _emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = function() return (_emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments); }; -/** @type {function(...*):?} */ -var _malloc = Module["_malloc"] = createExportWrapper("malloc"); - -/** @type {function(...*):?} */ -var _free = Module["_free"] = createExportWrapper("free"); - /** @type {function(...*):?} */ var dynCall_jiji = Module["dynCall_jiji"] = createExportWrapper("dynCall_jiji"); diff --git a/themes/dist/output.wasm b/themes/dist/output.wasm index 495ea67..427f834 100755 Binary files a/themes/dist/output.wasm and b/themes/dist/output.wasm differ -- cgit v1.2.1