pulsejet / banner-ics

Show calendar event banner from iCalendar attachments in Roundcube
https://packagist.org/packages/radialapps/banner-ics
MIT License
5 stars 5 forks source link

Show event date localized #2

Closed BathoryPeter closed 3 years ago

BathoryPeter commented 3 years ago

Showing the event date in the UI language would be a nice eye candy. Reading the RC code I found a date_format function that hopefully makes that easy:

$rcmail = rcmail::get_instance();
$rcmail->format_date();

I would be happy to send a PR but I have no working RoundCube installation yet and I think it would take more time than implementing the changes.

pulsejet commented 3 years ago

Neither do I. Docker to the rescue! This should also fix when users are in multiple timezones.

Note - I'm still in favor of keeping the date format hard-coded ... people rarely bother to configure it in roundcube settings.

BathoryPeter commented 3 years ago

Thank you, much better! Date format is relevant because of internalization. The English date format looks weird in most languages. For example in Hungarian we are using 2020.12.02. sze 14:00 – 15:00 (CEST). As I can see, both date and time format are supported by format_date() so they could look more natural.

pulsejet commented 3 years ago

Is there a way to use rcmail::format_date to format time using the set format?

EDIT: for clarity, I mean just get the time excluding the date

BathoryPeter commented 3 years ago

I think yes. In the config file, there is a separate entry for time: https://github.com/roundcube/roundcubemail/blob/8110ed9a9da0d99a7d87b9381a354a65014a5f4c/config/defaults.inc.php#L838 So this should work:

$dateString = $rcmail->format_date($date, $rcmail->config->get('date_format', 'D M d, Y'));
$timeString = $rcmail->format_date($date, $rcmail->config->get('time_format', 'h:i:a'));

The whole magic done by format_date() can be found here: https://github.com/roundcube/roundcubemail/blob/8110ed9a9da0d99a7d87b9381a354a65014a5f4c/program/include/rcmail.php#L1513

pulsejet commented 3 years ago

Just discovered that. Give me a minute ...

pulsejet commented 3 years ago

Using these now