• Resolved landovloom

    (@landovloom)


    Hi Alwyn

    Thank you so much for this great plugin, that we would love to integrate.

    Is there a way to change the formatting of an events date?

    We are located in Switzerland and currently all dates are formatted like “M, jS Y” where we would prefer something like “j. F Y” (with the month name in german instead of english).

    It would also be great to be able to change the format of the events time to 24h instead of AM/PM.

    Kind regards,

    David

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Alwyn Barry

    (@dramb)

    Hi David.

    If you have any experience in coding, then you can use the plugin editor to edit the code to achieve this. The code is always in the cs-integration/public/shortcodes/class-cs-XXX-view.php files. For example the Event Card view code is on line 84 of the class-cs-event-card-view.php file and the time on line 86 and 87.

    I could add date/time format options to the short code. The problem would be sanitizing the input, but it’s doable. I’ll put it on my todo list, or you can raise a request on the GITHUB site.

    I have created a block version of this plugin – see https://en-gb.wordpress.org/plugins/blocks-for-churchsuite/. It’s the same underlying code as this plugin, but exposes the attribute parameters in the block editor, and shows the results as you make changes. I haven’t got a date format or time format option in that yet either, but it is certainly possible.

    Alwyn

    Plugin Author Alwyn Barry

    (@dramb)

    Of course, I potentially could use something like:

    $fmt = new IntlDateFormatter('de-DE', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
    echo "DE: ".$fmt->format($d)."<br/>";
    

    or to get a month name in a locale:

    $fmt = new IntlDateFormatter('de-DE', IntlDateFormatter::NONE, IntlDateFormatter::NONE, NULL, NULL, "MMM");
    $monthName = datefmt_format($fmt, mktime(0, 0, 0, $i));

    … but I’m not sure how well this will work for each country – the format produced might still not be what’s wanted. Anyway, I’ll look into this.

    • This reply was modified 3 months, 2 weeks ago by Alwyn Barry.
    Thread Starter landovloom

    (@landovloom)

    Hi Alwyn

    I opend a PR on your GitHub repo where i added the date / time format as optional options in the shortcode. Let me know what you think.

    Kind regards,
    David

    Plugin Author Alwyn Barry

    (@dramb)

    Just to say that I’ve updated the Blocks-For-ChurchSuite plugin so that it now uses the Locale to format all date and time output. I’ll move the changes back into this plugin as I have opportunity in the days ahead. Sorry for the prolonged delay in this – personal circumstances prevented the work.

    Plugin Author Alwyn Barry

    (@dramb)

    Ok, the Locale sensitive code is in now, and so should work ‘automatically’ to get the Dates and Times rendered appropriate to location. However, it could still be dependent on the server – it uses ‘Default’ as the Locale setting, which is that of your server. If this doesn’t produce the required results, let me know and I’ll get it to pick up the Locale setting from the WordPress settings instead.

    Plugin Author Alwyn Barry

    (@dramb)

    I’ve moved the Block Plugin to get the defaults set up for the WordPress Website (in the ‘General’ Settings) for locale and default time and date formats, and to render times and dates from those. This seems to work better – the server default wasn’t a useful way forward. I’ve also factored the time/date localisation code out into a single module to reduce code glut and improve maintainability. So I’ll move that code change into this shortcode soon so all can benefit.

    Plugin Author Alwyn Barry

    (@dramb)

    Ok, since v1.0.8 the shortcodes are now set to output dates, day and month names, and times using the locale for a site as set in the WordPress settings page: Settings->General. It will also use any custom time or date output set on that page. So, date/time output will automatically follow that set for the WordPress site.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.