modules/ulid.zzm

ulid-0.1.0 documentation

Package

Name
ulid
Version
0.1.0
Uploaded
2026-07-30 22:55:51
Repository
https://github.com/tobyink/zuzu-ulid
Dependencies
Metadata
zuzu-distribution.json
Archive
Download .tar.gz

NAME

ulid - Universally Unique Lexicographically Sortable Identifiers.

SYNOPSIS

  from std/time import Time;
  from ulid import create_ulid, create_ulid_binary, ulid_time;

  let text := create_ulid();
  let raw := create_ulid_binary();
  let historical := create_ulid( time: new Time(946684800) );
  let timestamp := ulid_time(text);

IMPLEMENTATION SUPPORT

This module is supported by all implementations of ZuzuScript.

DESCRIPTION

This module generates ULIDs using a 48-bit Unix timestamp in milliseconds and 80 bits of cryptographically secure randomness. The text form uses canonical uppercase Crockford Base32.

Identifiers generated within the same millisecond are monotonic: the random component is incremented so that each later identifier sorts after the previous one.

EXPORTS

Functions

  • create_ulid_binary(time: Time?)

    Parameters: optional time supplies the timestamp; when omitted, the current time is used. Returns: BinaryString. Returns a single ULID as 16 raw bytes in network byte order.

  • create_ulid(time: Time?)

    Parameters: optional time supplies the timestamp; when omitted, the current time is used. Returns: String. Returns a single ULID as 26 uppercase Crockford Base32 characters.

  • ulid_time(String|BinaryString ulid)

    Parameters: ulid is a valid 26-character ULID, accepted case-insensitively, or a 16-byte binary ULID. Returns: Time. Returns the timestamp encoded in the ULID, with millisecond precision. The input form is detected automatically. Throws an exception if ulid is not valid.

COPYRIGHT AND LICENCE

ulid is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.