@@ -300,11 +300,11 @@ def _dump(limit = nil)
300
300
private :_dump
301
301
302
302
class << self
303
- def at ( sec , usec = undefined , unit = undefined , **kwargs )
303
+ def at ( sec , sub_sec = undefined , unit = undefined , **kwargs )
304
304
# **kwargs is used here because 'in' is a ruby keyword
305
305
offset = kwargs [ :in ] ? Truffle ::Type . coerce_to_utc_offset ( kwargs [ :in ] ) : nil
306
306
307
- result = if Primitive . undefined? ( usec )
307
+ result = if Primitive . undefined? ( sub_sec )
308
308
if Primitive . object_kind_of? ( sec , Time )
309
309
copy = allocate
310
310
copy . send ( :initialize_copy , sec )
@@ -321,11 +321,11 @@ def at(sec, usec=undefined, unit=undefined, **kwargs)
321
321
return result
322
322
end
323
323
324
- if Primitive . object_kind_of? ( sec , Time ) && Primitive . object_kind_of? ( usec , Integer )
324
+ if Primitive . object_kind_of? ( sec , Time ) && Primitive . object_kind_of? ( sub_sec , Integer )
325
325
raise TypeError , "can't convert Time into an exact number"
326
326
end
327
327
328
- second_arg_scale =
328
+ sub_sec_scale =
329
329
if Primitive . undefined? ( unit ) || :microsecond == unit || :usec == unit
330
330
1_000
331
331
elsif :millisecond == unit
@@ -336,31 +336,31 @@ def at(sec, usec=undefined, unit=undefined, **kwargs)
336
336
raise ArgumentError , "unexpected unit: #{ unit } "
337
337
end
338
338
339
- if Primitive . undefined? ( usec ) && Primitive . object_kind_of? ( sec , Rational )
339
+ if Primitive . undefined? ( sub_sec ) && Primitive . object_kind_of? ( sec , Rational )
340
340
rational = Truffle ::Type . coerce_to_exact_num ( sec )
341
341
seconds , fractional_seconds = rational . divmod ( 1 )
342
342
nano_fractional_seconds = fractional_seconds * 1_000_000_000
343
343
344
344
time = Primitive . time_at self , seconds , nano_fractional_seconds . to_i
345
345
time = Primitive . time_localtime ( time , offset ) if offset
346
346
return time
347
- elsif Primitive . undefined? ( usec )
348
- usec = 0
347
+ elsif Primitive . undefined? ( sub_sec )
348
+ sub_sec = 0
349
349
end
350
350
351
- s = Truffle ::Type . coerce_to_exact_num ( sec )
352
- u = Truffle ::Type . coerce_to_exact_num ( usec )
351
+ sec = Truffle ::Type . coerce_to_exact_num ( sec )
352
+ sub_sec = Truffle ::Type . coerce_to_exact_num ( sub_sec )
353
353
354
- sec = s . to_i
355
- nsec_frac = s % 1.0
354
+ seconds = sec . to_i
355
+ sec_frac = sec % 1.0
356
356
357
- sec -= 1 if s < 0 && nsec_frac > 0
358
- nsec = ( nsec_frac * 1_000_000_000 + 0.5 ) . to_i + ( u * second_arg_scale ) . to_i
357
+ seconds -= 1 if sec < 0 && sec_frac > 0
358
+ nsec = ( sec_frac * 1_000_000_000 + 0.5 ) . to_i + ( sub_sec * sub_sec_scale ) . to_i
359
359
360
- sec += nsec / 1_000_000_000
360
+ seconds += nsec / 1_000_000_000
361
361
nsec %= 1_000_000_000
362
362
363
- time = Primitive . time_at self , sec , nsec
363
+ time = Primitive . time_at self , seconds , nsec
364
364
time = Primitive . time_localtime ( time , offset ) if offset
365
365
time
366
366
end
0 commit comments