Dan Buch is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this againDt63 overview
Recent commits See more »
How to use Dt63
===============
The Dt63 encoder will accept either datetime objects or ISO-formatted time
strings, returning an ascii hash::
>>> from datetime import datetime
>>> import dt63
>>> mydate = datetime(1996, 10, 5, 11, 44, 27, 73762)
>>> mydate_str = str(mydate)
>>> print mydate_str
1996-10-05 11:44:27.073762
>>> from_obj = dt63.encode(mydate)
>>> from_str = dt63.encode(mydate_str)
>>> assert from_obj == from_str
>>> print from_obj, from_str
J96A5BiR073762 J96A5BiR073762
The Dt63 encoder and decoder are registered
with the standard library codecs on import and may be used during str.encode
and str.decode calls::
>>> datestr = str(datetime(2001, 8, 9, 12, 13, 33, 88321))
>>> print datestr
2001-08-09 12:13:33.088321
>>> encdate = datestr.encode('dt63')
>>> print encdate
K0189CDX088321
>>> assert encdate.decode('dt63') == datestr
What's the point?
+++++++++++++++++
I needed a way to retain fine-grained date information in some sort of id
which could be passed in http GET requests. Yes, I'm sure there are a
bajillion simpler ways to do this, but I felt like solving the problem
this way.
.. vim:filetype=rst