Skip to content

Commit

Permalink
Small clean up of time creation functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
aardvark179 committed Aug 26, 2022
1 parent dd0149b commit e68528c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/truffle/truffle/cext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1638,14 +1638,17 @@ def warning?
end

def rb_time_nano_new(sec, nsec)
Time.at sec, Rational(nsec, 1000)
Time.at sec, nsec, :nanosecond
end

def rb_time_timespec_new(sec, nsec, offset, is_utc, is_local)
time = rb_time_nano_new(sec, nsec)
return time if is_local
return time.getgm if is_utc
time.getlocal(offset)
if is_local
Time.at(sec, nsec, :nanosecond)
elsif is_utc
Time.at(sec, nsec, :nanosecond, in: 0).getgm
else
Time.at(sec, nsec, :nanosecond, in: offset)
end
end

def rb_time_num_new(timev, off)
Expand Down

0 comments on commit e68528c

Please sign in to comment.