TooTallNate / node-time

"time.h" bindings for Node.js
MIT License
381 stars 84 forks source link

Has anyone gotten this working on alpine linux? #94

Open bdentino opened 8 years ago

bdentino commented 8 years ago

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.

Yumonra07 commented 7 years ago

@bdentino I'm having the same issue. Did you get any further with this issue?

Yumonra07 commented 7 years ago

Running apk add --update tzdata and setting the TZ env variable to a valid timezone solves the issue.

dettoni commented 7 years ago

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.

jaydp17 commented 7 years ago

@TooTallNate I see that there has been a commit (2739eac5d5e11d47f4048af7711f68556ae893d4) regarding alpine. If it's working, can you please release a new version?

jaydp17 commented 7 years ago

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)
Ilhicas commented 7 years ago

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.

comster commented 6 years ago

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.