From a096bb6509694fd2788ad557b6843ce5727de14e Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 16 Aug 2010 21:17:57 +0000 Subject: [PATCH] * adjust Time preflet to write only the name of the timezone into libroot_timezone_info (will change again, soon) * when formatting the preview/current time, the difference between old and new timezone offset has to be taken into account if the RTC is set to local time git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38163 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/time/ZoneView.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/preferences/time/ZoneView.cpp b/src/preferences/time/ZoneView.cpp index 972b4e96a6..f5eaef9829 100644 --- a/src/preferences/time/ZoneView.cpp +++ b/src/preferences/time/ZoneView.cpp @@ -36,7 +36,6 @@ #include #include -#include #include #include @@ -367,20 +366,13 @@ TimeZoneView::_SetSystemTimeZone() status_t status = find_directory(B_COMMON_SETTINGS_DIRECTORY, &path, true); BFile file; if (status == B_OK) { - path.Append(BPrivate::skPosixTimeZoneInfoFile); + path.Append("libroot_timezone_info"); status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY); } if (status == B_OK) { - BPrivate::time_zone_info tzInfo; - tzInfo.offset_from_gmt = timeZone.OffsetFromGMT(); - tzInfo.uses_daylight_saving = timeZone.SupportsDaylightSaving(); - strlcpy(tzInfo.short_std_name, timeZone.ShortName().String(), - BPrivate::skTimeZoneInfoNameMax); - strlcpy(tzInfo.short_dst_name, - timeZone.ShortDaylightSavingName().String(), - BPrivate::skTimeZoneInfoNameMax); - file.Write(&tzInfo, sizeof(tzInfo)); + const BString& timeZoneID = timeZone.Code(); + file.Write(timeZoneID.String(), timeZoneID.Length()); file.Sync(); } @@ -398,10 +390,15 @@ TimeZoneView::_FormatTime(TimeZoneListItem* zoneItem) if (zoneItem == NULL) return result; - time_t nowInTimeZone = time(NULL) + zoneItem->OffsetFromGMT(); BLocale locale; be_locale_roster->GetDefaultLocale(&locale); - locale.FormatTime(&result, nowInTimeZone, false); + time_t now = time(NULL); + bool rtcIsGMT; + _kern_get_real_time_clock_is_gmt(&rtcIsGMT); + if (!rtcIsGMT) { + now -= zoneItem->OffsetFromGMT() - fCurrentZoneItem->OffsetFromGMT(); + } + locale.FormatTime(&result, now, false, &zoneItem->TimeZone()); return result; }