Create A KSUID For A Specific Date In Python
NOTE: I'm using `ulid` now instead of `ksuid` since it allows going back to epoch (Jan. 1, 1970) instead of KSUID's epock of May 2014.
NOTE: I need to go back and review this one
NOTE: KSUIDs epoch is May 13th, 2014. You can't go before that. They run out in somewhere over 100 years too. Less of a problem there, but something to know.
Code
python3 -i -c "from ksuid import Ksuid; from datetime import datetime; datetime = datetime(year=2015, month=1, day=1, hour=10, minute=22, second=13); print(Ksuid(datetime))"
Results
0AbwgV4iNcd543b9khXluR2QJj7
The original ksuid package doesn't have a way to generate KSUIDs for a specific date. I need that feature to go back and add KSUIDs to my previous notes/posts.
This python module provides the functionality.
Install with:
Code
-
And then run it with:
Code
= 2017
= 11
= 16
= 12
= 0
= 0
=
=
# This 12 character version is what I use for the slugs on my site
Results
0wRwD3sllvzEOg53Grv73EA5815
0wRwD3sllvzE
(NOTE: Be cafeful if you try the ruby version. I got incorrect dates when examining the values)