PowerBuilder and Norwegian/Finish/Serbian string to date conversion on Windows 10

Problem:
Problem is in system locale on Windows 10.
In Windows 10 Microsoft changed date time formats for some regions:
Finnish, Norwegian Bokmål (“Norway” and “Svalbard and Jan Mayen” variants), Serbian (variants “Cyrillic, Kosovo”, “Latin, Montenegro”, “Latin, Serbia” and “Latin, Kosovo”).
It was internally changed so that it has now the same separator in date and time parts.
For example, previously format was “01.01.2001 11:01” now is “01.01.2001 11.01”.
It is so even if in regional settings user sets “:” as time separator.
It was reported in other systems that on Windows 10 DateTime.Parse(DateTime.Now.ToString()) no longer works correctly for described regions.
More info: http://www.heikniemi.net/hardcoded/2015/08/windows-10-breaks-net-date-parsing-in-certain-locales/
Solution.
As in my case system locale for users cannot be changed to any other and it is unknown if and when MS will release any fix, solution in PB should be found.
My proposal would be:
Create function DATE in for example w_sheet window so all other windows inherit it.
public function date date (string astr_string);
n_cst_datetime dtm
return dtm.of_getdate(astr_string)
end function
Create helper function of_getdate in pfc_n_cst_datetime:
public function date of_getdate (string astr_date);
return Date(DateTime(astr_date))
end function
So, whenever Date( data ) is called in itemchanged (or other) event, our function would be used instead and it would return correct converted date.

Leave a Reply

Your email address will not be published. Required fields are marked *