@@ -300,18 +300,25 @@ def _dump(limit = nil)
300
300
private :_dump
301
301
302
302
class << self
303
- def at ( sec , usec = undefined , unit = undefined )
304
- if Primitive . undefined? ( usec )
305
- if Primitive . object_kind_of? ( sec , Time )
306
- copy = allocate
307
- copy . send ( :initialize_copy , sec )
308
- return copy
309
- elsif Primitive . object_kind_of? ( sec , Integer )
310
- return Primitive . time_at self , sec , 0
311
- elsif Primitive . object_kind_of? ( sec , Float ) and sec >= 0.0
312
- ns = ( sec % 1.0 * 1e9 ) . round
313
- return Primitive . time_at self , sec . to_i , ns
314
- end
303
+ def at ( sec , usec = undefined , unit = undefined , **kwargs )
304
+ # **kwargs is used here because 'in' is a ruby keyword
305
+ offset = kwargs [ :in ] ? Truffle ::Type . coerce_to_utc_offset ( kwargs [ :in ] ) : nil
306
+
307
+ result = if Primitive . undefined? ( usec )
308
+ if Primitive . object_kind_of? ( sec , Time )
309
+ copy = allocate
310
+ copy . send ( :initialize_copy , sec )
311
+ copy
312
+ elsif Primitive . object_kind_of? ( sec , Integer )
313
+ Primitive . time_at self , sec , 0
314
+ elsif Primitive . object_kind_of? ( sec , Float ) and sec >= 0.0
315
+ ns = ( sec % 1.0 * 1e9 ) . round
316
+ Primitive . time_at self , sec . to_i , ns
317
+ end
318
+ end
319
+ if result
320
+ result = Primitive . time_localtime ( result , offset ) if offset
321
+ return result
315
322
end
316
323
317
324
if Primitive . object_kind_of? ( sec , Time ) && Primitive . object_kind_of? ( usec , Integer )
@@ -343,7 +350,9 @@ def at(sec, usec=undefined, unit=undefined)
343
350
sec += nsec / 1_000_000_000
344
351
nsec %= 1_000_000_000
345
352
346
- Primitive . time_at self , sec , nsec
353
+ time = Primitive . time_at self , sec , nsec
354
+ time = Primitive . time_localtime ( time , offset ) if offset
355
+ time
347
356
end
348
357
349
358
def from_array ( sec , min , hour , mday , month , year , nsec , is_dst , is_utc , utc_offset )
0 commit comments