- The same API as Python's datetime module (see below for differences).
- Clear distinction between naive and aware datetimes.
- All functions/methods return immutable (ok, frozen) objects.
- Timedelta arithmetics.
- Unix timestamps (i.e. seconds instead of milliseconds).
- Lightweight (~3KB gzipped).
leverages the native Date functions wherever possible. In fact, you can think
pythonic-datetime as a wrapper.
Whetting your appetite:
var birthday = datetime; // ja, months start from 1console; // 1989birthdayyear = 1431; // raises TypeError in strict, simply fails otherwisevar partyDay = datetime; // presents are welcomevar yearsAlive = partyDay // returns timedelta object;var partyTime = datetime;datetimedatetime; // 2016-12-05T21:30:00
bower install pythonic-datetime. Or you can git clone this repo as a
submodule; the master branch will always contain the latest stable.
Differences with the original
- The smallest time unit is milliseconds instead of microseconds. Wherever you see microseconds in Python's datetime API, replace it with milliseconds.
used for datetime arithmetics:
delta.compare(another): returns one of -1, 0, 1
- If wrong arguments are provided, TypeError is raised. However, comprehensive argument validation is yet to be implemented.
- No tzinfo, only timezone. This is more of a status-quo.
- Other functions/methods which are not (yet?) implemented:
- The following printf directives are currently not implemented:
%pare not localised.
- Of the scanf directives, only
- To implement the proleptic Gregorian ordinals:
- To validate the constructor arguments.
MIT. Do as you please and praise the snake gods.