REBOL Developer Network

Time Zone Fix

Carl Sassenrath, CTO
REBOL Technologies
21-Nov-2006 17:26 GMT

Article #0005
Main page || Index || Prior Article [0004] || Next Article [0006] || 30 Comments || Send feedback

RAMBO Ticket #3822 reports a problem with REBOL timezone computation on Windows systems.

We would like to fix this problem in 2.7.1.

The root of the problem could be that REBOL uses the posix gmtime() and localtime() functions to compute the zone difference, even on Win32 systems. But this has not yet been confirmed as the problem.

Win32 provides the GetTimeZoneInformation() function for this, and REBOL 3.0 uses this code for it (this is in the open source part of REBOL 3.0):

/***********************************************************************
**
*/  void OS_Get_Time(REBOL_DAT *dat)
/*
**      Get the current system date and time.
**
***********************************************************************/
{
    SYSTEMTIME stime;
    TIME_ZONE_INFORMATION tzone;

    GetLocalTime(&stime);
    GetTimeZoneInformation(&tzone);

    dat->year = stime.wYear;
    dat->month = stime.wMonth;
    dat->day = stime.wDay;
    dat->time = stime.wHour * 3600 + stime.wMinute * 60 + stime.wSecond;
    dat->nano = 1000000 * stime.wMilliseconds;
    dat->zone = tzone.Bias;
}

So, a possible solution is to use this 3.0 code in 2.7.

The question for you: is the GetTimeZoneInformation() fast enough to be called each time a time is requested. Remember that all GUI events in REBOL are timestamped and will call this OS_Get_Time() function. Will it be fast enough?

Let me know what you think.

30 Comments

Updated 11-Sep-2009   -   Copyright 2006 Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code