Here is some code related to dates and times:
Code: Select all
DatasourceASCIIQuoteCharacter = '';
n = Now;
sNow = Timst( n, '\d-\m-\Y \h:\i:\s' );
ASCIIOutput( 'test.txt', sNow );
i = NewDateFormatter( 'nl_BE', 'Europe/Brussels', '', '', 'datetime' );
v = FormatDate( n, 'EEEE dd MMMM y - H:mm', i );
ASCIIOutput( 'test.txt', v );
i = NewDateFormatter( 'nl_BE', 'Europe/Brussels', '', '', 'date' );
v = FormatDate( Dayno( Today(0)), 'EEEE dd MMMM y', i );
ASCIIOutput( 'test.txt', v );
Executed in IBM PAoC (probably a data center in Germany and same timezone):
11-05-2025 22:30:32
Monday 12 May 2025 - 0:30
Sunday 11 May 2025
Executed on my own laptop TM1 2.0.9.21 - Belgian settings:
12-05-2025 00:30:51
Monday 12 May 2025 - 2:30
Monday 12 May 2025
Findings:
- LINE 1: Now() gives a time in UTC, or so I thought (viewtopic.php?p=47871#p47871). Why would the result then change depending on where the code is executed ? Now does not seem to return UTC.
- LINE 2: Why the difference if I specifically mention that the timezone is Europe/Brussels ? PAoC seems to be correct.
- LINE 3: Also a difference ? Laptop seems to be correct.
The ultimate goal is to just print the date and time of "now" in a cube for a given timezone. That seems to be harder than I thought unless I am missing something.
And code that is universal irrespective of server locations or PA versions/delivery methods.
Or should I take into account server locations in any of these calculations, like Yuri wrote about (https://www.ykud.com/blog/pa_timezone) ?