I didn't see this reported elsewhere, so I will now do so. I am running into an issue with 5.x-2.0-rc (haven't checked other versions) with timezones in the formatter. Specifically, they don't show up, ever.

What I am trying to do: I want to be able to set the timezone of an event when it is created, and have it always show in the user's timezone *with* timezone identifier. ("Event" is a node type that has only one CCK field on it, a date field.)

What is happening: I am only able to set the timezone of the event if the field is set to display the date in "Date's time zone". If I want it to display in the user's timezone, then I cannot. (Since the "native" time of the event is not the same as my timezone when creating it, that is a problem.) Furthermore, regardless of what I have set as the display format the timezone identifier never appears.

Test case (verbal):

Create a node type "event" with no fields but a date field. Set the input format to anything. (This is where there should be a setting to specify the timezone explicitly or not, IMO.) Set the granularity to all fields (note timezone is not included!). Under Default Display, select any format that includes the string-based timezone or specify a custom format string that includes 'e' (which is the code for the timezone). Set the timezone handling to "Date's time zone" so that you can set a timezone explicitly.

Set the site timezone to America/New York.

Set your user's timezone to America/Chicago.

Create a new event (the node type created above) and set the time to noon (12 pm) and the timezone to America/Denver. The date doesn't matter.

Save the node. The date field should display something like: 5 July 2008 12:00 pm (Note the lack of a timezone!)

Now, change the field settings to show "site's timezone". Clear the cache and review the node you just created. It still shows "5 July 2008 12:00 pm". (It should now be showing 2 pm, since Denver is 2 hours behind New York. There's also still no timezone displayed.)

Now change the field settings to show "user's timezone". For me it is now displaying "5 July 2008 05:00 pm", which is simply flat out wrong. (Besides the lack of timezone info, it should be showing 1 pm, since Chicago is one hour ahead of Denver.)

I am not entirely sure what is going on here, but a little brief code poking suggests that the lack of timezone display is caused by date_formatter_format() in date.module. The last line of that function is:

return date_limit_format($format, date_granularity($field));

There is no granularity information for timezone. Therefore the timezone info gets filtered out entirely. However, I could be completely off base about that. Nonetheless I suspect that once the timezone display question is sorted out the weirdness about what timezone gets displayed will be easier.

I am marking this critical as it is displaying misleading or wrong information, which is a bad thing. :-) Karen, feel free to refile if necessary.

CommentFileSizeAuthor
#15 date-date_timezone-276544-14.patch670 bytesJames Marks

Comments

karens’s picture

Status: Active » Fixed

This should be fixed in the -dev version. There are lots and lots of changes since the rc, I'm almost ready to roll a new rc.

If you see problems in the -dev version, please reopen.

karens’s picture

Status: Fixed » Active

Oops, maybe not. I think I mis-read your post. I'll take another look, but the suggestion to move to the -dev version still holds :)

karens’s picture

Status: Active » Fixed

OK, now this is actually fixed. What happened here is partly some bad logic as you pointed out above in thinking that only dates that have timezones might want to display the timezones. The rest of the problem came from my rework to the date theme to make it 'prettier' by changing something like:

Thursday, May 1, 2008 4:00am - Thursday, May 1, 2008 6:00pm

to:

Thursday, May 1, 2008 4:00am - 6:00pm

I had to pull the timezone names out of that logic and tack them back on at the end, but needed to do it in a different way to allow for the various ways that timezones could be formatted.

Anyway, committed to both 5.2 and 6.2.

Thanks!

Crell’s picture

Status: Fixed » Active

Hm. No, I'm afraid this is still broken in multiple ways. :-( (I pulled the latest 5-2.x from CVS.)

1) Any timezone information I have is displaying twice. While an improvement over never displaying, I think just once is sufficient. :-) It seems whatever format I select, if it has a timezone identifier in it then it will display the timezone twice. That includes both string and offset based timezones.

2) The logic for how to display what timezone is still wonky, IMO. I cannot set a timezone on the event without displaying the event's timezone rather than the site or user's timezone. I don't know if it's even possible to then set an event in a timezone other than my own, which I need to do. I still think the event's timezone and the display timezone need to be separate configuration options.

3) When I created an event for noon in America/New York and then set the display field to "User's timezone" with my timezone set to America/Chicago, I get a display time of "5 July 2008 4:00pm America/Chicago America/Chicago". (Yep, doubled.) My suspicion is that it has something to do with the offset from GMT, since 4 hours is the offset for America/New York to GMT during daylight savings.

karens’s picture

Title: Timezone not displaying » Display dates with timezones in the user timezone instead
Category: bug » feature
Priority: Critical » Normal

The doubled timezone name was a small bug (I needed to trim the timezone name before replacing it out of the dates).

The other issue sounds like you want the Date module to do something I never intended it to do -- set a timezone on a date and then not display it and instead display the user's timezone. I have made the assumption that if you give dates their own timezones it's because the timezones are an important piece of information about the event. I usually use that to display events that should always be displayed in their own timezone because they're real-world events that will happen at that date and in that timezone. If you're attending a real-world event, you don't need to know what time it will happen in your timezone, you need to know what time it will happen in its own timezone.

Online events or things without timezones are the ones you might want to translate into the user's timezone -- things like the date a node got updated or the date and time of an online event -- and I never give them their own timezone since they don't really have one and it always makes sense to show them in the user or site timezone.

