Learn & Refresh: Using date and time in Delphi

Learn & Refresh: Using date and time in Delphi

Date and time values are always considered “special” in each programming language. Many modern object-oriented programming languages provide classes to handle date and time easily.

Delphi is no exception. Even though Delphi has been released in 1995 and that version did not provide a dedicated class for dates and time, there have been some significant improvements. This means these post and videos are designed for both beginners and long-time Delphi developers.

The first video, which was released in honor of Delphi’s 27th birthday, the types TDate and TDateTime are introduced to store dates and work with dates. Again, this might seem obvious at first, but there are new opportunities in the RTL to be made use of instead of using third party libraries or outdated methods. Embarcadero has done an amazing job with the unit System.DateUtils.pas to make working with dates easier.

Looking at TDateTime, the recent versions of Delphi provide even easier access. With the introduction of class and record helpers, you can use TDateTime directly to work with dates and time. This is what the second video focuses on:

Before looking at time, there is an interesting data type to handle duration called TTimeSpan. This type is essential when calculation the difference between to dates and also when modifying an exciting value.

And after all that build-up, you are ready to learn about time values and how issues with time zones can be prevented. For example, you want to make sure that a data store that is accessible from all over the world contains dates that are in the correct order world-wide. Also, when displaying values to a user, you want them to be localized to their current time zone. The following video will look at that aspect.

All these videos refer to the Delphi RTL and the techniques learned work out of the box with recent Delphi versions. No third party libraries are required. Of course, you will become a master at incorporating products like TMS Planner into your applications without encountering issues handling date and time values.

Tags: , , , , , , , ,

Partnerships




Top