File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def unpack_decoded_bytes(packed_bytes)
5151 ( time_bytes [ 1 ] . to_i << 32 ) |
5252 ( time_bytes [ 0 ] . to_i << 40 )
5353
54- [ Time . at ( time_int * 0.001 ) . utc , seed ]
54+ [ Time . at ( time_int * 1 / 1000 r ) . utc , seed ]
5555 end
5656
5757 end
Original file line number Diff line number Diff line change 3434 end
3535
3636 it 'returns same time that was used to generate it' do
37- # NOTE: we may not get the PRECISE time out due to conversion from
38- # Time -> Float -> Base32 -> Float -> Time
39- #
40- # It's not immediately clear to me whether that's a function of Ruby
41- # or of the format.
42- expect ( ulid_time ) . to be_within ( 0.001 ) . of ( KNOWN_TIME )
37+ expect ( ulid_time ) . to eq ( KNOWN_TIME )
38+ end
39+
40+ it 'handles timestamp as the milliseconds precision' do
41+ time = ULID . time ( '0A000000000000000000000000' )
42+ expect ( time . to_i ) . to eq ( 10995116277 )
43+ expect ( time . nsec ) . to eq ( 760000000 )
4344 end
4445 end
4546
You can’t perform that action at this time.
0 commit comments