strftime improvements

Corinna Vinschen
Wed Feb 23 22:26:00 GMT 2005

On Feb 23 14:21, Jeff Johnston wrote:
> Sorry for the delay.  I just checked in a patch.  I put the types in time.h 

No worries.  Thank you for doing this!

> near the declaration of _tzset_r.  I also added a new function 
> __gettzinfo() which gets access to some variables that were previously 
> declared global and are used by the other time functions.  For example, the 
> __tzrule array.  I changed _timezone in _tzset_r to be long as requested in 
> another post.  For Cygwin, I left it asis as I imagine you will have to 
> change it on the other side as well. If you are ok with making _timezone 
>  long, just change libc/include/time.h and remove the added flag.

Ok, I changed the Cygwin part which is now using __gettzinfo() as well.
I've changed the Cygwin definition of _timezone to long so I've dropped
the #ifdef __CYGWIN__ part from libc/include/time.h.

> I noted that for Cygwin you #define timezone to be ((long int)_timezone) in 
> certain instances.  This has a problem in that elsewhere there is a struct 
> timezone declared (reent.h).

Yeeezzz.  I've changed the definition in libc/include/time.h to

#ifndef timezone
#define timezone _timezone

but that won't help very much.

There's something fishy.  POSIX requires that `timezone', `daylight' and
`tzname' are defined as variables.  While libc/include/time.h defines tzname
globally, it only defines daylight and timezone if __CYGWIN__ is defined.
That seems wrong for any non-Cygwin target.

Cygwin OTOH suffers from the existence of an exported function timezone().
I have not the faintest idea why this has been defined (back in 1996 or so)
since I don't recall that a timezone() function was ever defined in some

Usually, timezone is defined as the function, unless timezonevar has been
explicitely defined by the application.  So usually there's no namespace
clash between timezone, the function and timezone, the struct name.  The
only no-no in Cygwin is to #include <sys/time.h> after #include <time.h>
if the application #define's timezonevar.

I would love to get rid of the timezone function and instead have a clean
and simple definition of long timezone, but that's not possible otherwise
we'd break backward compatibility.  Sigh.


Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.

More information about the Newlib mailing list