[Gambas-bugtracker] Bug #1969: result of function Format () is error

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Mon Nov 23 03:16:09 CET 2020


http://gambaswiki.org/bugtracker/edit?object=BUG.1969&from=L21haW4-

Comment #26 by 梁炜:

I haven't used Microsoft Windows for many years. Under Linux, I use libreoffice or Kingsoft WPS. In China, Microsoft's policy of indulging in piracy to occupy the market has made docx the de facto standard. I was once complained that the documents could not be opened or edited. After that, the documents that I gave to others were usually in docx format.I didn't notice that you don't use Microsoft Windows too.

In the "correct" line, if the output of Gambas conforms to the Chinese expression, I mark "OK"; if the output does not conform to the Chinese expression, I write the correct expression in red. Although I translated the wiki, I don't remember ever using this predefined constant. Maybe I tried it?

A long time ago, there was a confusion about the dates that once worked properly. I checked and found that I got a UTC time instead of a local time. But I don't care about UTC at all. I only use and process local time. I looked at the Wiki and found that CDate will get UTC instead of local time, which means that users suddenly have to face UTC when dealing with local time, and it takes a bit of effort to convert strings to local time.

After that, I used the Split string and the Date function to get the local time. Until yesterday, I studied the relationship between UTC and local time. The DateAdd and CDate functions are used to complete the conversion.

According to the wiki, CDate function will get UTC. But Print will convert UTC to local time and print it out. So:
Print CDate("11/22/2020 17:06:45")
Output:
2020年11月23日 01时06分45秒
Because I'm in CST, that's right. But:
Print CDate("17:06:45")
Output:
17时06分45秒
It should output "01时06分45秒".

The following code checks the Val function:
Print "gb.generaldate", Format(CDate("08/03/2020 17:06:45"), gb.GeneralDate)
Print IsNull(Val("2020年08月04日 01时06分45秒"))
Print IsNull(Val("08/04/2020 01:06:45"))
Print IsNull(Val("2020/08/04 01:06:45"))
Output:
gb.generaldate  2020年08月04日 01时06分45秒
True
True
True
It seems that the change of date separator affects the function of Val function.




More information about the Bugtracker mailing list