cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.11k stars 604 forks source link

Ruby: Incorrect utc offset #526

Open syuu1228 opened 10 years ago

syuu1228 commented 10 years ago

On C program, OSv provides correct utc offset. For example:

#include <stdio.h>
#include <time.h>

void main(void)
{
    time_t timer;
    struct tm *date;
    char str[256];

    timer = time(NULL);
    date = localtime(&timer);
    strftime(str, 255, "%Y, %B, %d, %A %p%I:%M:%S %z", date);
    printf("%s\n", str);
}

will output correct utc offset with TZ param:

$ ./scripts/run.py -e "--env=TZ=JST-9 /a.out"
OSv v0.13-76-g1033d7e
eth0: 192.168.122.15
2014, October, 22, Wednesday AM04:32:45 +0900

However, in Ruby Time class returns localtime with +0000 utc offset.

$ ./scripts/run.py -e "--env=TZ=JST-9 /ruby.so /irb"
OSv v0.13-76-g1033d7e
eth0: 192.168.122.15
sigaltstack() stubbed
irb(main):001:0> __sigsetjmp() stubbed
Time.now
=> 2014-10-22 04:34:07 +0000

It looks like implementing their original strftime, probably Ruby does not able to receive correct utc offset in the implementation.

penberg commented 10 years ago

@nyh Does this ring a bell to you?