Project

General

Profile

Actions

Bug #1854

closed

timegm() works incorrect

Added by Roman Strashkin over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2011-12-04
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

test code:

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

int main (void) {

    struct tm Tm; 
    time_t time;

    strptime("Sun, 04 Dec 2011 13:09:43 GMT", "%a, %d %b %Y %H:%M:%S %Z", &Tm);
    time = timegm(&Tm);
    printf("Time1: %d\n", time);

    strptime("Sun, 04 Dec 2011 17:09:43 MSK", "%a, %d %b %Y %H:%M:%S %Z", &Tm);
    time = mktime(&Tm);
    printf("Time2: %d\n", time);
}

Result:

# ./test
Time1: 1323018583
Time2: 1323004183

As you can see timegm() returns seconds from the Epoch, with correction to local TZ, that is incorrect.

Result of same code, which compiled and started on Linux:

# ./test
Time1: 1323004183
Time2: 1323004183

Actions #1

Updated by Vitaliy Gusev over 11 years ago

  • Assignee set to Vitaliy Gusev
Actions #2

Updated by Vitaliy Gusev over 11 years ago

It is a strptime() issue. It does convert to locale's timezone if "GMT" specifier is in format.

Actions #3

Updated by Vitaliy Gusev over 11 years ago

  • Status changed from New to Closed

WONTFIX

Actions #4

Updated by Vitaliy Gusev over 11 years ago

As Garrett said "behavior is correct".

Actions

Also available in: Atom PDF