https://github.com/extrawurst/ulid-d
ULID implementation in D
https://github.com/extrawurst/ulid-d
d dlang ulid uuid
Last synced: 4 months ago
JSON representation
ULID implementation in D
- Host: GitHub
- URL: https://github.com/extrawurst/ulid-d
- Owner: extrawurst
- License: mit
- Created: 2017-06-08T19:07:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-02T11:54:09.000Z (over 7 years ago)
- Last Synced: 2025-10-29T04:31:12.557Z (8 months ago)
- Topics: d, dlang, ulid, uuid
- Language: D
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ulid-d [](https://travis-ci.org/Extrawurst/ulid-d)
ULID implementation in D
# usage
```
import std.stdio;
import ulid.ulid;
void main()
{
// simple usage but shows different time portions
writefln("simple: %s", ULID.generate());
writefln("simple: %s", ULID.generate().toString());
// set your own time stamp
writefln("custom time: %s", ULID.generate(1469918176385).toString());
writefln("custom time: %s", ULID.generate(1469918176385).toString());
writefln("custom time: %s <- time portion", ULID.generate(1469918176385).toString()[0 .. 10]);
static ubyte randomByte()
{
return 4;
}
// now we define all components manually by also overriding the random generator
writefln("all custom: %s", ULID.generate(1469918176385, &randomByte).toString());
writefln("all custom: %s", ULID.generate(1469918176385, &randomByte).toString());
}
```
see `source/demo.d`
# build demo
```
dub --config=demo
```
output:
```
simple: 7DFPGD9GPH2X5T9Y05S7EDW3N2
simple: 7DFPGDEC1JQC153KSP6VPEF27T
custom time: 01ARYZ6S410EHN4S8FDPCWWQ00
custom time: 01ARYZ6S413XBZ5V68XJJTV5FS
custom time: 01ARYZ6S41 <- time portion
all custom: 01ARYZ6S410G2081040G208104
all custom: 01ARYZ6S410G2081040G208104
```