]> gitweb.factorcode.org Git - factor.git/commitdiff
ulid: Fix same-millisecond calculation
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 27 Dec 2021 19:07:59 +0000 (13:07 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 27 Dec 2021 19:07:59 +0000 (13:07 -0600)
Fixes #2519

extra/ulid/ulid.factor

index 7d35bcf8535eafeae52bed7362780dda1156e2bb..d9f82d07990907971d4d0b6920e201eaff0b69d9 100644 (file)
@@ -27,9 +27,9 @@ SYMBOL: last-random-bits
 : encode-time ( timestamp -- string )
     timestamp>millis 10 encode-bits ;
 
-: same-msec? ( -- ? )
-    nano-count 1000 /i dup \ same-msec? get =
-    [ drop t ] [ \ same-msec? set f ] if ;
+: same-millisecond? ( -- ? )
+    nano-count 1,000,000 /i dup \ same-millisecond? get =
+    [ drop t ] [ \ same-millisecond? set f ] if ;
 
 : pack-bits ( seq -- seq' )
     5 swap [ first ] [ rest ] bi [
@@ -45,7 +45,7 @@ SYMBOL: last-random-bits
 
 TR: (normalize-ulid) "ILO" "110" ; inline
 
-: (ulid) ( same-msec? -- ulid )
+: (ulid) ( same-millisecond? -- ulid )
     [
         last-time-string get last-random-bits get 1 +
         dup 80-bits > [ ulid-overflow ] when
@@ -57,7 +57,7 @@ TR: (normalize-ulid) "ILO" "110" ; inline
 PRIVATE>
 
 : ulid ( -- ulid )
-    same-msec? (ulid) ;
+    same-millisecond? (ulid) ;
 
 ERROR: ulid>bytes-bad-length n ;
 M: ulid>bytes-bad-length summary drop "Invalid ULID length" ;