realbasic-plugins
[Top] [All Lists]

Re: getting the correct GMT offset for a given date

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: getting the correct GMT offset for a given date
From: Norman Palardy <palardyn at shaw dot ca>
Date: Fri, 25 Feb 2005 08:58:44 -0700
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
References: <c50bf8cff09ff90e409f5b976fe8e42d at shaw dot ca> <6FA5ED98-8743-11D9-944B-000A957CB4CC at desuetude dot com>

On Feb 25, 2005, at 8:39 AM, Charles Yeomans wrote:


On Feb 24, 2005, at 5:58 PM, Norman Palardy wrote:

Here I figured this would be easy to do but in Carbon I'm finding this is really a pain in the arse.

I've got code in XCode/CW that does this fine for Mach-O using the standard C libraries but Carbon has been driving me nuts. CW's libraries don't implement mktime in the same way as the Mach-O standard libraries so the same code doesn't work in CW and XCode

This code in XCode

        struct tm time_str;

        time_str.tm_year = (year - 1900);
        time_str.tm_mon = ( mon - 1);
        time_str.tm_mday = day;
        time_str.tm_hour = hour;
        time_str.tm_min = minute;
        time_str.tm_sec = seconds;
        time_str.tm_isdst = -1;

        mktime(&time_str) ;

        return tm_str.tm_gmtoff ;

works and gets me the right gmt offset even when DST is in effect seemingly all the time (or at least as well as can be had based on the vagaries of things like DST)

But trying to get the using Carbon calls ... well ... there's another matter. It's just not working for me and is always off by the gmt offset .... which if I could get that properly I could correct for ... you see my problem.

I really need to be able to display any given date as "2005-01-01 16:05:03 +TZOffset" but the correct +tzoffset varies of course.

Anyone got any code that can actually do this properly ?

I've got REALbasic code calling Core Foundation that does it properly.

Thanks.
Turns out that I had it in my head backwards and what I need to change is the code I posted above (which I've already done and it works just fine)

Too many hours at the keyboard I think

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>