So I'm not sure if this ever worked right or if time is just measured

differently in Germany, but NetworkTime was always setting my time 6 hours
ahead, no matter what time zone or whether I stored the time in local time or
GMT. Upon looking closer and doing some Googling I determined that the constant
Axel used for the number of seconds between 1900 and 2000 was off by 6 hours,
and that combined with the odd kUTCtoGMT constant resulted in the 6 hour
difference.

By just replacing the system_time_difference() function with a correct constant
for the number of seconds between 1900 and 1970 and getting rid of kUTCtoGMT it
now works for me (and at least one other person on #haiku-dev, thanks
kallisti5!) For those wondering NTP time is measured from 1900 hence the need
for this conversion.

I will now look into integrating this with the Time preflet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40103 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2011-01-04 06:18:51 +00:00
parent 0d791a3062
commit e853910af2

View File

@ -93,28 +93,13 @@ enum ntp_modes {
};
const uint32 kUTCtoGMT = 12 * 60 * 60;
uint32
seconds_system_difference(void)
{
const uint32 kYear2000 = 3155713200UL;
// that many seconds from year 1900 to 2000.
struct tm tm;
memset(&tm, 0, sizeof(struct tm));
tm.tm_mday = 1;
tm.tm_year = 100;
return kYear2000 - mktime(&tm);
}
const uint32 kSecondsBetween1900And1970 = 2208988800UL;
uint32
seconds_since_1900(void)
{
return seconds_system_difference() + real_time_clock();
return kSecondsBetween1900And1970 + real_time_clock();
}
@ -207,7 +192,7 @@ ntp_update_time(const char *hostname, Monitor *monitor)
return B_BAD_VALUE;
}
time_t now = message.transmit_timestamp.Integer() - seconds_system_difference() + kUTCtoGMT;
time_t now = message.transmit_timestamp.Integer() - kSecondsBetween1900And1970;
if (monitor) {
char buffer[64];