diff --git a/headers/private/libroot/time/localtime.h b/headers/private/libroot/time/localtime.h new file mode 100644 index 0000000000..d512f84224 --- /dev/null +++ b/headers/private/libroot/time/localtime.h @@ -0,0 +1,30 @@ +/* + * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _LOCALTIME_H +#define _LOCALTIME_H + + +#include + + +namespace BPrivate { + + +static const char* skPosixTimeZoneInfoFile = "libroot_timezone_info"; +static const int skTimeZoneInfoNameMax = 32; + +// holds persistent info set by Time preflet +struct time_zone_info { + char short_std_name[skTimeZoneInfoNameMax]; + char short_dst_name[skTimeZoneInfoNameMax]; + uint32 offset_from_gmt; + bool uses_daylight_saving; +}; + + +} // namespace BPrivate + + +#endif // _LOCALTIME_H diff --git a/src/preferences/time/Jamfile b/src/preferences/time/Jamfile index e0840bd8e5..a87a1a39cf 100644 --- a/src/preferences/time/Jamfile +++ b/src/preferences/time/Jamfile @@ -2,7 +2,7 @@ SubDir HAIKU_TOP src preferences time ; SetSubDirSupportedPlatformsBeOSCompatible ; -UsePrivateHeaders locale shared ; +UsePrivateHeaders locale shared [ FDirName libroot time ] ; UsePrivateSystemHeaders ; local sources = diff --git a/src/preferences/time/ZoneView.cpp b/src/preferences/time/ZoneView.cpp index 1dad92aa59..972b4e96a6 100644 --- a/src/preferences/time/ZoneView.cpp +++ b/src/preferences/time/ZoneView.cpp @@ -22,11 +22,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -34,6 +36,7 @@ #include #include +#include #include #include @@ -345,7 +348,8 @@ TimeZoneView::_SetSystemTimeZone() { /* Set sytem timezone for all different API levels. How to do this? * 1) tell locale-roster about new default timezone - * 2) write new POSIX-timezone file + * 2) tell kernel about new timezone offset + * 3) write new POSIX-timezone-info file */ int32 selection = fZoneList->CurrentSelection(); @@ -359,6 +363,27 @@ TimeZoneView::_SetSystemTimeZone() _kern_set_timezone(timeZone.OffsetFromGMT()); + BPath path; + status_t status = find_directory(B_COMMON_SETTINGS_DIRECTORY, &path, true); + BFile file; + if (status == B_OK) { + path.Append(BPrivate::skPosixTimeZoneInfoFile); + 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)); + file.Sync(); + } + fSetZone->SetEnabled(false); fLastUpdateMinute = -1; // just to trigger updating immediately