UG update; Time class plus fixes to the time class to mitigate data mutation

issues and rename the .with_offset method to .as_zone to align better.
This commit is contained in:
Peter Camilleri 2015-06-17 16:27:53 -04:00
parent 5eb127fa06
commit 8a68ab10a1
3 changed files with 9 additions and 9 deletions

Binary file not shown.

View file

@ -120,7 +120,7 @@ class TimeLibraryTester < Minitest::Test
foorth_equal('[ 2015 6 14 18 50 0.0 0 ] .to_t .as_local',
[Time.at(1434322200+ofs)])
foorth_equal('3600 [ 2015 6 14 18 50 0.0 ] .to_t .with_offset',
foorth_equal('3600 [ 2015 6 14 18 50 0.0 ] .to_t .as_zone',
[Time.at(1434322200).localtime(3600)])
end

View file

@ -62,11 +62,11 @@ module XfOOrth
})
Time.create_shared_method('.to_t', TosSpec, [], &lambda {|vm|
vm.push(self)
vm.push(self.clone)
})
Time.create_shared_method('.to_t!', TosSpec, [], &lambda {|vm|
vm.push(self)
vm.push(self.clone)
})
Array.create_shared_method('.to_t', TosSpec, [], &lambda {|vm|
@ -81,7 +81,7 @@ module XfOOrth
begin
vm.push(Time.new(*self))
rescue
error "F40: Cannot convert \"#{self.to_s}\" to a Time instance"
error "F40: Cannot convert #{self.to_s} to a Time instance"
end
})
@ -148,18 +148,18 @@ module XfOOrth
#[time] .as_utc [time]
Time.create_shared_method('.as_utc', TosSpec, [], &lambda {|vm|
vm.push(self.localtime(0))
vm.push(self.clone.localtime(0))
})
#[time] .as_local [time]
Time.create_shared_method('.as_local', TosSpec, [], &lambda {|vm|
vm.push(self.localtime)
vm.push(self.clone.localtime)
})
#[offset time] .with_offset [time]
Time.create_shared_method('.with_offset', TosSpec, [], &lambda {|vm|
#[offset time] .as_zone [time]
Time.create_shared_method('.as_zone', TosSpec, [], &lambda {|vm|
offset = Integer.foorth_coerce(vm.pop)
vm.push(self.localtime(offset))
vm.push(self.clone.localtime(offset))
})