Closed Bug 1610400 Opened 4 years ago Closed 4 years ago

calendar is having problems with time zones

Categories

(Calendar :: Lightning Only, defect)

Lightning 68
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
68.5.0

People

(Reporter: guy, Assigned: darktrojan)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0

Steps to reproduce:

Accepted a calendar invite (iCal format, as base64 encoded MIME email attachment). The invite contains date/times with time zones, example:

DTSTART;TZID="(UTC+12:00) Auckland, Wellington":20200121T120000
DTEND;TZID="(UTC+12:00) Auckland, Wellington":20200121T130000

Then I viewed this specific calendar entry (e.g. in the week view)

Actual results:

When viewing the calendar item, details of the invite are not visible (e.g. description, attendees, etc.).

The Error Console shows this exception:

RangeError: invalid time zone in DateTimeFormat(): (UTC+12:00) Auckland, Wellington mozIntl.jsm:841:9
NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS: [JavaScript Error: "invalid time zone in DateTimeFormat(): (UTC+12:00) Auckland, Wellington" {file: "resource://gre/modules/mozIntl.jsm" line: 841}]'[JavaScript Error: "invalid time zone in DateTimeFormat(): (UTC+12:00) Auckland, Wellington" {file: "resource://gre/modules/mozIntl.jsm" line: 841}]' when calling method: [calIDateTimeFormatter::formatDateTime] calendar-item-bindings.js:72
    set item chrome://calendar/content/calendar-item-bindings.js:72
    onLoad chrome://calendar/content/calendar-summary-dialog.js:96
    onload chrome://calendar/content/calendar-summary-dialog.xul:1

Expected results:

The proper invite details should be rendered in the event view pop up as expected. As well as they (some of them) are shown in the mouse over hover window.

Can you attach the whole ical file? Change any personal info if you feel the need.

What I can tell you is that that is an unusual format for the timezone ID (I don't think I've seen it before) and it's also wrong. Auckland and Wellington are UTC+13 on those dates (okay you probably know that, and it's just a label). Where did it come from?

Flags: needinfo?(guy)
Attached the sample as it was generated by Amazon WorkMail's calendar, only changed personal details.

```

Attached the sample as it was generated by Amazon WorkMail's calendar, only changed personal details.

When received by email, it is attached as a MIME attachment in base64 encoding, in case that makes a difference.

--=_Knc93NEfSaEqXGTGZHE1bwKzKE2938jjSbC3WhMwnmKC1ONl
Content-Type: text/calendar; method=REQUEST; charset=utf-8
Content-Transfer-Encoding: base64
Attached patch 1610400-timezone-fail-1.diff — — Splinter Review

The function in question only appears to like IANA timezone names (Pacific/Auckland) but there's no good way of knowing if any particular string is a valid timezone name. Next best thing is just to try, and do something else if we fail, I guess.

Assignee: nobody → geoff
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(guy)
Attachment #9121959 - Flags: review?(philipp)
Attachment #9121959 - Flags: approval-calendar-esr?(philipp)
Attachment #9121959 - Flags: approval-calendar-beta?(philipp)

I suppose any treatment but letting the exception go "untreated" is good. But if (as in this case) a substring matching a regex (untested) in the likes of UTC([+-])[0-9]{2}:[0-9]{2} appears, it may be suitable to use that for a fallback treatment.

Somehow, the calendar is doing "The Right Thing" (TM) already as it's diarising the event correctly. So I guess it's just this part of the UI that's having the issue with the time zone.

Cheers for drilling into the issue so promptly!!!

Attachment #9121959 - Flags: review?(philipp)
Attachment #9121959 - Flags: review?(paul)
Attachment #9121959 - Flags: approval-calendar-esr?(philipp)
Attachment #9121959 - Flags: approval-calendar-esr?(paul)
Attachment #9121959 - Flags: approval-calendar-beta?(philipp)
Attachment #9121959 - Flags: approval-calendar-beta?(paul)
Comment on attachment 9121959 [details] [diff] [review]
1610400-timezone-fail-1.diff

Review of attachment 9121959 [details] [diff] [review]:
-----------------------------------------------------------------

::: calendar/base/src/calDateTimeFormatter.js
@@ +70,5 @@
>        aOptions.timeZone = timezone.tzid;
> +      try {
> +        formatter = new Services.intl.DateTimeFormat(undefined, aOptions);
> +      } catch (ex) {
> +        cal.WARN(ex);

if this throws, formatter won't be usable below. 
return null here, or what?

If it throws, formatter will have the same value it already had.

Comment on attachment 9121959 [details] [diff] [review]
1610400-timezone-fail-1.diff

Review of attachment 9121959 [details] [diff] [review]:
-----------------------------------------------------------------

Changes look okay to me.  I sanity checked to confirm that in cases like this the `formatter` variable is not reassigned when the error occurs on the right side of the assignment operator.  One suggestion on documenting what is going on here.

::: calendar/base/src/calDateTimeFormatter.js
@@ +70,5 @@
>        aOptions.timeZone = timezone.tzid;
> +      try {
> +        formatter = new Services.intl.DateTimeFormat(undefined, aOptions);
> +      } catch (ex) {
> +        cal.WARN(ex);

How about a comment to explain the problem we are try/catching here?  Or instead maybe in the catch log a warning that says something like "warning: there may be a problem due to a non-IANA timezone name."
Attachment #9121959 - Flags: review?(paul)
Attachment #9121959 - Flags: review+
Attachment #9121959 - Flags: approval-calendar-esr?(paul)
Attachment #9121959 - Flags: approval-calendar-esr+
Attachment #9121959 - Flags: approval-calendar-beta?(paul)
Attachment #9121959 - Flags: approval-calendar-beta+

This already logs "RangeError: "invalid time zone in DateTimeFormat(): XYZ"" with a stack trace. I'll leave a comment in the code about IANA zones should anyone follow the error link back to it.

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/f2e3b944020b
Fail gracefully when formatting a date with a timezone unknown to Services.intl. r=pmorris

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 74
Target Milestone: 74 → 68.5.0
Attachment #9121959 - Flags: approval-calendar-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: