Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Fri, 26 Oct 2012 09:57:37 +0200
From: Yoran Heling <>
Subject: localtime() isn't local


I noticed that the localtime() function is equivalent to gmtime() on my
system. Following example illustrates the problem:

  $ cat localtime.c

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

  int main(int argc, char **argv) {
    char local[16], global[16];
    time_t tm = time(NULL);
    strftime(local, 10, "%H:%M:%S ", localtime(&tm));
    strftime(global, 10, "%H:%M:%S ", gmtime(&tm));
    printf("Local:  %s\nGlobal: %s\n", local, global);
    return 0;

  $ musl-gcc localtime.c -o localtime-musl
  $ gcc localtime.c -o localtime-glibc
  $ ./localtime-musl
  Local:  07:53:47 
  Global: 07:53:47
  $ ./localtime-glibc
  Local:  09:53:50 
  Global: 07:53:50
  $ date
  Fri Oct 26 09:53:51 CEST 2012

This is on Arch Linux x86_64 with musl v0.9.6-88-g607b05a (that is, the
current git master).


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.