Trying to do something else would be a feature request and we'd need to think about how to offer that option without confusing everyone. It would need to be configurable, since that is not the way everyone would do it.

Crell’s picture

Yeah, I can see that as a feature request, but in a multi-timezone world that's what makes the most sense to me. What about item 3 in #4 above, though? No matter what, there's no way it should be showing 4 pm there given the configured timezones.

karens’s picture

I missed item 3, I'll double-check that. What PHP version are you using?

As to the theory of how timezones should be displayed, see http://wiki.mozilla.org/Calendar:Timezones, http://groups.google.com/group/google-calendar-help-publishers/msg/44253..., http://tools.ietf.org/html/rfc2445#section-4.3.5 (there are lots of other similar links) for discussions about the differences between events that have a fixed timezone where the timezone is an important component of the date and 'floating' timezones that are intended to be displayed in the user timezone.

Crell’s picture

PHP version is PHP 5.2.4-2ubuntu5.1 (vis, PHP 5.2.4 with Ubuntu branding).

As for the use case, here's my specific situation: I have various deadlines for an organization that are defined as being in US Eastern Time (which I've arbitrarily decided will be New York). This is typical for the organization, as it has members in just about every time zone on Earth.

One of the Australian members asked if I could post updates about when such deadlines are, since he can't keep track of his own timezone much less one halfway around the world. :-) I am not in New York time, of course. Therefore, what I need to be able to do is define a date that corresponds to a specific time on a specific day in New York, because that is the official point in time when it happens. I then want people in all 24 timezones (OK, it's more like 500 given wacky DST rules) to see the event in their local timezone (marked as such) so that they can plan accordingly.

At the moment I see now way that I can do this in Date, other than setting the field to "date's timezone" so that I get a timezone identifier and then writing my own formatter that selectively ignores configuration settings. I consider that quite sub-optimal, however. If there is a solution I am missing, please share. :-)

karens’s picture

OK, I can see the use case. For now, you can override theme_date_display_combination() to get this working. you have the raw date info available to you there and you can convert the raw date to the user timezone and display it.

jerdavis’s picture

Subscribing

dww’s picture

While searching for existing issues in the date queue that could explain what I'm running into over at #336255-11: CCK datestamp fields totally broken and fields without timezone handling mostly broken, I found this. This doesn't seem relevant to the bug I'm currently hunting (which I just submitted as #336829: nodes with CCK datestamp field using "Site's timezone" handling appear to be saved with user's TZ instead for the interested reader). However, I wanted to chime in here that IMHO, Crell is right on, and there are definitely plenty of use-cases for this sort of functionality. Try scheduling d.o downtime, IRC meetings, etc. They happen at a specific, absolute moment in time. People viewing that event don't care that the d.o server lives in US/Pacific time and that's the "local" timezone for the downtime. All they want to know is when d.o will be offline relative to their own timezone.

karens’s picture

Version: 5.x-2.0-rc » 6.x-2.x-dev

No new features in D5, moving feature requests to D6.

weimeng’s picture

Subscribing.

James Marks’s picture

Component: Date CCK Field » Code

Bumping this feature request for D6 (at least).

We maintain a calendar of meetings for our international NGO. These meetings are typically attended both in person and online from a variety of locations around the world and the timezone of the meetings' date/time is typically set to that of the physical location of the meetings. Often, these meetings are scheduled by users who are travelling and not currently in the timezone that the meeting will take place in.

We need to allow the user creating the meeting node to be able to attach a timezone other than their own to the meeting date/time and for that meeting to be displayed on a calendar adjusted for the viewing user's timezone so they don't see a 1:00 p.m. meeting in Seattle displayed alongside a 1:00 p.m. meeting in Cairo and have to constantly calculate the various meeting timeshifts on their own.

I'll look into overriding theme_date_display_combination() but having this as an option 'out of the box' would be a substantial benefit/improvement.

James Marks’s picture

Status: Active » Needs review
StatusFileSize
new670 bytes

It appears that all that is needed is to allow the timezone field to be exposed and editable when the Time zone handling is set to "User's time zone". This can be accomplished by changing one line of code - the test in the if statement in the _date_widget() function in date_elements.inc:

Change this:

if ($field['tz_handling'] == 'date') {
  $element['timezone'] = array(
    '#type' => 'date_timezone',
    '#delta' => $delta,
    '#default_value' => $timezone,
    '#weight' => $field['widget']['weight'] + .2,
    );  
}

to this:

if ($field['tz_handling'] == 'date' || $field['tz_handling'] == 'user') {
  $element['timezone'] = array(
    '#type' => 'date_timezone',
    '#delta' => $delta,
    '#default_value' => $timezone,
    '#weight' => $field['widget']['weight'] + .2,
    );  
}

This doesn't appear to create any problems as far as I can tell and allows timezones other than the author's timezone to be set in the node while retaining the behavior of "User's time zone" handling.

I'm attaching a patch with this comment.

James Marks’s picture

One caveat to the patch is that when you save a node with a date/time using a timezone other than your own then reopen the node for editing, the date/time and timezone will be converted using your timezone (because you've set the site to use "User's time zone" for Time zone handling) and will display values adjusted for your timezone rather than the values you originally entered. This may be unexpected and/or disconcerting but is a correct behavior based on the configuration settings.

Crell’s picture

Status: Needs review » Closed (outdated)