delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/11/02/05:49:46

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:date:message-id:subject:from:to
:content-type; q=dns; s=default; b=fnxivM1RA1lJ1A0fS6GPf4bs2/Y0C
HVYNmh9k8tw5I5/onn8zGFGZSeqXEXeiwEv8DUsAsBTDAo76DF9guS9jdYXYde6D
QxByFX9D7nzIVLwovfJKE6EUpk43X167piO7DFia5+cFyIGuYKOxpIEuwDrOrf3l
C3fiWEJe3eDI9c=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:date:message-id:subject:from:to
:content-type; s=default; bh=l2rUrL36i+fxnNBvuMq7jRaeESw=; b=sB5
Slw1j8wIQI7uiFZ3IAhPpYAI++NjPyYARor/pnXJbBohaMYn3U1ytjFlhOrae/GX
GYwaPrHJvTILlXxF4f4JllM9ZE2B9Sp49Gdy2o9N5EPTmRqTZvjdI1Pq3rM/2ive
5uDhCze8c2t/F15zjquhXX8rnQ5ILF5zCqJ+viDA=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ig0-f172.google.com
MIME-Version: 1.0
X-Received: by 10.42.170.201 with SMTP id g9mr621189icz.76.1414925359407; Sun, 02 Nov 2014 02:49:19 -0800 (PST)
Date: Sun, 2 Nov 2014 13:49:19 +0300
Message-ID: <CAH+u25=E=8O9=KeAz585xkMnuJzFDcxFkcqGxLh-djqGVX+Dtg@mail.gmail.com>
Subject: Different (and wrong) timezones reported by both strftime(3) and date(1)
From: Egor Tensin <egor DOT tensin AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

Hello,

I've run into an issue of both strftime(3) and date(1) reporting
different (and wrong) timezones. I'm in the MSK timezone (switched
from +0400 to +0300 on 10/26/14). However, as of today, 11/2/14, the
following simple program

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

int main()
{
    char buf[128];
    time_t tt = time(NULL);
    tm* lt = localtime(&tt);
    strftime(&buf[0], 128, "%H:%M:%S%z\n", lt);
    printf("%s\n", buf);
    return 0;
}

outputs "14:10:00+0330". Both time and timezone here are wrong (it
should be "13:10:00+0300" instead, and Moscow is never in the "+0330"
timezone).

Running "date +'%H:%M:%S%z'" at the same time produces
"14:10:00+0400", which is better, since Moscow was in the "+0400"
timezone a week ago, but it still should be "13:10:00+0300" as in the
example above).

Curiously enough, `unset`ting the TZ environment variable fixes both
of these issues.

Anyway, I hope somebody will be able to fix this issue anytime.

Thanks,
Egor.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019