qt5core, qlocale, cldr and two digit years for some locales

155 views
Skip to first unread message

Fa Bio

unread,
Oct 13, 2016, 12:54:20 AM10/13/16
to golden-cheetah-users
After spending hours fiddling with /usr/share/i18n/locales files i found out (or i think to have find out) that the issue with two digit year with some locales in linux is caused by qt5core (qlocale) simply ignoring that settings but only reading locale language and country to apply cldr settings.
With language and country (honouring LC_TIME too) qt5core applyes hardcoded format settings, sourcing them when building from qlocale_data_p_h in src/corelib/tools in qtbase source code.
You can also read src/corelib/tools/qlocale.qdoc for some further info.

Searching for "F
ormats - Standard - Date Formats" in these pages
http://st.unicode.org/cldr-apps/v#/it/Gregorian/
http://st.unicode.org/cldr-apps/v#/en_GB/Gregorian/
you can see that the same short date value 9/14/99 becomes 14/09/99 for italian and 14/09/1999 for english, which i think causes the two digit year in italian locale and not in english locale.

So i think the only ways to have four digits years for some locales are:

-to make QDateEdit read dates in a different format than short (i don't know if it's possible) - or
-to change method to get dates (i don't know if it's possible) - or
-to hack qlocale_data_p_h to have four digit short date years and provide a new qt5core package with GC package.

I'll try to hack
qlocale_data_p_h (i have some spare time these days) but i think it's out of my reach, what do you think about my finding?
Does it makes sense?

Fa Bio

unread,
Oct 13, 2016, 1:00:05 PM10/13/16
to golden-cheetah-users
i enclose a screenshot in archlinux with modified qtcore package and italian locale :-)

i like archlinux more than ubuntu but i like the opportunity to download custom chart and i don't want to lose this chance only because i need to build GC myself, i'll try to do an italian qtcore Ubuntu package.
to make a package in ubuntu is much more complicated than in archlinux so i tested it in arch.

anyway, is there another way to get e.g. Ale's triscore PMC chart?

any chances that some developer could build an Archlinux package? I could provide the PKGBUILD file (after cleaning it, it's not following Arch's guidelines right now)

If required i could write (in my bad english) the whole procedure i followed in the wiki, it's not so complicated (for Arch) but it took me a lot of time to understand what to do.
qtrebuilt-archlinux.png

Ale Martinez

unread,
Oct 13, 2016, 5:15:27 PM10/13/16
to golden-cheetah-users
El jueves, 13 de octubre de 2016, 1:54:20 (UTC-3), Fa Bio escribió:
After spending hours fiddling with /usr/share/i18n/locales files i found out (or i think to have find out) that the issue with two digit year with some locales in linux is caused by qt5core (qlocale) simply ignoring that settings but only reading locale language and country to apply cldr settings.
With language and country (honouring LC_TIME too) qt5core applyes hardcoded format settings, sourcing them when building from qlocale_data_p_h in src/corelib/tools in qtbase source code.
You can also read src/corelib/tools/qlocale.qdoc for some further info.

Searching for "F
ormats - Standard - Date Formats" in these pages
http://st.unicode.org/cldr-apps/v#/it/Gregorian/
http://st.unicode.org/cldr-apps/v#/en_GB/Gregorian/
you can see that the same short date value 9/14/99 becomes 14/09/99 for italian and 14/09/1999 for english, which i think causes the two digit year in italian locale and not in english locale.

So i think the only ways to have four digits years for some locales are:

-to make QDateEdit read dates in a different format than short (i don't know if it's possible) - or
I think this is possible using the setDisplayFormat method, but this would disable the ability of the user to set his preferred date format, although it can be left as a translator option.

-to change method to get dates (i don't know if it's possible) - or
A calendar popup could be enabled, you can try if adding the following line:
dateEdit->setCalendarPopup(true);
works to set Power Zones with your native locale.

Fa Bio

unread,
Oct 14, 2016, 12:55:27 AM10/14/16
to golden-cheetah-users

Hi Ale, this could be an easy fix for two digits year locales. I patched newcyclist.cpp too and, being born in 1966, i find a little bit depressing scroll back to 1966 to insert my dob :-)
If GC's developers decide to follow this way maybe it could be the case to patch charts date selection too, i see weird things when i select date intervals in chart.

As far as i'm concerned i think i'll patch my qtcore lib, i'm too old for calendar in dob :-) but i think that this is not a bad idea

Thanks
calendar.png

Fa Bio

unread,
Oct 14, 2016, 2:27:23 AM10/14/16
to golden-cheetah-users
A good solution could be to format newcyclist.cpp and put a calendar option elsewhere.

