Changeset 2747

Show
Ignore:
Timestamp:
11/06/07 16:15:40 (10 months ago)
Author:
prahal
Message:

Set timezone to Etc/UTC around mktime call in opensync_time.c osync_time_tm2vtime
to avoid applying DST of any local timezone to the unix timestamp converted value.
Add timezone (TZ) environment variable to check_time test_unix_converter to
have the test working reliably in any timezone.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/opensync/format/opensync_time.c

    r2368 r2747  
    288288        GString *vtime = g_string_new(""); 
    289289        struct tm my_time = *time; 
     290        const char *tz = NULL; 
    290291 
    291292        /* ask C library to clean up any anomalies */ 
     293        if (is_utc) { 
     294                tz = g_getenv("TZ"); 
     295                putenv("TZ=Etc/UTC"); 
     296        } 
    292297        mktime(&my_time); 
     298        if(is_utc) { 
     299                if (tz) { 
     300                        g_setenv("TZ", tz, TRUE); 
     301                } else { 
     302                        g_unsetenv("TZ"); 
     303                } 
     304        } 
    293305 
    294306        g_string_printf(vtime, "%04d%02d%02dT%02d%02d%02d", 
  • trunk/tests/format-tests/check_time.c

    r2529 r2747  
    163163        struct tm base; 
    164164 
     165 
     166        putenv("TZ=America/Montreal"); 
     167 
    165168        // simple test, no DST 
    166169        base.tm_sec = 0;