Tcl Source Code

View Ticket
Login
Ticket UUID: 4a0c163d24549700a25d1e3a47c2c77477b50a25
Title: Win clock locale change not passed to "-locale current"
Type: Bug Version: 8.6.4
Submitter: oehhar Created on: 2015-06-30 14:42:51
Subsystem: 06. Time Measurement Assigned To: oehhar
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2015-10-23 14:10:04
Resolution: Fixed Closed By: oehhar
    Closed on: 2015-10-23 14:10:04
Description:

Taking this command:

clock format [clock seconds] -locale system -format %x
On windows, the system encoding is taken from *msgcat::mclocale*. If *msgcat::mclocale* changes, the corresponding parse functions are not rebuild.

E.g.:

% mclocale de_de
% clock format [clock seconds] -locale system -format %x
01.07.2015
# mclocale en_us
% clock format [clock seconds] -locale system -format %x
01.07.2015

On the second call, the parser build at the first invokation is reused and not re-initialized due to the locale change. Nevertheless, the used message catalogue should change.

It is not clear to me, if this is an issue. I am writing this ticket to eventually not forget it (also by myself).

----

Addendum to ticket by oehhar:

The upper test is not an issue. The issue arises, if "-locale current" is used. Only windows port makes the difference. The bug is within format and scan. Details in comments. Due to that, renamed title. Hope this is ok...

User Comments: oehhar added on 2015-10-23 12:55:11:

Sorry, test failure probably due to time zone. Fixed that test only checks format by commit [3fdcaf2b64]. Thank you, Harald


dgp added on 2015-10-23 12:05:52:
New test fails:

==== clock-67.4 Change format %x output on global locale change [Bug 4a0c163d24] FAILED
==== Contents of test case:

    msgcat::mclocale de_de
    set res [list [clock format 1 -locale current -format %x]]
    msgcat::mclocale en_uk
    lappend res [clock format 1 -locale current -format %x]

---- Result was:
31.12.1969 12/31/1969
---- Result should have been (exact matching):
01.01.1970 01/01/1970
==== clock-67.4 FAILED

oehhar added on 2015-10-23 08:59:58:

Fix committed to trunk with [5855bdf4a8]. Bug closed.


oehhar added on 2015-10-21 20:33:40:

For the locale "system", %x translates to the msgcat key DATE_FORMAT, which is set by the registry key "HKEY_CURRENT_USER\Control Panel\International->sShortDate"

Here is the global map:

    lappend list %EY [string map $list [mc LOCALE_YEAR_FORMAT]]
    lappend list %T  [string map $list [mc TIME_FORMAT_24_SECS]]
    lappend list %R  [string map $list [mc TIME_FORMAT_24]]
    lappend list %r  [string map $list [mc TIME_FORMAT_12]]
    lappend list %X  [string map $list [mc TIME_FORMAT]]
    lappend list %EX [string map $list [mc LOCALE_TIME_FORMAT]]
    lappend list %x  [string map $list [mc DATE_FORMAT]]
    lappend list %Ex [string map $list [mc LOCALE_DATE_FORMAT]]
    lappend list %c  [string map $list [mc DATE_TIME_FORMAT]]
    lappend list %Ec [string map $list [mc LOCALE_DATE_TIME_FORMAT]]

And here is what is set by the registry (within "HKEY_CURRENT_USER\Control Panel\International") :

  • LOCALE_DATE_FORMAT: sLongDate
  • DATE_FORMAT: sShortDate
  • sTimeFormat: sTimeFormat Those are used to compose:
  • DATE_TIME_FORMAT
  • LOCALE_DATE_TIME_FORMAT

But for the locale current, the msgcat value is used. Thus, the observed action is ok, but is not ok for the locale current. On Unix, "current" and "system" is the same.

Thus the following is a bug:

% mclocale de_de
% clock format [clock seconds] -locale current -format %x
01.07.2015
# mclocale en_us
% clock format [clock seconds] -locale current -format %x
01.07.2015

A proposed solution is implemented by clearing the format functions on the current locale change (for this locale) in branch [bug-4a0c163d24], commit [e5bf4e6084].


oehhar added on 2015-08-31 08:42:58:
I have tried your test script with tcl 8.5.18, tcl8.6.4 and current trunk.

The issue is present in all version, so this is nothing I have introduced by the msgcat modifications.

There is code to detect that but maybee not at the right places or whatever.

Thank you,
Harald

oehhar added on 2015-08-31 06:58:40:
At least, I can confirm that this is a bug and should not happen.

Could you confirm if this is in 8.6.4 release or current trunk ?
In the first case please try the current trunk.

Thank you,
Harald