Delorean

raw JSON →
1.0.0 verified Mon Apr 27 auth: no python maintenance

Delorean is a Python library for manipulating datetimes with ease and clarity. Current version 1.0.0 is the first stable release. The project appears to be in maintenance mode with no recent releases since 2016.

pip install delorean
error ImportError: cannot import name 'Delorean'
cause You imported delorean (lowercase) instead of Delorean (capitalized).
fix
Use: from delorean import Delorean
error TypeError: an integer is required (got type str)
cause Passing a string as epoch instead of int/float.
fix
Use epoch=int('1234567890') or epoch=1234567890.
gotcha Delorean class does not support direct arithmetic, use .shift() or .next_day() etc.
fix Use .shift(hours=2) or .next_day() instead of adding timedelta.
deprecated Some datetime methods may be deprecated in modern Python; Delorean was last updated in 2016.
fix Consider using pendulum or dateutil for actively maintained alternatives.

Basic usage: create a Delorean object for the current UTC time, or from a specific datetime with timezone, or from a Unix timestamp.

from delorean import Delorean, epoch
from datetime import datetime

d = Delorean()
print(d.datetime)

d2 = Delorean(datetime(2020, 1, 1, 0, 0, 0), timezone='US/Eastern')
print(d2.datetime)

print(Delorean(epoch=1000000000).datetime)