Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++CodeDelphi

Easily Perform Datetime Conversions And Time Zone Shifting Using Python Delorean Library On Windows

Earlier we have learned how to manipulate date-time efficiently using Python Arrow Library in the Delphi application. Another alternate for this library is using Python Delorean Library. Delorean is a library that provides easy and convenient DateTime conversions in Python. Dealing with generating lists of date-times, timezone shifting, and much more. In this post will get to understand how to use Delorean using Python4Delphi in Delphi/C++ application.

Delphi itself has extensive date and time conversation capabilities in both System.SysUtils and System.DateUtils. You can find out more about the date and time types in Delphi over in the Embarcadero DocWiki. If you have an existing Python application or code and want to do date time conversion however then the Python Delorean Library is a great place to start. If you want to speed up your date time conversions you could send the conversions over to Delphi with Python4Delphi. You can use Python4Delphi a number of different ways such as:

  • Create a Windows Python GUI around you existing Python app.
  • Add Python scripting to your Delphi Windows apps.
  • Add parallel processing to your Python apps through Delphi threads.
  • Enhance your speed sensitive Python apps with functions from Delphi for more speed.

Prerequisites.

  • If not python and Python4Delphi is not installed on your machine, Check this how to run a simple python script in Delphi application using Python4Delphi sample app
  • Open windows open command prompt, and type pip install -U delorean to install arrow. For more info for Installing Python Modules check here
  • First, run the Demo1 project for executing Python script in Python for Delphi. Then load the script in the Memo1 field and press the Execute Script button to see the result. Go to GitHub to download the Demo1 source.

Delorean Python Library sample script details: Delorean provides you with convenient ways to get significant dates and times and easy ways to move dates from state to state. The sample script demonstrates,

  • How to create a DateTime with the current DateTime and using Unix timestamps.
  • Normalize the timezone to another timezone.
  • Naive Datetime – a date-time object without a timezone.
  • Easy steps to do time arithmetic.
  • Replace or truncate the date-time.
  • Parse from strings the DateTime.
delorean demo 6082544
<strong>Delorean Python Library Demo<strong>

Note: Samples used for demonstration were picked from here with only the difference of printing the outputs. You can check the APIs and some more samples from the same place.

You have read the quick overview of Deloreanlibrary, download this library from here and use user-friendly Date Time manipulations in your applications. Check out Python4Delphi and easily build Python GUIs for Windows using Delphi.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES