Skip to content

Commit 18ceb83

Browse files
authored
fix(id-parsing): fixes timestamp parsing from a given ID (#43)
This fix will parse properly the timestamp of a given ID
1 parent 53f94ac commit 18ceb83

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Sonyflake.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function parseId(string $id, $transform = false): array
101101
$data = [
102102
'sequence' => substr($id, -1 * self::MAX_SEQUENCE_LENGTH),
103103
'machineid' => substr($id, -1 * $length, self::MAX_MACHINEID_LENGTH),
104-
'timestamp' => substr($id, 0, $length),
104+
'timestamp' => substr($id, 0, strlen($id) - $length),
105105
];
106106

107107
return $transform ? array_map(function ($value) {

0 commit comments

Comments
 (0)