Currently, the timeslot field displays the correct timezone wherever it is used. However, the token which creates the automatic title for the Timeslot content type is not taking time zones into account, regardless of the site's time zone settings. I believe this is a quick fix to the tokens which generate the node title for the Timeslot content type.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 1703332-timeslots-use-correct-timezone-user-2.patch | 979 bytes | CountPacMan |
| #17 | 1703332-timeslots-use-correct-timezone-user-1.patch | 1.01 KB | CountPacMan |
| #14 | 2015-05-31_time_label_issue.png | 16.04 KB | jcicolani |
| #12 | Screen Shot 2013-08-22 at 10.17.31 PM.png | 27.29 KB | rootwork |
| #9 | 1703332-cod_session-automatic_titles-9.patch | 719 bytes | chrisguindon |
Comments
Comment #1
ezra-g commentedJust updating the title to clarify the desired behavior (vs using user timezones). Thanks!
Comment #2
ezra-g commentedComment #3
sheldonkreger commentedI did some additional testing. The issue is the same as described in OP. See image below. I had modified both the sitewide and user time settings . . . then I created the node.
field_slot_datetime is working correctly, but the node titles are displaying correctly. By default, it reflects the sitewide time zone settings.The display of field_slot_datetime also changes for users in different timezones. That's awesome! That's what we would like to have happen to the node titles, as well.
The problems lies in the token which is used to generate the title of the node. Although the pattern is set to [node:field_slot_datetime], it's converting it to GMT when it creates the node:
There may be a way to configure around this, or it could be a general problem with the way the node title is generated - which would be outside of the scope of COD. I'm curious if anybody knows a quick way to fix this.
Comment #4
sheldonkreger commentedThis appears to be an issue with Automatic Nodetitles and the way it handles tokens. This seems to be a closely related issue #1197278: Date tokens are not displaying correctly.
Comment #5
langworthy commentedclosed #1837918: Timeslot title uses UTC not site timezone as a duplicate of this issue
Comment #6
langworthy commentedThis seems to be because dates are stored in UTC and token.module is not doing any conversion #1103032: Document how to use date tokens
I tried using an entity_token.module pattern instead, like
[node:field-slot-datetime:medium]. But the token literal becomes the title.Comment #7
langworthy commentedI got this working using the following ANT pattern
[node:field-slot-datetime:value:custom:l M j g:ia] - [node:field-slot-datetime:value2:custom:l M j g:ia]and a D7 version of the patch here http://drupal.org/node/1035292#comment-6659022 to allow spaces in tokens.Comment #8
ezra-g commentedSince "displaying wrong event time" is a fairly critical aspect of an event management tool, I'm marking as critical and "needs work" pending a patch for #7.
Comment #9
chrisguindon commentedAttach is a patch that replace the title pattern to [node:field-slot-datetime:value:custom:l, M j, Y H:i] - [node:field-slot-datetime:value2:custom:l, M j, Y H:i].
This is based off comment #7 but I made some changes. This is an example of how the title date will appear:
Thursday, May 30, 2013 00:00 - Thursday, May 30, 2013 20:00
Comment #10
ezra-g commentedAwesome - Thanks, chrisguindon!
Marking as "needs review".
Comment #11
gregglesI didn't test the patch, but I put the pattern in place and conceptually I agree that pattern is better.
Comment #12
rootworkThis is great, and would also fix the same issue where you add allowed slots to a room:
It might be worth considering if this specific configuration should be documented, since some sites might want to change the display of the time (e.g. with 12-hour + AM/PM).
But this patch is HUGE improvement on the current situation.
Comment #13
japerryOh forgot to mark this as fixed.. from a while ago! Its now based upon the timezone set in the time entity itself.
Comment #14
jcicolani commentedThe patch seems to no longer apply to the cod_session.strongarm.inc file and the node titles are displaying 5 hours off of the selected times.
Comment #15
timwood@jcicolani
The patch I provided here: https://www.drupal.org/node/2407607#comment-9999695
seems to do the trick for us. Not sure whether it's correct or not.
Comment #16
japerryComment #17
CountPacMan commentedPrevious patch removed offset which made it store the user's time zone time in the db. I broke out the logic of what is generated for the time stored in the db and what is generated for the label.
Comment #18
BabaYaga64 commentedI was able to apply CountPacMan's patch and now I'm able to create time slots for events based on appropriate timezones, and now the time slots display based on the event timezones, and not the user or site timezones.
Comment #19
CountPacMan commentedupdated patch to remove extraneous code and wrap in t()
Comment #20
pcorbett commentedJust so that we're clear, the fix at https://www.drupal.org/node/2407607#comment-9999695 seems to work well (although it may make sense to wrap in t() as in @CountPacMan's patch #19). Is there a particular reason why we're not formatting the date any longer (e.g., 4:45pm vs. 2015-07-31 16:45:00)? I suggest that https://www.drupal.org/node/2407607 and this aren't any different really and one should fall in favor for the other.
Comment #21
japerryThis is fixed in the 2.x branch.