Has anyone gotten this working on alpine linux?
bdentino opened this issue ยท 7 comments
Having trouble running a node app that uses this library in an alpine-based docker container, as I'm getting the 'unknown timezone' error. Debug output shows it's trying to find a proper zoneinfo directory and failing to do so. Most likely because of this: https://wiki.alpinelinux.org/wiki/Alpine_Linux:FAQ#How_do_I_set_the_local_timezone.3F
Is there any chance of this being supportable on alpine? I'd submit a PR if someone could point me in the right direction, but not sure if it's even feasible without significant rewrites.
Running apk add --update tzdata
and setting the TZ
env variable to a valid timezone solves the issue.
We tried to use use here on Alpine and find out that tzset has different results between musl glibc (alpine) and ubuntu glibc.
#include <stdio.h>
#include <time.h>
void main()
{
tzset();
printf("daylight = %d tz[0] = [%s] tz[1] = [%s] timezone = [%ld]\n", daylight, tzname[0], tzname[1], timezone);
}
This simple snippet will print:
tzname[1] = tzname[0]
for Ubuntu in time zones without Daylight Saving Time.
tzname[1] = ""
for Alpine in time zones without Daylight Saving Time.
When the time zone has Daylight Saving Time, it will return the name for the time zone when Daylight Saving Time is in use for both.
Based on this link, I believe that musl glibc is correct and you should not use tzname[1] to validate the time zone, but I am not sure about this.
@TooTallNate I see that there has been a commit (2739eac) regarding alpine.
If it's working, can you please release a new version?
That commit doesn't seem to fix the issue.
@TooTallNate here's the debug ouput I get on alpine
time Date#setTimezone(UTC, undefined) +21s
time current timezone is not "UTC", calling tzset() +1ms
time set the current timezone to: +0ms UTC
time got bad zoneinfo object: +0ms { tzname: [ 'UTC', '' ], timezone: 0, daylight: 0 }
Error: Unknown Timezone: 'UTC'
at Function.tzset (/src/node_modules/time/index.js:160:15)
This is not related to this library, node or other languages, for some reason someone thumbed down @Yumonra07 answer, on install tzdata, and that solves the issue, on other languages as well such as python for instance.
Hey guys,
This issue is still open it seems? My best attempt at the previous two solutions didn't seem to work for me, still getting the 'unknown timezone' error for UTC.