We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4a8341b + d6ed0fb commit 3f18e1dCopy full SHA for 3f18e1d
lib/ulid/generate.rb
@@ -61,7 +61,7 @@ def random_bytes
61
end
62
63
def millisecond_time
64
- (@time.to_f * 1_000).to_i
+ (@time.to_r * 1_000).to_i
65
66
67
# THIS IS CORRECT (to the ULID spec)
spec/ulid_spec.rb
@@ -24,6 +24,12 @@
24
expect(ULID.at(KNOWN_TIME)).to be_a_valid_ulid
25
26
27
+ it 'handles timestamp as the milliseconds precision' do
28
+ expect(ULID.at(Time.parse('2016-07-30 22:36:16.001000000 UTC'))).to start_with('01ARYZ6RR1')
29
+ expect(ULID.at(Time.parse('2016-07-30 22:36:16.002000000 UTC'))).to start_with('01ARYZ6RR2')
30
+ expect(ULID.at(Time.parse('2016-07-30 22:36:16.003000000 UTC'))).to start_with('01ARYZ6RR3')
31
+ end
32
+
33
34
35
describe '.time' do
0 commit comments