[Development] QCalendar and QCalendarBackend questions

Gary Wang wzc782970009 at gmail.com
Mon Dec 28 12:53:27 CET 2020


*

> Just add it to Qt, if it is useful. I don't think

> we should accept obsolete, fictional, or similar calendars, but if your

> proposal of Chinese Lunar calendar actually has uses, we should simply have it

> in QtCore.

*
*

Agree! Chinese lunar calendar is widely used in mainland China and

all major calendar application like Google Calendar and Outlook both

support set Chinese lunar calendar as alternate calendar system to

make the date display under the main calendar, so I guess it could

be great to get Chinese calendar support directly from QtCore :)

*
*

Actually the reason I wish there is a public API to add custom calendar

system is because implement a Chinese calendar system from scratch seems

not be a very simple work to do, if the goal is do a quick implementation

for my need, then I could just use other libraries which already support

Chinese calendar system and use that to implement the Qt APIs. ICU

already supports Chinese calendar and I am using ICU currently. It

could be good if we can push such support into Qt (and KDE) but obviously

we'll need a clean implementation than a random dirty-but-works one.

*
*

> The question there is where we'd get the l10n data in the first place. Is it

> in ICU?

*
*

Sadly the localized day name isn't in ICU. I found there is a proposal 
in CLDR [1]

but seems not get approved/implemented yet. ICU do support get the Cyclic

year name, though.

*
*

To get a chinese calendar instance from ICU for testing, we can use the 
following

code:

*
*

Locale locale("en_US", 0, 0, "calendar=chinese");

UErrorCode errorCode = U_ZERO_ERROR;

m_cal = Calendar::createInstance(TimeZone::createTimeZone("GMT+8:00"), 
locale, errorCode);

*
*

Then `SimpleDateFormat` can be used to get localized strings, "U" can be 
used

**

for Cyclic year name for example [2], but there are no patterns for 
getting a localized

**

day name at this moment.

*
*

Since the initial goal is adding Alternate Calendar display support for 
KDE, I

did a test repo which uses ICU4C for Chinese calendar system support to 
create

the KDE applet [3]. The code may be useful to do some quick tests.

*
**
*

[1]: 
http://cldr.unicode.org/development/development-process/design-proposals/chinese-calendar-support

[2]: 
https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1SimpleDateFormat.html#details

[3]: https://github.com/BLumia/pineapple-calendar

*



More information about the Development mailing list