Skip to content

Commit

Permalink
Set timezone in the target system on read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Dec 12, 2016
1 parent ad037da commit b77c6b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions timezone/src/modules/Timezone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,22 @@ def Set(zone, really)
# Do not update the timezone if it's forced and it was already set
if (Mode.installation || Mode.update) && readonly && !@timezone.empty?
log.info "Timezone is read-only and cannot be changed during installation"
return -1
else
# Set the new timezone internally
@timezone = zone
end

zmap = get_zonemap

# Set the new timezone internally
@timezone = zone

sel = 0
while Ops.less_than(sel, Builtins.size(zmap)) &&
!Builtins.haskey(Ops.get_map(zmap, [sel, "entries"], {}), zone)
!Builtins.haskey(Ops.get_map(zmap, [sel, "entries"], {}), @timezone)
sel = Ops.add(sel, 1)
end

@name = Ops.add(
Ops.add(Ops.get_string(zmap, [sel, "name"], ""), " / "),
Ops.get_string(zmap, [sel, "entries", zone], zone)
Ops.get_string(zmap, [sel, "entries", @timezone], @timezone)
)

# Adjust system to the new timezone.
Expand Down
8 changes: 4 additions & 4 deletions timezone/test/Timezone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
allow(Yast::FileUtils).to receive(:IsLink).with("/etc/localtime").and_return(false)
end

it "returns the timezone index" do
it "returns the region number" do
expect(subject.Set("Atlantic/Canary", false)).to eq(3)
end

Expand All @@ -105,8 +105,8 @@
allow(Yast::Mode).to receive(:installation).and_return(true)
end

it "returns -1" do
expect(subject.Set("Atlantic/Canary", false)).to eq(-1)
it "returns the region number" do
expect(subject.Set("Atlantic/Canary", false)).to eq(10) # UTC
end

it "does not modify the timezone" do
Expand All @@ -118,7 +118,7 @@
context "when timezone is read-only in a running system" do
let(:readonly_timezone) { true }

it "returns the timezone index" do
it "returns the region number" do
expect(subject.Set("Atlantic/Canary", false)).to eq(3)
end

Expand Down

0 comments on commit b77c6b8

Please sign in to comment.