authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-10 18:39:10 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-10 18:39:10 -08:00
log875affe19905b430fdc5514418cde32f5f25119e
treedf01aef981109b961c6c5b41ea2327adb3e4cb2c
parent9b047a3e3df0e86d47c088d376c7b34ef4801a84

use nektro/zig-time


3 files changed, 8 insertions(+), 1 deletions(-)

licenses.txt+5
...@@ -2,3 +2,8 @@ MIT:...@@ -2,3 +2,8 @@ MIT:
2= https://spdx.org/licenses/MIT2= https://spdx.org/licenses/MIT
3- This3- This
4- git https://github.com/nektro/zig-extras4- git https://github.com/nektro/zig-extras
5- git https://github.com/nektro/zig-sys-linux
6- git https://github.com/nektro/zig-time
7
8Unspecified:
9- system_lib c
ulid.zig+2-1
...@@ -4,6 +4,7 @@ const std = @import("std");...@@ -4,6 +4,7 @@ const std = @import("std");
4const string = []const u8;4const string = []const u8;
5const base32 = @import("./base32.zig");5const base32 = @import("./base32.zig");
6const extras = @import("extras");6const extras = @import("extras");
7const time = @import("time");
78
8pub const Factory = struct {9pub const Factory = struct {
9 epoch: i64,10 epoch: i64,
...@@ -17,7 +18,7 @@ pub const Factory = struct {...@@ -17,7 +18,7 @@ pub const Factory = struct {
17 }18 }
1819
19 pub fn newULID(self: Factory) ULID {20 pub fn newULID(self: Factory) ULID {
20 const now = std.time.milliTimestamp();21 const now = time.milliTimestamp();
21 return ULID{22 return ULID{
22 .timestamp = std.math.cast(u48, now - self.epoch) orelse @panic("time.milliTimestamp() is higher than 281474976710655"), // this is Tue Aug 02 10889 05:31:50.655 UTC23 .timestamp = std.math.cast(u48, now - self.epoch) orelse @panic("time.milliTimestamp() is higher than 281474976710655"), // this is Tue Aug 02 10889 05:31:50.655 UTC
23 .randomnes = self.rand.int(u80),24 .randomnes = self.rand.int(u80),
zig.mod+1
...@@ -6,3 +6,4 @@ description: ULID implementation for Zig...@@ -6,3 +6,4 @@ description: ULID implementation for Zig
6min_zig_version: 0.10.0-dev.2431+0e6285c8f6min_zig_version: 0.10.0-dev.2431+0e6285c8f
7dependencies:7dependencies:
8 - src: git https://github.com/nektro/zig-extras8 - src: git https://github.com/nektro/zig-extras
9 - src: git https://github.com/nektro/zig-time