delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/12/14/19:57:26

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <6910a60712141657x1345ec00j9ea7d645bd516ce@mail.gmail.com>
Date: Fri, 14 Dec 2007 19:57:02 -0500
From: "Reini Urban" <rurban AT x-ray DOT at>
To: cygwin AT cygwin DOT com
Subject: Re: Timezone manipulation within Perl script
In-Reply-To: <9761.12995-16991-2031106093-1197667559@email.cz>
MIME-Version: 1.0
References: <9761 DOT 12995-16991-2031106093-1197667559 AT email DOT cz>
X-Google-Sender-Auth: 67a3c5f08f762dfa
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

2007/12/14, roman DOT vasicek AT email DOT cz <roman DOT vasicek AT email DOT cz>:
> Hi all,
> I want to ask you how convert time between different timezones in perl script running under cygwin. I have an application which store datetime information in Zulu/GMT. I need to provide date in user timezone. How to do the correct conversion? I want to be able to offer Timezone info like 'Europe/Prague'. Following code snippet will provide correct output when running under Active state Perl (time will differ 1 or 2 hours depending on input date), but when running under cygwin perl no conversion will be done. Can anyone help me?
>
>         $ENV{TZ}    = 'Zulu';
>         POSIX::tzset();
>         $time       = timegm($second, $minute, $hour, $day, $month, $year);
>
>         $ENV{TZ}    = 'Europe/Prague';
>         POSIX::tzset();
>         ($second, $minute, $hour, $day, $month, $year)   = POSIX::localtime($time);
>
> Attached program will produce under ActiveState PERL
>
>  Winter (delta should be +1 h)
>  ZULU : 2007-12-13 11:47:02 Zulu
>  LOCAL: 2007-12-13 12:47:02 Europe/Prague
>
>  Summer (delta should be +2 h)
>  ZULU : 2007-06-13 11:47:02 Zulu
>  LOCAL: 2007-06-13 13:47:02 Europe/Prague
>
> and under CygWin PERL output will be
>
>  Winter (delta should be +1 h)
>  ZULU : 2007-12-13 11:47:02 Zulu
>  LOCAL: 2007-12-13 11:47:02 Europe/Prague
>
>  Summer (delta should be +2 h)
>  ZULU : 2007-06-13 11:47:02 Zulu
>  LOCAL: 2007-06-13 11:47:02 Europe/Prague

Interesting. For me the standard cygwin perl works okay.

$ perl test-1.pl

Winter (delta should be +1 h)
ZULU : 2007-12-13 11:47:02 Zulu
LOCAL: 2007-12-13 12:47:02 Europe/Prague

Summer (delta should be +2 h)
ZULU : 2007-06-13 11:47:02 Zulu
LOCAL: 2007-06-13 13:47:02 Europe/Prague

$ printenv TZ

Windows XP, currently in the GMT-5 timezone
-- 
Reini Urban

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

- Raw text -


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