Handle different time zones

In the FireStart client, it is possible to configure different time zones in case you need to save a time that is different from the local time, it is good to understand how these work in order to make consistent use of them.
In this article, we discuss how time zones are saved and taken from a database (MSSQL) with different settings.
 When a Business Entity is mapped to a database table it needs a timezone that is set at the time of mapping:

overview-2021-04-28-1

In this case, the timezone is set to UTC+1, which means that a specific DateTime value will be mapped in the database with this timezone and when retrieved from the database it will be converted to the value.

E.g.: With the Date time zone field set to Moscow (UTC+3) and local time being Berlin (UTC+1) 14:00, the time stored in the database will be 16:00(Moscow Time), and the time displayed in the client will be 14:00(Berlin Time).

The timezone set in the mapping window is the key point of timezone consistency, the saved value will always refer to the set timezone, like in the previous example, while the returned value will always be the local one. If you need a return of the absolute value of the date, for example, you want to read from the database without conversions and regardless of the timezone: it is possible to set the Date time zone field with the value (UTC) Co-ordinated Universal Time and save the value in a variable of type DateTime that ignores the timezones, this will returns times without any conversion.

Time in logs and BE

It is worth pointing out a few aspects that may be misleading in the use of timezones. When a certain time is saved it is shown in the logs with the value of GMT+0, this means that if during the daylight saving time period of the year, a DateTime variable is saved in the Database with the Date time zone value set to UTC+1, at 15:00, in the logs, it will appear as 13:00. In the Business Entity, the data stored is live data and not fixated, this will affect the usage of timezones: if a DateTime variable is saved with UTC+3 the variable will hold a time relative to UTC+3, if the mapping is changed, the business entities related to that mapping are changed accordingly, this excludes problems related to data inconsistency. 

Use the converter

A converter can be set in the mapping and on the use of a variable of type DateTime:

overview-2021-04-28-2

overview-2021-04-28-3

The converter interferes not only with the timezone of the time but also with the format, this tool is particularly efficient and useful when working with DateTime represented by text strings, using the converter it is possible to convert a date into a string, the process, on the other hand, is more complicated as not all databases understand, or interpret, all possible date formats. By selecting the Custom format you can change both time and format, FireStart supports this kind of conversion only if applied to strings, the use of converter + mapping applies several times a timezone to the variable which can lead to inconsistency of data and poor readability by third parties.