|
I've tried to follow the advice given by Ulf Wiger in this old thread:
http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html However, it doesn't work for me: aromanov@alexey-desktop:~/workspace/gmcontroller$ erl Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.1 (abort with ^G) 1> os:getenv("TZ"). false 2> time(). {17,49,40} 3> os:putenv("TZ", "GMT"). true 4> os:getenv("TZ"). "GMT" 5> time(). {17,50,8} Am I doing something wrong? Setting TZ in the shell does work (but isn't suitable for my purposes): aromanov@alexey-desktop:~/workspace/gmcontroller$ TZ=GMT erl Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.1 (abort with ^G) 1> os:getenv("TZ"). "GMT" 2> time(). {14,50,39} Yours, Alexey Romanov ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
Hmm… At least it works on my Macbook: uwiger$ erl Erlang R14B (erts-5.8.1) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.1 (abort with ^G) 1> os:getenv("TZ"). false 2> time(). {16,42,42} 3> os:putenv("TZ","GMT"). true 4> time(). {15,43,2} 5> os:putenv("TZ","EST"). true 6> time(). {10,43,33} BR, Ulf W On 2 Dec 2010, at 15:59, Alexey Romanov wrote: > I've tried to follow the advice given by Ulf Wiger in this old thread: > http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html > > However, it doesn't work for me: > > aromanov@alexey-desktop:~/workspace/gmcontroller$ erl > Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.8.1 (abort with ^G) > 1> os:getenv("TZ"). > false > 2> time(). > {17,49,40} > 3> os:putenv("TZ", "GMT"). > true > 4> os:getenv("TZ"). > "GMT" > 5> time(). > {17,50,8} > > Am I doing something wrong? > > Setting TZ in the shell does work (but isn't suitable for my purposes): > > aromanov@alexey-desktop:~/workspace/gmcontroller$ TZ=GMT erl > Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.8.1 (abort with ^G) > 1> os:getenv("TZ"). > "GMT" > 2> time(). > {14,50,39} > > Yours, Alexey Romanov > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:[hidden email] > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
In reply to this post by Alexey Romanov
Out of curiosity, do you need to change the timezone at runtime?
Otherwise the shell shook be fine. I use the shell approach to force Zotonic into EST. If you need runtime timezone handling I recommend using GMT and putting in a dispay module to convert to the timezone needed by the current process. Otherwise you could get strange behavior when otwo process change the global timezone and get muddled in context switching. On Thursday, December 2, 2010, Alexey Romanov <[hidden email]> wrote: > I've tried to follow the advice given by Ulf Wiger in this old thread: > http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html > > However, it doesn't work for me: > > aromanov@alexey-desktop:~/workspace/gmcontroller$ erl > Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.8.1 (abort with ^G) > 1> os:getenv("TZ"). > false > 2> time(). > {17,49,40} > 3> os:putenv("TZ", "GMT"). > true > 4> os:getenv("TZ"). > "GMT" > 5> time(). > {17,50,8} > > Am I doing something wrong? > > Setting TZ in the shell does work (but isn't suitable for my purposes): > > aromanov@alexey-desktop:~/workspace/gmcontroller$ TZ=GMT erl > Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.8.1 (abort with ^G) > 1> os:getenv("TZ"). > "GMT" > 2> time(). > {14,50,39} > > Yours, Alexey Romanov > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:[hidden email] > > ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
In reply to this post by Ulf Wiger
# Ulf Wiger 2010-12-02:
> Hmm… > > At least it works on my Macbook: [... it works ...] Well, localtime(3) is specified (in POSIX.1) to behave as if it calls tzset(3) every time, but no such promise is made for localtime_r(3). So on some platforms that provide localtime_r(3), the tzset(3) call in erts/emulator/sys/unix/sys.c:erl_sys_init() may be the only time TZ variable is ever taken into consideration. Unfortunately, there doesn't seem to be a standard API for conversions between different timezones in the C library -- it has zoneinfo around and enough functions to process it, but is simply too greedy to export that functionaly. Not that this actually helps anyone, but perhaps it explains different behaviours on different platforms... Regards, -- Jachym ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
On Thu, Dec 2, 2010 at 10:46 PM, Jachym Holecek <[hidden email]> wrote:
> # Ulf Wiger 2010-12-02: >> Hmm… >> >> At least it works on my Macbook: [... it works ...] > > Well, localtime(3) is specified (in POSIX.1) to behave as if it calls > tzset(3) every time, but no such promise is made for localtime_r(3). > So on some platforms that provide localtime_r(3), the tzset(3) call > in erts/emulator/sys/unix/sys.c:erl_sys_init() may be the only time > TZ variable is ever taken into consideration. > > Unfortunately, there doesn't seem to be a standard API for conversions > between different timezones in the C library -- it has zoneinfo around > and enough functions to process it, but is simply too greedy to export > that functionaly. > > Not that this actually helps anyone, but perhaps it explains different > behaviours on different platforms... (Initially sent off the list) Actually, it does: it suggests it should be enough to write a program in C which calls tzset(3) and call it through a port... > Regards, > -- Jachym > -- Yours, Alexey Romanov ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
In reply to this post by Alain O'Dea
On Thu, Dec 2, 2010 at 8:13 PM, Alain O'Dea <[hidden email]> wrote:
> Out of curiosity, do you need to change the timezone at runtime? Yes. The requirement probably could be worked around (e.g. by restarting the system when the timezone changes) but it would be better if I can avoid this. > Otherwise the shell shook be fine. I use the shell approach to force > Zotonic into EST. > > If you need runtime timezone handling I recommend using GMT and > putting in a dispay module to convert to the timezone needed by the > current process. Otherwise you could get strange behavior when otwo > process change the global timezone and get muddled in context > switching. Ah no, I need precisely to handle actual timezone change (the system only finds at runtime what timezone it's in by asking a server...) > On Thursday, December 2, 2010, Alexey Romanov > <[hidden email]> wrote: >> I've tried to follow the advice given by Ulf Wiger in this old thread: >> http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html >> >> However, it doesn't work for me: >> >> aromanov@alexey-desktop:~/workspace/gmcontroller$ erl >> Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] >> [hipe] [kernel-poll:false] >> >> Eshell V5.8.1 (abort with ^G) >> 1> os:getenv("TZ"). >> false >> 2> time(). >> {17,49,40} >> 3> os:putenv("TZ", "GMT"). >> true >> 4> os:getenv("TZ"). >> "GMT" >> 5> time(). >> {17,50,8} >> >> Am I doing something wrong? >> >> Setting TZ in the shell does work (but isn't suitable for my purposes): >> >> aromanov@alexey-desktop:~/workspace/gmcontroller$ TZ=GMT erl >> Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] >> [hipe] [kernel-poll:false] >> >> Eshell V5.8.1 (abort with ^G) >> 1> os:getenv("TZ"). >> "GMT" >> 2> time(). >> {14,50,39} >> >> Yours, Alexey Romanov >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:[hidden email] >> >> > -- Yours, Alexey Romanov ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
In reply to this post by Alexey Romanov
On Thu, Dec 2, 2010 at 3:29 PM, Alexey Romanov
<[hidden email]>wrote: > On Thu, Dec 2, 2010 at 10:46 PM, Jachym Holecek <[hidden email]> wrote: > > # Ulf Wiger 2010-12-02: > >> Hmm… > >> > >> At least it works on my Macbook: [... it works ...] > > > > Well, localtime(3) is specified (in POSIX.1) to behave as if it calls > > tzset(3) every time, but no such promise is made for localtime_r(3). > > So on some platforms that provide localtime_r(3), the tzset(3) call > > in erts/emulator/sys/unix/sys.c:erl_sys_init() may be the only time > > TZ variable is ever taken into consideration. > > > > Unfortunately, there doesn't seem to be a standard API for conversions > > between different timezones in the C library -- it has zoneinfo around > > and enough functions to process it, but is simply too greedy to export > > that functionaly. > > > > Not that this actually helps anyone, but perhaps it explains different > > behaviours on different platforms... > > (Initially sent off the list) Actually, it does: it suggests it should > be enough to write a program in C which calls tzset(3) and call it > through a port... > It's not, really... In general you cannot convert local time to universal time in unambiguous way using POSIX calls... At least twice a year in DST environment :) As mentioned above, timezone info functions are not exported in glibc... > > > Regards, > > -- Jachym > > > > > > -- > Yours, Alexey Romanov > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:[hidden email] > > |
|
In reply to this post by Alexey Romanov
On Thursday, December 2, 2010, Alexey Romanov
<[hidden email]> wrote: > On Thu, Dec 2, 2010 at 8:13 PM, Alain O'Dea <[hidden email]> wrote: >> Out of curiosity, do you need to change the timezone at runtime? > > Yes. The requirement probably could be worked around (e.g. by > restarting the system when the timezone changes) but it would be > better if I can avoid this. > >> Otherwise the shell shook be fine. I use the shell approach to force >> Zotonic into EST. >> >> If you need runtime timezone handling I recommend using GMT and >> putting in a dispay module to convert to the timezone needed by the >> current process. Otherwise you could get strange behavior when otwo >> process change the global timezone and get muddled in context >> switching. > > Ah no, I need precisely to handle actual timezone change (the system > only finds at runtime what timezone it's in by asking a server...) This sounds like a one-time or synchronized operation so I see no issue with os:setenv("TZ",...) for that :) > >> On Thursday, December 2, 2010, Alexey Romanov >> <[hidden email]> wrote: >>> I've tried to follow the advice given by Ulf Wiger in this old thread: >>> http://www.erlang.org/pipermail/erlang-questions/2006-December/024291.html >>> >>> However, it doesn't work for me: >>> >>> aromanov@alexey-desktop:~/workspace/gmcontroller$ erl >>> Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] >>> [hipe] [kernel-poll:false] >>> >>> Eshell V5.8.1 (abort with ^G) >>> 1> os:getenv("TZ"). >>> false >>> 2> time(). >>> {17,49,40} >>> 3> os:putenv("TZ", "GMT"). >>> true >>> 4> os:getenv("TZ"). >>> "GMT" >>> 5> time(). >>> {17,50,8} >>> >>> Am I doing something wrong? >>> >>> Setting TZ in the shell does work (but isn't suitable for my purposes): >>> >>> aromanov@alexey-desktop:~/workspace/gmcontroller$ TZ=GMT erl >>> Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] >>> [hipe] [kernel-poll:false] >>> >>> Eshell V5.8.1 (abort with ^G) >>> 1> os:getenv("TZ"). >>> "GMT" >>> 2> time(). >>> {14,50,39} >>> >>> Yours, Alexey Romanov >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:[hidden email] >>> >>> >> > > > > -- > Yours, Alexey Romanov > ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
On 3 Dec 2010, at 05:19, Alain O'Dea wrote: > On Thursday, December 2, 2010, Alexey Romanov >> >> Ah no, I need precisely to handle actual timezone change (the system >> only finds at runtime what timezone it's in by asking a server...) > > This sounds like a one-time or synchronized operation so I see no > issue with os:setenv("TZ",...) for that :) So, the original advice came from the AXD 301 days, where we had to deal with timezone and DST issues in a non-stop system. Running on Solaris, at the time, updating the zoneinfo files was an OS patch each time, and there were ca 200 different settings. Timezone is relatively straightforward - at least the AXD 301 tended not to move once brought into service, but DST is really a PITA; some countries decide through parlamentary decision when it's supposed to happen each year, and others have different rules for years with presidential elections… Also, we needed to get the time representation in logs correct (i.e. correct localtime) - not just the time presented in the GUI. Granted, it was early days for OTP, so some of our issues have long-since been fixed. Initially, there was no erlang:universaltime(), and if the OS time changed to DST, this would affect erlang:now() and all timers in the system, so we set the system clock to UST and tweaked the TZ variable from within Erlang. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
|
And remember we've already got another PITA called the leap seconds.
(Note: POSIX intentionally *ignores* the leap seconds at all. Fortunately this has been properly handed in Erlang since R14B.) Kenji Rikitake still running my FreeBSD servers with djb's libtai In the message <[hidden email]> dated Fri, Dec 03, 2010 at 08:28:55AM +0100, Ulf Wiger <[hidden email]> writes: > So, the original advice came from the AXD 301 days, where we had to deal > with timezone and DST issues in a non-stop system. Running on Solaris, > at the time, updating the zoneinfo files was an OS patch each time, and there > were ca 200 different settings. Timezone is relatively straightforward - at least > the AXD 301 tended not to move once brought into service, but DST is really > a PITA; some countries decide through parlamentary decision when it's > supposed to happen each year, and others have different rules for years > with presidential elections… > > Also, we needed to get the time representation in logs correct (i.e. correct > localtime) - not just the time presented in the GUI. > > Granted, it was early days for OTP, so some of our issues have long-since > been fixed. Initially, there was no erlang:universaltime(), and if the OS time > changed to DST, this would affect erlang:now() and all timers in the system, > so we set the system clock to UST and tweaked the TZ variable from within Erlang. > > BR, > Ulf W ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:[hidden email] |
| Powered by Nabble | Edit this page |
