delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/15/13:58:23

From: Eric Backus <ericb AT lsid DOT hp DOT com>
Subject: Re: DJGPP FAQ collection [was: DJGPP Memory Org. Docs?]
To: peter AT deakin DOT edu DOT au
Date: Tue, 15 Mar 94 10:28:10 PST
Cc: turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp, djgpp AT sun DOT soe DOT clarkson DOT edu
Mailer: Elm [revision: 70.85]

> I do not know if this is an FAQ but it is obscure enough given the lack of
> documentation on TZ in djgpp. I found this answer elsewhere (Borland C or SCO
> Xenix). 
> 
> Q. Using ctime() returns a crazy time. Why?
> A. Set TZ in the environment to "EST0EDT".
> 
> Q. Why does EST10EDT not work as expected?
> A. The clock is not set to GMT. 

Possible alternate answer: Eastern Standard Time is only five hours
away from GMT, so you should try EST5EDT?

Related topic:

Last I checked, there was an inconsistancy in DJGPP, between the time
functions in the C library (ctime(), etc.) and the time functions in
go32 (which uses Turbo C library calls).  This inconsistancy sometimes
causes an hour difference on things like file timestamps.  The root of
the problem is that Turbo C doesn't know about timezones, and makes
assumptions about daylight savings time, while the unix-like libc
functions try to be smart about timezones (using TZ) but are less
smart about daylight savings time.

On a real UNIX system, the libc functions use the TZ environment
variable to figure out the timezone, and look up information about
daylight savings time in a file (usually /usr/lib/tztab), so they know
exactly when to adjust the time by an hour.  DJGPP doesn't have this
file, so the libc functions don't know when daylight savings time
starts.

It is possible to set the TZ variable to a long complicated string
which tells the libc functions when daylight savings time starts.  The
symantics of this are messy, but on my machine I ended up with:

	TZ="PST8PDT,M4.1.0,M10.4.0"

This sets the timezone to PST, eight hours away from GMT.  The
daylight savings time timezone is PDT, which starts on Sunday of the
first week of April, and ends on Sunday of the fourth week of October.
--
				Eric Backus
				ericb AT lsid DOT hp DOT com
				(206) 335-2495

- Raw text -


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