[tz] Adapting localtime.c
Carsten Larsen
cs at innolan.dk
Sat Oct 8 19:46:39 UTC 2016
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 ?
Kind regard
Carsten Larsen
More information about the tz
mailing list