Delorean is a library for clearing up the inconvenient truths that arise when dealing with datetime in Python. Understanding that timing is delicate enough of a problem, Delorean hopes to provide a cleaner and less troublesome solution to shifting, manipulating, and generating datetime.
Delorean stands on the shoulders of giants: pytz and dateutil library.
Delorean will provide natural language improvements for manipulating time, as well as datetime abstractions for ease of use. The overall goal of Delorean is to improve datetime manipulations, with a little bit of software and philosophy.
This post will guide you on how to run datetime manipulations using Python’s Delorean library and then display it in the Delphi Windows GUI app using Python for Delphi.
First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.
Delorean’s Hello World:
from datetime import datetime
est = pytz.timezone('US/Eastern')
d = datetime.now(pytz.utc)
d = est.normalize(d.astimezone(est))
from delorean import Delorean
d = Delorean()
d = d.shift('US/Eastern')
Congratulations, now you have learned how to run datetime manipulations using Python’s Delorean library and then display it in the Delphi Windows GUI app using Python for Delphi!
Check out the Delorean library for Python and use it in your projects: https://pypi.org/project/Delorean/ and
Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi: https://github.com/pyscripter/python4delphi