Conversation
Includes an adjustment to take into account the potential for a timezone to be included in the DTSTART or DTEND datetime and calculates to remove the timezone, apply as GMT and allow the local browser to render appropriately for the local timezone
Christop406
left a comment
There was a problem hiding this comment.
Would you be able to write a test case for this? For now, you can just add it to the test cases in test/ical/test.js. I think a test case would help not break this in the future and also give some more insight into the actual issue.
| //Allow to parse as per GMT | ||
| events[event_count][k].value = getDate(undefined, value.concat('Z')); | ||
| //If a locale exists, strip preceeding / | ||
| if(params["TZID"].search(/\//) != -1){ |
There was a problem hiding this comment.
I am not sure this does exactly what you want it to do, it seems that this check will find any / in the TZID then take a substring, so, for example, wouldn't this:
America/Los_Angelesmatch for your .search(...) call? Which would then end up with merica/Los_Angeles?
I think you would just want to check if the string starts with /, which simplifies the call to if(params["TZID"].startsWith('/'))
There was a problem hiding this comment.
Yes agree re the search. I'll make the change to the code and commit the change. I'll also write a test case for it and submit. Thanks for the advice.
There was a problem hiding this comment.
Sounds good - I'm about to head on a trip for a bit over a week tomorrow so I may go quiet here, but I will try my best to come back to this promptly after my trip. I hope you have a workaround for the time being.
| params["TZID"] = params["TZID"].slice(1); | ||
| } | ||
| //Pass to toLocaleString to reduce to GMT based on timezone | ||
| events[event_count][k].value.toLocaleString(undefined, {timeZone: params["TZID"]}); |
There was a problem hiding this comment.
What does this line do? toLocaleString doesn't set anything, so I think the return of this function is unused.
There was a problem hiding this comment.
My understanding is it returns a correctly coded datetime using the correct locale.
Includes an adjustment to take into account the potential for a timezone to be included in the DTSTART or DTEND datetime and calculates to remove the timezone, apply as GMT and allow the local browser to render appropriately for the local timezone