Skip to content

Commit

Permalink
Merge pull request #8 from jsuchome/master
Browse files Browse the repository at this point in the history
use timezone data from/etc/localtime if available (bnc#773491)

I hope it can be merged, even if not perfect.
  • Loading branch information
jsuchome committed Aug 16, 2012
2 parents b2ca7f4 + c91df0a commit 7cc6eb6
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.22.7
2.22.8
6 changes: 6 additions & 0 deletions package/yast2-country.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Aug 16 10:41:41 CEST 2012 - jsuchome@suse.cz

- use timezone data from /etc/localtime if available (bnc#773491)
- 2.22.8

-------------------------------------------------------------------
Tue Aug 14 11:39:44 CEST 2012 - jsuchome@suse.cz

Expand Down
12 changes: 12 additions & 0 deletions timezone/src/Timezone.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module "Timezone";
textdomain "country";

import "Arch";
import "FileUtils";
import "Language";
import "Misc";
import "Mode";
Expand Down Expand Up @@ -360,6 +361,17 @@ global define string UpdateTimezone (string tmz) {
default_timezone =
Misc::SysconfigRead(.sysconfig.clock.DEFAULT_TIMEZONE, default_timezone);

// /etc/localtime has priority over sysconfig value of timezone
if (FileUtils::IsLink ("/etc/localtime"))
{
string tz_file = (string) SCR::Read (.target.symlink, "/etc/localtime");
if (tz_file != nil && substring (tz_file, 0, 20) == "/usr/share/zoneinfo/")
{
timezone = substring (tz_file, 20);
y2milestone ("time zone read from /etc/localtime: %1", timezone);
}
}

list<string> adjtime= ReadAdjTime ();
if (size (adjtime) == 3)
{
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions timezone/testsuite/tests/Timezone2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Read .target.symlink "/etc/localtime" "/usr/share/zoneinfo/Europe/Berlin"
Read .etc.adjtime ["0", "0", "UTC"]
Return $["hwclock":"UTC", "timezone":"Europe/Berlin"]
47 changes: 47 additions & 0 deletions timezone/testsuite/tests/Timezone2.ycp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* tests for Timezone.ycp constructor
* Author: jsuchome@suse.cz
* $Id$
*/
{

// testedfiles: Timezone.ycp

import "Testsuite";

map READ = $[
"sysconfig" : $[
"clock" : $[
"TIMEZONE" : "Europe/Prague",
"HWCLOCK" : "-u",
],
],
"target" : $[
"size" : 1,
"yast2" : $[],
"lstat" : $[
"islink" : true
],
"symlink" : "/usr/share/zoneinfo/Europe/Berlin",
],
"etc" : $[
"adjtime" : [
"0",
"0",
"UTC" ]
],
];
map EXECUTE = $[
"target" : $[
"bash_output" : $[],
],
];



Testsuite::Init([READ,$[],EXECUTE], nil);

import "Timezone";

Testsuite::Test (``(Timezone::Export ()), [], nil);
}

0 comments on commit 7cc6eb6

Please sign in to comment.