Ale Martinez

unread,
Oct 14, 2016, 7:58:17 PM10/14/16
to golden-cheetah-users
What I like about to enable calendar popup is that it adds to usability without changing anything else, even to create a New Athlete it took me 2 clicks on the calendar popup to go to my DOB in 1962 ;-)

Fa Bio

unread,
Oct 15, 2016, 3:42:30 AM10/15/16
to golden-cheetah-users
It's very likely (read sure) that you know that option better than me, so i probably did it the longest way.
Please, let me know if you and other developers opt for calendar solution.
Thank you very much

Ale Martinez

unread,
Oct 15, 2016, 8:23:44 AM10/15/16
to golden-cheetah-users
El sábado, 15 de octubre de 2016, 4:42:30 (UTC-3), Fa Bio escribió:
It's very likely (read sure) that you know that option better than me, so i probably did it the longest way.
The month and year at the top row allows to jump directly to the month of the year you want.
 
Please, let me know if you and other developers opt for calendar solution.
I created a Pull Request (https://github.com/GoldenCheetah/GoldenCheetah/pull/2138), it is not merged yet, but it would be useful if you can test it in your locale using 2 digits years. 
Thanks, Ale.

Fa Bio

unread,
Oct 15, 2016, 10:25:11 AM10/15/16
to golden-cheetah-users
Hi Ale, today I am sick and I have a high fever, as soon as possible (i hope tomorrow) i'll made the mods in you pull request and start testing it in Ubuntu.

Mark Liversedge

unread,
Oct 15, 2016, 1:09:36 PM10/15/16
to golden-cheetah-users
On Saturday, 15 October 2016 15:25:11 UTC+1, Fa Bio wrote:
Hi Ale, today I am sick and I have a high fever, as soon as possible (i hope tomorrow) i'll made the mods in you pull request and start testing it in Ubuntu.

Get well !

There is plenty of time, do it when you are ready

CHEERS

Mark 

Fa Bio

unread,
Oct 16, 2016, 5:06:00 AM10/16/16
to golden-cheetah-users
Thanks, today i'm well and i'm in front of PC to avoid bedsores :-)
I made some fast test and after i found out how to fast modify year :-D it seems to works well, there are only two downside that i can see:
1)you can't know of calendar esistence if you don't click on the right side arrow, so maybe if you choose to go this way this should be documented somewhere (maybe i'm still missing something?);
2)for some reason in my Mate desktop Linuxmint the year field get partially hidden (see enclosed screenshots), this does not happen with LXQT so i think that it's desktop related. I don't know if this can be avoided but it's not a real issue, only cosmetic.
Greetings
Fabio
GC.png
GCcalendar.png

Ale Martinez

unread,
Oct 16, 2016, 11:34:46 AM10/16/16
to golden-cheetah-users
El domingo, 16 de octubre de 2016, 6:06:00 (UTC-3), Fa Bio escribió:
Thanks, today i'm well and i'm in front of PC to avoid bedsores :-)
I made some fast test and after i found out how to fast modify year :-D it seems to works well, there are only two downside that i can see:
1)you can't know of calendar esistence if you don't click on the right side arrow, so maybe if you choose to go this way this should be documented somewhere (maybe i'm still missing something?);
2)for some reason in my Mate desktop Linuxmint the year field get partially hidden (see enclosed screenshots), this does not happen with LXQT so i think that it's desktop related. I don't know if this can be avoided but it's not a real issue, only cosmetic.
Greetings
Fabio
I thought the down arrow is common enough but, if you think it needs to be explained you are welcome to add an explanation to the wiki, there is even a Translation/Localization section intended to document specifics of Languages and Locales: https://github.com/GoldenCheetah/GoldenCheetah/wiki/UG_Main-Page_Table-of-contents#translationlocalization
WRT the cosmetic issue I also see it on pre-existing QDateEdit fields with calendar popups, I have no idea why this happens nor how it can be solved, ideas are welcome.
Thanks for your comments, I will merge it as is for now.

Fa Bio

unread,
Oct 16, 2016, 11:57:14 AM10/16/16
to golden-cheetah-users
Do i need a github account to edit the wiki? Is there an how-to about it?

Ale Martinez

unread,
Oct 16, 2016, 12:20:07 PM10/16/16
to golden-cheetah-users
El domingo, 16 de octubre de 2016, 12:57:14 (UTC-3), Fa Bio escribió:
Do i need a github account to edit the wiki?
Yes
 
Is there an how-to about it?

Fa Bio

