We know how to manipulate Date Time in our Delphi/C++ Builder with n-number of APIs in TDateTime. Similarly, Python’s standard library and some other low-level modules have a near-complete date, time, and timezone functionality, but don’t work very well from a usability perspective like too many Modules and types, timezone, and timestamp conversions are verbose. To fill these gaps of usability perspective an Excellent powerful library Arrow is built. In this post will get to understand how to use Arrow using Python4Delphi in Python GUI Delphi/C++ applications.
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 arrow 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.
Arrow Python Library sample script details: The sample script demonstrates,
- How the Date time is created in different ways i.e using now(), from timestamps, using a naive or time-aware DateTime
- Using properties to represent the date time and Formatting the date-time
- Replace and shift the date-time for the user’s preferred date-time value.
- Convert from one timezone to others by name or tzinfo.
- Humanize the DateTime relative to now.
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 Arrow library, 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.