Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/et-orbi/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def to_debug_s
uo = self.utc_offset
uos = uo < 0 ? '-' : '+'
uo = uo.abs
uoh, uom = [ uo / 3600, uo % 3600 ]
uoh, uom = [ uo / 3600, (uo % 3600) / 60 ]

[
'ot',
Expand Down
4 changes: 2 additions & 2 deletions lib/et-orbi/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_offset_tzone(str)

hr = nil if hr.abs > 11
hr = nil if mn > 59
mn = -mn if hr && hr < 0
mn = -mn if m[1].start_with?('-')

hr ?
custom_tzs[str] = create_offset_tzone(hr * 3600 + mn * 60, str) :
Expand Down Expand Up @@ -85,7 +85,7 @@ def to_offset(n)

i = n.to_i
sn = i < 0 ? '-' : '+'; i = i.abs
hr = i / 3600; mn = i % 3600; sc = i % 60
hr = i / 3600; mn = (i % 3600) / 60; sc = i % 60

sc > 0 ?
'%s%02d:%02d:%02d' % [ sn, hr, mn, sc ] :
Expand Down
11 changes: 11 additions & 0 deletions test/module_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,17 @@
end
end

test 'handles fractional-hour offsets' do

assert EtOrbi.get_tzone(19_800).name, '+05:30'
assert EtOrbi.get_tzone(-1_800).name, '-00:30'
assert EtOrbi.get_tzone('-00:30').name, '-00:30'

assert(
EtOrbi::EoTime.new(0, 19_800).to_debug_s,
'ot 1970-01-01 05:30:00 +05:30 dst:false')
end

# test 'returns a timezone for well-known abbreviations' do
#
# assert gtz('JST'), 'Japan'
Expand Down