Bug 30412 - d_t_fmt in id_ID uses %r placeholder but am_pm and t_fmt_ampm are undefined
Summary: d_t_fmt in id_ID uses %r placeholder but am_pm and t_fmt_ampm are undefined
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: localedata (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.39
Assignee: Mike FABIAN
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-02 10:49 UTC by Philip Withnall
Modified: 2023-12-19 10:24 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
attachment-3741274-0.html (568 bytes, text/html)
2023-12-18 08:44 UTC, Zhafran Rama Azmi
Details
attachment-1830105-0.html (633 bytes, text/html)
2023-12-19 07:00 UTC, Zhafran Rama Azmi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Withnall 2023-05-02 10:49:45 UTC
See https://gitlab.gnome.org/GNOME/glib/-/issues/2967#note_1719623 for context.

The following definitions currently exist in localedata/locales/id_ID (https://github.com/bminor/glibc/blob/master/localedata/locales/id_ID):
```
d_t_fmt     "%a %d %b %Y %r"
date_fmt    "%a %d %b %Y %r %Z"
am_pm       "";""
t_fmt_ampm  ""
```

It seems inconsistent to use `%r` in `d_t_fmt`/`date_fmt` while also having `am_pm` and `t_fmt_ampm` undefined.

Apparently `date` uses a fallback in this case. GLib (for better or worse) does not, which causes date formatting using `d_t_fmt`/`date_fmt` to fail in id_ID. We could change GLib to apply a fallback, but in this case it looks to me like it’s the localedata that’s wrong.

There are some proposed changes to the locale strings here: https://gitlab.gnome.org/GNOME/glib/-/issues/2967#note_1713065, based on the fact that Indian standard time uses the 24-hour clock rather than 12-hour, so `d_t_fmt`/`date_fmt` should not use `%r` at all.

The proposed changes are:
```
-d_t_fmt     "%a %d %b %Y %r"
-date_fmt    "%a %d %b %Y %r %Z"
+d_t_fmt     "%a %d %b %Y %T %Z"
+date_fmt    "%a %d %b %Y %T %Z"
```
and
```
-am_pm       "";""
-t_fmt_ampm  ""
+am_pm       "AM";"PM"
+t_fmt_ampm  "%I:%M:%S %p"
```
Comment 1 Andreas Schwab 2023-05-02 11:18:00 UTC
If t_fmt_ampm is empty, it defaults to "%I:%M:%S %p".
Comment 2 Philip Withnall 2023-05-15 14:33:12 UTC
(In reply to Andreas Schwab from comment #1)
> If t_fmt_ampm is empty, it defaults to "%I:%M:%S %p".

And presumably hence if am_pm is empty then it also defaults to `"AM";"PM"` for this to work?

Would your preferred fix be for
 1. localedata to use `%T %Z` rather than `%r` in `d_t_fmt`/`date_fmt`; or
 2. GLib to use `%I:%M:%S %p` for `t_fmt_ampm` if it’s otherwise undefined?
Comment 4 Zhafran Rama Azmi 2023-12-18 08:44:04 UTC
Created attachment 15262 [details]
attachment-3741274-0.html

Hey, I would like to inform that i'm currently having this on hold, got 
one thing wrong, that is it turns out first weekday is indeed sunday 
here, so I'm going to correct that, rest are still correct. I would 
also like to collect evidence and the likes

Pada Sen, 18 Des 2023 pada 08:22:26 +00:00:00, maiku.fabian at gmail 
dot com via Libc-locales <libc-locales@sourceware.org> menulis:
> <https://sourceware.org/bugzilla/show_bug.cgi?id=30412>
> 
> Mike FABIAN <maiku.fabian at gmail dot com> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>    Target Milestone|---                         |2.39
>            Assignee|unassigned at sourceware dot org   |maiku.fabian 
> at gmail dot com
> 
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 5 Sourceware Commits 2023-12-18 09:23:07 UTC
The master branch has been updated by Mike Fabian <mfabian@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=12ab77e893479a1f7d4666082a48efad79777bb9

commit 12ab77e893479a1f7d4666082a48efad79777bb9
Author: RushingAlien <rushing27alien@gmail.com>
Date:   Mon Aug 21 10:55:30 2023 +0700

    id_ID: Update Time Locales
    
    Hello! I am Indonesian, was born and raised in Indonesia and still do live in
    Indonesia.
    
    This patch brings a few changes to the time locales of id_ID, which
    includes :
    \- Defining am_pm and time_fmpt_ampm
    \- Changing time_fmt and d_t_fmt to use the 24-hour format
    \- Changing first_weekday to Monday
    This is a squashed version of what is previously a 5 patch set
    
    Here are reasons and details of the changes :
    
    Change 1 part 1
    
    id_ID: Define `am_pm` string
    
    Current formatting does not define am_pm string, leading to AM and PM
    not being specified in 12 H time format. This change defines the string
    by changing it from an empty string to "AM";"PM".
    
    output of `date +%r`:
    before commit: 01:23
    after commit: 01:23 PM
    
    Change 1 part 2
    
    id_ID: Define time_fmt_ampm, change from an empty string
    
    Currently, time_fmpt_ampm is set to an empty string, causing some
    programs to not be able to display time in the 12-hour format, for
    example, glib: https://gitlab.gnome.org/GNOME/glib/-/issues/2967.
    This commit changes it from an empty string to "%I:%M:%S %p"
    
    Change 2 part 1
    
    id_ID: Use 24-hour format for time_fmt
    
    Indonesian standard and formal time format uses the 24-hour format inst-
    ead of the 12-hour format. This commit aims to change the id_ID locale's
    time_fmt to match that accordingly.
    
    Change 2 part 2
    
    id_ID: Use 24-hour format for d_t_fmt.
    
    Indonesian standard and formal time format uses the 24-hour format inst-
    ead of the 12-hour format. This commit aims to change the id_ID locale's
    d_t_fmt to match that accordingly.
    
    Change 3
    
    id_ID: Change first_weekday to monday
    
    Indonesian calendar starts of the week with Monday, let's comply
    
    Message-ID: <20230821035530.9075-1-rushing27alien@gmail.com>
    Resolves: BZ # 30412
    Reviewed-by: Mike Fabian <mfabian@redhat.com>
Comment 6 Mike FABIAN 2023-12-18 09:25:26 UTC
(In reply to Zhafran Rama Azmi from comment #4)
> Created attachment 15262 [details]
> attachment-3741274-0.html
> 
> Hey, I would like to inform that i'm currently having this on hold, got 
> one thing wrong, that is it turns out first weekday is indeed sunday 
> here, so I'm going to correct that, rest are still correct. I would 
> also like to collect evidence and the likes

Oh, sorry, I didn't see that before committing.

So I need to correct the first weekday to Sunday?
Comment 7 Zhafran Rama Azmi 2023-12-19 07:00:42 UTC
Created attachment 15265 [details]
attachment-1830105-0.html

Yes, that is correct

Pada Sen, 18 Des 2023 pada 09:25:26 +00:00:00, maiku.fabian at gmail 
dot com via Libc-locales <libc-locales@sourceware.org> menulis:
> <https://sourceware.org/bugzilla/show_bug.cgi?id=30412>
> 
> --- Comment #6 from Mike FABIAN <maiku.fabian at gmail dot com> ---
> (In reply to Zhafran Rama Azmi from comment #4)
>>  Created attachment 15262 [details]
>>  attachment-3741274-0.html
>> 
>>  Hey, I would like to inform that i'm currently having this on hold, 
>> got
>>  one thing wrong, that is it turns out first weekday is indeed sunday
>>  here, so I'm going to correct that, rest are still correct. I would
>>  also like to collect evidence and the likes
> 
> Oh, sorry, I didn't see that before committing.
> 
> So I need to correct the first weekday to Sunday?
> 
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 8 Sourceware Commits 2023-12-19 10:23:35 UTC
The master branch has been updated by Mike Fabian <mfabian@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1e7025250843f234ac6743dd0dcd8aa9018bae3f

commit 1e7025250843f234ac6743dd0dcd8aa9018bae3f
Author: Mike FABIAN <mfabian@redhat.com>
Date:   Tue Dec 19 10:48:42 2023 +0100

    localedata: id_ID: change first weekday to Sunday
    
    Resolves: BZ # 30412
    
    See: https://sourceware.org/bugzilla/show_bug.cgi?id=30412#c7
    
    CLDR also has ID in the list of territories which have Sunday as the
    first day of the week.
Comment 9 Mike FABIAN 2023-12-19 10:24:49 UTC
Fixed in glibc master.