unread,
Oct 16, 2016, 12:43:39 PM10/16/16
to golden-cheetah-users
Thanks

Fa Bio

unread,
Oct 17, 2016, 2:02:06 AM10/17/16
to golden-cheetah-users
For the sake of curiosity i built ubuntu QT5 packages with a modified qlocale_data_p_h which provides four digit short year format to it_* locales.
I Installed these packages and found out that your GoldenCheetah binary file does not change dates format while the binary file i built myself does.
The output of
ldd /opt/GoldenCheetah/GoldenCheetah
tells me that you already provide a custom version of some libs, at least for linux os:

fabio@asus ~ $ ldd /opt/GoldenCheetah/GoldenCheetah
    linux-vdso.so.1 =>  (0x00007fff6a1dd000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb0b473b000)
    libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fb0b44d2000)
    libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fb0b408d000)
    libGLU.so.1 => /usr/lib/x86_64-linux-gnu/libGLU.so.1 (0x00007fb0b3e1e000)
    libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fb0b3c06000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb0b3a01000)
    libvlc.so.5 => /usr/lib/libvlc.so.5 (0x00007fb0b37e1000)
    libsamplerate.so.0 => /usr/lib/x86_64-linux-gnu/libsamplerate.so.0 (0x00007fb0b3475000)
    libQt5Svg.so.5 => /opt/GoldenCheetah/lib/libQt5Svg.so.5 (0x00007fb0b3220000)
    libQt5WebKitWidgets.so.5 => /opt/GoldenCheetah/lib/libQt5WebKitWidgets.so.5 (0x00007fb0b2fd9000)
    libQt5OpenGL.so.5 => /opt/GoldenCheetah/lib/libQt5OpenGL.so.5 (0x00007fb0b2d82000)
    libQt5Widgets.so.5 => /opt/GoldenCheetah/lib/libQt5Widgets.so.5 (0x00007fb0b2502000)
    libQt5WebKit.so.5 => /opt/GoldenCheetah/lib/libQt5WebKit.so.5 (0x00007fb0aff4b000)
    libQt5Gui.so.5 => /opt/GoldenCheetah/lib/libQt5Gui.so.5 (0x00007fb0af739000)
    libQt5Xml.so.5 => /opt/GoldenCheetah/lib/libQt5Xml.so.5 (0x00007fb0af4fc000)
    libQt5Sql.so.5 => /opt/GoldenCheetah/lib/libQt5Sql.so.5 (0x00007fb0af2bc000)
    libQt5Network.so.5 => /opt/GoldenCheetah/lib/libQt5Network.so.5 (0x00007fb0aef63000)
    libQt5Concurrent.so.5 => /opt/GoldenCheetah/lib/libQt5Concurrent.so.5 (0x00007fb0aed5c000)
    libQt5SerialPort.so.5 => /opt/GoldenCheetah/lib/libQt5SerialPort.so.5 (0x00007fb0aeb42000)
    libQt5Bluetooth.so.5 => /opt/GoldenCheetah/lib/libQt5Bluetooth.so.5 (0x00007fb0ae895000)
    libQt5Core.so.5 => /opt/GoldenCheetah/lib/libQt5Core.so.5 (0x00007fb0ae14e000)
    libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007fb0adedd000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb0adcc0000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb0ad93d000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb0ad634000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb0ad41e000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb0ad054000)
    libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fb0ad034000)
    /lib64/ld-linux-x86-64.so.2 (0x0000555d431d1000)
    libvlccore.so.8 => /usr/lib/libvlccore.so.8 (0x00007fb0acd34000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fb0acb22000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fb0ac7e8000)
    libxslt.so.1 => /usr/lib/x86_64-linux-gnu/libxslt.so.1 (0x00007fb0ac5aa000)
    libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007fb0ac222000)
    libgstapp-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstapp-0.10.so.0 (0x00007fb0ac015000)
    libgstinterfaces-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstinterfaces-0.10.so.0 (0x00007fb0abe02000)
    libgstpbutils-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstpbutils-0.10.so.0 (0x00007fb0abbde000)
    libgstvideo-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstvideo-0.10.so.0 (0x00007fb0ab9c1000)
    libgstbase-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstbase-0.10.so.0 (0x00007fb0ab766000)
    libgstreamer-0.10.so.0 => /usr/lib/x86_64-linux-gnu/libgstreamer-0.10.so.0 (0x00007fb0ab477000)
    libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fb0ab224000)
    libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fb0ab01f000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fb0aae1d000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb0aac15000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fb0aa903000)
    libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fb0aa549000)
    libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007fb0aa274000)
    libQt5Sensors.so.5 => /opt/GoldenCheetah/lib/libQt5Sensors.so.5 (0x00007fb0aa037000)
    libQt5Positioning.so.5 => /opt/GoldenCheetah/lib/libQt5Positioning.so.5 (0x00007fb0a9dfa000)
    libQt5PrintSupport.so.5 => /opt/GoldenCheetah/lib/libQt5PrintSupport.so.5 (0x00007fb0a9b8c000)

    libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fb0a9981000)
    libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007fb0a977e000)
    libicui18n.so.54 => /opt/GoldenCheetah/lib/libicui18n.so.54 (0x00007fb0a930f000)
    libicuuc.so.54 => /opt/GoldenCheetah/lib/libicuuc.so.54 (0x00007fb0a8f61000)
    libicudata.so.54 => /opt/GoldenCheetah/lib/libicudata.so.54 (0x00007fb0a7537000)
    libQt5Quick.so.5 => /opt/GoldenCheetah/lib/libQt5Quick.so.5 (0x00007fb0a6f67000)
    libQt5Qml.so.5 => /opt/GoldenCheetah/lib/libQt5Qml.so.5 (0x00007fb0a6938000)
    libQt5WebChannel.so.5 => /opt/GoldenCheetah/lib/libQt5WebChannel.so.5 (0x00007fb0a671b000)
    libQt5DBus.so.5 => /opt/GoldenCheetah/lib/libQt5DBus.so.5 (0x00007fb0a649e000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fb0a6274000)
    libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007fb0a6071000)
    libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007fb0a5e6e000)
    libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007fb0a5c66000)
    libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007fb0a5a63000)
    libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007fb0a5835000)
    libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007fb0a5631000)
    libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fb0a542b000)
    libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fb0a5229000)
    libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007fb0a500f000)
    libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007fb0a4e0a000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fb0a4be8000)
    libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007fb0a49e1000)
    libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007fb0a47d2000)
    libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007fb0a459e000)
    libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fb0a4352000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fb0a4130000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fb0a3f14000)
    liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007fb0a3c94000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fb0a3a8b000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fb0a381b000)
    libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007fb0a3487000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fb0a3264000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fb0a305f000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fb0a2e59000)
    libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fb0a2dd4000)
    libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007fb0a131c000)
    libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fb0a103b000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fb0a0e26000)

