Comment 1 for bug 603172

Revision history for this message
Fumihito YOSHIDA (hito) wrote :

gedit-2.30.3/plugins/time/gedit-time-plugin.cのget_time()において、ロケールによる挙動を一切無視した実装が行われている。

以下でフォーマットを宣言して、そのままget_time()でstrftimeする作りになっているのが問題。

static const gchar *formats[] =
{
        "%c",
        "%x",
        "%X",
        "%x %X",
        "%Y-%m-%d %H:%M:%S",
        "%a %b %d %H:%M:%S %Z %Y",
        "%a %b %d %H:%M:%S %Y",
        "%a %d %b %Y %H:%M:%S %Z",
        "%a %d %b %Y %H:%M:%S",
        "%d/%m/%Y",
        "%d/%m/%y",
#ifndef G_OS_WIN32
        "%D", /* This one is not supported on win32 */
#endif
        "%A %d %B %Y",
        "%A %B %d %Y",
        "%Y-%m-%d",
        "%d %B %Y",
        "%B %d, %Y",
        "%A %b %d",
        "%H:%M:%S",
        "%H:%M",
        "%I:%M:%S %p",
        "%I:%M %p",
        "%H.%M.%S",
        "%H.%M",
        "%I.%M.%S %p",
        "%I.%M %p",
        "%d/%m/%Y %H:%M:%S",
        "%d/%m/%y %H:%M:%S",
#if __GLIBC__ >= 2
        "%a, %d %b %Y %H:%M:%S %z",
#endif
        NULL
};

選択肢 a) 単純な対応:
setlocale(LC_ALL, ""); をstrftimeの直前にいれて、本来のロケールに戻すsetlocaleを直後に入れる。

選択肢 b) まじめだが面倒な対応
フォーマット文字列をロケール情報も含めたものにするか、もしくはstrftimeに頼らない構造にする。