ulid-d 0.1.0

ULID implementation in D


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

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
Authors:
  • Stephan Dilly
Dependencies:
none
Versions:
0.1.1 2018-Mar-21
0.1.0 2017-Oct-26
0.0.1 2017-Jun-09
~master 2018-Oct-02
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 1124 downloads total

Score:
0.5
Short URL:
ulid-d.dub.pm