So wouldn't it be better to change
qlocale_data_p_h to give 4 digits year to all locales while you build the custom libQt5* you provide with the deb package instead of changing source code?
I could provide you a
qlocale_data_p_h with 4 digit year for all locales even if it's trivial to produce it, QT5base source code provides the instruments to do it in util/localdatabase provided you have cldr database main directory somewhere in the building machine.
It would work out of the box for every linux locale and you should not need to change your code nor your way to distribute binaries and i could edit the wiki posting the
qlocale_data_p_h which give four years digit to the more skilled linux users with wrong locales who wants to build himself both GC and qt5.
I think that this would be the better way to follow to leave a newbye Ubuntu user full enjoy GoldenCheetah without troubles, wouldn't you?


G Coco

unread,
Oct 24, 2016, 8:51:55 PM10/24/16
to golden-cheetah-users


On Monday, October 17, 2016 at 2:02:06 AM UTC-4, Fa Bio wrote:
For the sake of curiosity i built ubuntu QT5 packages with a modified qlocale_data_p_h which provides four digit short year format to it_* locales.
I Installed these packages and found out that your GoldenCheetah binary file does not change dates format while the binary file i built myself does.
The output of
ldd /opt/GoldenCheetah/GoldenCheetah
tells me that you already provide a custom version of some libs, at least for linux os:

Hi,

The QT libs are the ones provided by QT via the Linux QT install downloads. The .deb has them bundled in and GC references them so that we could QT 5.5.1 on all Linux builds.

There are some static libs used to create the builds as well which you do not see.

Gareth

Fa Bio

unread,
Oct 25, 2016, 2:12:55 AM10/25/16
to golden-cheetah-users
Well, if i copy my it-locale 4digit short year libqt5gui and libqt5core libs in /opt/goldencheetah/libs i get 4 digits year in my locale too with your GC binary file without rebuilding. This broke maps showing but i think this is due to some other libs to change, it works well in my self built GC.
I just don't understand why not to provide a qt5 lib wich works well with GC in all locales, you could do it while building binary file and libs. But i'm not a dev so this is your choice. Greetings Fabio
Reply all
Reply to author
Forward
0 new messages