Are you looking for powerful tools to deal with datetime and build a nice GUI for them? You can build it easily by combining the Delorean and Python4Delphi library, inside Delphi and C++Builder.
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from datetime import datetime import pytz est = pytz.timezone('US/Eastern') d = datetime.now(pytz.utc) d = est.normalize(d.astimezone(est)) print(d) from delorean import Delorean d = Delorean() d = d.shift('US/Eastern') print(d) |
The result:
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