[tz] Adapting localtime.c
Brian Inglis
Brian.Inglis at Shaw.ca
Sun Oct 9 02:59:17 UTC 2016
On 2016-10-08 13:46, Carsten Larsen wrote:
> Den 08-10-2016 kl. 20:03 skrev Random832:
>> On Sat, Oct 8, 2016, at 13:27, Carsten Larsen wrote:
>>> Hello list
>>>
>>> I am trying to adapt the tz code to a local system without any timezone
>>> database (AmigaOS). I got the code up and running and everything seems
>>> to work as intended. But one thing about the code puzzles me.
>>>
>>> I need to implement "time_t time(time_t *p)" which is the very last part
>>> of localtime.c. Should this code return time as local time or as GMT
>>> time ? Because I cannot get the time calculations to work properly.
>>
>> This function returns the current time as a time_t. On Windows and
>> Unix-like systems, this is UTC seconds since midnight of January 1,
>> 1970.
>>
>> Does AmigaOS not already have such a function? There's no implementation
>> in tzcode because it's expected to already exist as part of a lower
>> level of the C runtime library (and historically it was a direct system
>> call to the Unix kernel)
>
> AmigaOS uses an Epoch of January 1, 1978, 00:00:00 instead of January 1, 1970, 00:00:00 UTC. Time zone is not specified.
>
> The Epoch difference is easy to calculate. 2 leap years and 6 normal. No leap seconds:
>
> 2922 is the number of days between 1.1.1970 and 1.1.1978
> 2922 * 24 * 60 * 60 = 252460800
>
>> What is the native format of the system time? What are you doing to
>> determine what the actual time is?
>
> The actual time is is number of seconds since 1.1.1978 and possibly a
> GMT offset (if the user have bothered to set it. The system does not take it into consideration). There is no concept of daylight saving rules and no concept of UTC.
>
> I guess I need to determine the exact point of January 1, 1970, 00:00:00 *UTC* on my (AmigaOS) timeline in order to use the time.h functions in tz, and I assume the TZ variable and tz code can help me to do so. Right ?
POSIX Base Definitions 4.16 Seconds Since the Epoch gives the calculation in
POSIX time (UTC ignoring leap seconds):
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_16
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
More information about the tz
mailing list