HaikuArchives / Calendar

:calendar: A native Calendar application for Haiku.
MIT License
29 stars 20 forks source link

Use newly-exported libshared DateTimeEdit controls #118

Open JadedCtrl opened 2 years ago

JadedCtrl commented 2 years ago

Just swaps out the text controls with the exported DateEdit and TimeEdit. datetime

humdingerb commented 2 years ago

Now this is very, very nice! đź‘Ť I'll let this PR sit for a few days to see if other have some input. Looks very good to me!

nielx commented 2 years ago

Could you share your decision of including a copy of the control rather than including it from the system and linking to libshared.a?

pulkomandy commented 2 years ago

I don't see a copy of the Haiku code here? I see an identically named class that subclasses it and customizes the drawing a bit to add borders around it.

nielx commented 2 years ago

You're right, I overlooked that.

JadedCtrl commented 2 years ago

Hmm, that'd probably have to be done as a patch to DateTime in libshared, since the function determining it (DateTime::_UpdateFields) is private. It could be exposed as an option pretty easily.

I'm not sure how well that'd work across the board, though, since several locales use month-names in MEDIUM_FORMAT― I don't think the class necessarily requires sections to be numbers, though. If text doesn't render well, maybe using the the most complicated number-only format would work?

pulkomandy commented 2 years ago

It should be possible to extend the locale API to allow more control on the date format by using "skeletons" as documented here: https://cldr.unicode.org/translation/date-time/date-time-patterns

The idea is that you give a string with date fields such as "yMMd" and ICU can compute the proper format (in the right order and with appropriate separators). Then we can force to keep a numeric format while having a 4 digit year. Which is indeed not guaranteed with the "medium" format.

scottmc commented 1 year ago

@JadedCtrl any progress on this one?

JadedCtrl commented 1 year ago

@scottmc Unfortunately not, I haven't touched Haiku or Calendar code in a bit.