Problem/Motivation

The need of having an option to display the event times in month view in my preferred format using the date formatting strings and characters given by Fullcalendar and momentJS

Proposed resolution

Add a field in the display fullcalendar_view settings to edit the timeFormat according Fullcalendar and MomentJS rules.

I join a patch in #2 that works correctly for me.

User interface changes

In Fullcalendar view display settings, find a new field labelled "Time Format settings for month view" in display section where you can edit at your own. If you leave it blank the time will be default formatted according Fullcalendar default.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pslcbs created an issue. See original summary.

pslcbs’s picture

Mingsong’s picture

Thank you so much, @pslcbs

I will have a look a the patch attached.

DuaelFr’s picture

This is just a reroll on the last dev version.

DuaelFr’s picture

This patch

  1. fixes the time format having been hardcoded in the JS
  2. adds a default value consistent with the default value of the JS lib

  • DuaelFr authored 209e82a on 8.x-2.x
    Issue #3053438 by DuaelFr, pslcbs: Add option to edit timeFormat in...
Mingsong’s picture

Committed.

Thanks a lots for Edouard and Juan.

Mingsong’s picture

Status: Needs review » Reviewed & tested by the community
Mingsong’s picture

Status: Reviewed & tested by the community » Fixed
Mingsong’s picture

Actually, there is a minor issue with the #5 patch in which the url placeholders.

I fixed it with the latest dev version.

DuaelFr’s picture

Well done! I did not check this part while doing my last patch.
I'd have an other suggestion, though. When using placeholders for URLs, you should prefix them by ":" instead of "@" to ensure they are filtered.
@see \Drupal\Component\Render\FormattableMarkup::placeholderFormat()

Mingsong’s picture

Thanks Edouard.

That is a really good point.

I am using the Url::fromUri() to create the URL and the placeholder is prefixed by '%'. I believe that there should be no security issue.

More details about output sanitisation:

https://www.drupal.org/docs/8/security/drupal-8-sanitizing-output

I also sanitise the user input by using Xss::filter()

The codes details are here:
https://git.drupalcode.org/project/fullcalendar_view/commit/099bb78

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

maxstarkenburg’s picture

I'm wondering if this stopped working between 8.x-2.x and higher versions. I tried out the recommended version today (5.0.1), having not used this module before. No matter what I'm changing the value to in my View, it would seem that it's always outputting things in h(:mm)a format (I think ... my times in month view are showing as things like "4p" and "11:01a").

Mingsong’s picture

Version: 8.x-2.x-dev » 5.0.1
FileSize
3.98 KB

Thanks for reporting.

Here is the patch to fix it for version 5.0.1

Mingsong’s picture

Released with 5.0.2