Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Question on timezone offsets
I'm trying to resolve an apparent conflict between Solaris 9 and
FreeBSD 6.1. After calling localtime() the offsets returned have
opposite signs.

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

#ifdef sun
#define HAVE_DECL_ALTZONE 1
#else
#define HAVE_STRUCT_TM_TM_GMTOFF 1
#endif

#if HAVE_STRUCT_TM_TM_GMTOFF
inline time_t gmtOffset(const struct tm *t){ return t->tm_gmtoff; }
#elif HAVE_DECL_ALTZONE
extern time_t altzone;
inline time_t gmtOffset(const struct tm *t)
{ return (t->tm_isdst == 1) ? altzone : timezone; }
#endif

int main()
{
struct tm tms;
time_t t = time(0);
tms = *localtime(&t);
printf("tms.tm_gmtoff = %d\n", gmtOffset(&tms));
}

Solaris 9 prints 18000, while FreeBSD prints -18000 (I'm in
US/Central).

POSIX says that the offset component of a TZ variable value is east of
the Prime Meridian when the it has a negative sign, and west of it
when the sign is positive.

I don't see it define the offset received from localtime() though. I'd
expect it to be as defined for a TZ variable setting, but I can see
why negative would make sense in this case too, since localtime() goes
from UTC to local.

FreeBSD doesn't define the POSIX daylight or timezone variables, and
they have a timezone function which returns a character string, so it
doesn't look like FreeBSD is very standard in this regard.

Does POSIX define this somewhere, or is this in the realm of
implementation dependence?

Thanks

Joe

Report this thread to moderator Post Follow-up to this message
Old Post
joe@invalid.address
07-15-06 11:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:31 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.