Time string format and Locale

Forum Home Forums Uncategorized Issues Time string format and Locale

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #16511
    JW
    Participant

    SCADA V6, deplored on Win10 PC, simplified Chinese (zh-CN)

    In default language en-GB, the displayed time string format (on table view and dynamic text on scheme) is HH:mm (e.g. 13:30)

    I applied a language pack zh-Hans, the displayed time string format becomes tt H:mm (e.g. 下午 1:30, PM 1:30)

    I tried the following tests:

    1. change the format on windows, but the displayed time string format doesn’t seem to change with the OS format setting. Sitll being tt H:mm.

    2. I changed the language pack file name and locale info to zh-CN to match the Win10 locale name. Then change the format again. But the time string format doesn’t change with the OS either. Sitll being tt H:mm.

    3. I tried deploying the same project and language pack zh-CN on a Win11 PC simplified Chinese (zh-CN), the time string format is HH:mm. But also not change with OS format setting.

    Questions

    Is displayed time string format determined by the language pack, locale setting, OS setting or all of them?

    How to config the displayed time string format properly?

    #16516
    Mikhail
    Moderator

    Hi,

    The conversion is performed here by the ToString method.

    I suppose, it doesn’t depend on the OS settings. It depends on the format string from the Formats table (you can change it) and depends on the selected culture name.

    #16517
    Mikhail
    Moderator

    Probably, the simplest approach is changing the Format table (edit existing or add new format). Possible format strings are here.

    #16518
    JW
    Participant

    Thanks Mikhail.

    So the format is based on both the format identifier and culture name.

    For the Input channels, Editing the formats works display as the method you said and the link your provided.

    But for the time of the table view column, and the datetime on the event table, how can I force the format of them? They are now changed with culture name but not the format table.

    How can I force the table view column to be HH:mm and the event table datetime to be yyyy/MM/dd HH:mm:ss?

    #16528
    Mikhail
    Moderator

    I suppose, the following should work:
    In the Formats table, find the row with ID=33. Set the Format field of that row to HH:mm:ss. Use the format with ID=33 for the channel.
    Does it work? If no, I can research by debugging.

    #16529
    JW
    Participant

    The channel format works as your instruction.

    But the column name from 00:00 to 23:00 in HH:mm, changed to AM 12:00 to PM 11:00 in “tt h:mm” when I set the culture to “zh-CN” on a win10 PC, and couldn’t get it displayed as 00:00 to 23:00 “HH:mm”.

    I added a datetime channel to a table view for comparison, the format of the channel value changed, but the “Column name” remains.

    https://1drv.ms/i/c/7d196e63b671ad1b/Ecgl1GNclGJCmMjWyu4dMvoBC4Y7Y2EEH-VBKXB0ZNt88Q?e=KUFT40

    #16538
    Mikhail
    Moderator

    Column headers use the fixed formats, link. Only the selected culture name affects them.

    • This reply was modified 3 months ago by Mikhail.
    #16547
    JW
    Participant

    I am considering 2 ways to change this format.

    1. Modified this line of code, re-compile the PlgMain.dll

    2. Is the any method to alter the default shorttime format of zh-CN globally (system / scada level).

    #16548
    manjey73
    Participant

    In theory, it can be displayed on a diagram or table in a string format as you like through the Calculated channel using scripts.

    Without touching the dll assembly. The channel cell stores a double representation of the time DateTime.ToOADate(). How you convert it to a DateTime and then to a string doesn’t matter.

    • This reply was modified 3 months ago by manjey73.
    #16554
    Mikhail
    Moderator

    > Is the any method to alter the default shorttime format of zh-CN globally (system / scada level).

    I suppose, it’s hardcoded somewhere in .NET framework.

    #16556
    manjey73
    Participant

    It’s not exactly rigid, there are default options for a short date for different languages, but you can apply your own format and output it as a string.

    https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

    You can also create your own short format.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.