[haiku-commits] r38163 - haiku/trunk/src/preferences/time

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Aug 2010 23:17:57 +0200 (CEST)

Author: zooey
Date: 2010-08-16 23:17:57 +0200 (Mon, 16 Aug 2010)
New Revision: 38163
Changeset: http://dev.haiku-os.org/changeset/38163

Modified:
   haiku/trunk/src/preferences/time/ZoneView.cpp
Log:
* 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

Modified: haiku/trunk/src/preferences/time/ZoneView.cpp
===================================================================
--- haiku/trunk/src/preferences/time/ZoneView.cpp       2010-08-16 21:14:23 UTC 
(rev 38162)
+++ haiku/trunk/src/preferences/time/ZoneView.cpp       2010-08-16 21:17:57 UTC 
(rev 38163)
@@ -36,7 +36,6 @@
 #include <View.h>
 #include <Window.h>
 
-#include <localtime.h>
 #include <syscalls.h>
 
 #include <unicode/datefmt.h>
@@ -367,20 +366,13 @@
        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 @@
        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;
 }


Other related posts:

  • » [haiku-commits] r38163 - haiku/trunk/src/preferences/time - zooey