Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't erase event timezones #653

Merged
merged 32 commits into from
Sep 17, 2021
Merged

Conversation

mcclurgm
Copy link
Collaborator

@mcclurgm mcclurgm commented Feb 28, 2021

Fixes #650
Or at least part of it. We no longer set the timezones to floating, but this doesn't (yet) preserve the original timezone either, instead changing everything to the system timezone. It also doesn't add any affordance in the UI for time zones.
This now preserves the original timezone and displays timezone information in the dialog UI.

The issue was that we tried to set the timezone before we told libical that the time isn't DATE type. Libical just doesn't change the timezone in that case. So this reorganizes that code to fix it, and also adds tests to make sure that doesn't happen again! While I'm here, I also added support for floating timezones (outside of the implicitly floating DATE types) by changing the timezone argument behavior.

Still to do:

  • Preserve the original timezone where possible
  • Figure out how to use tests with a TimeManager 😠️

@mcclurgm mcclurgm marked this pull request as ready for review March 6, 2021 16:29
@mcclurgm
Copy link
Collaborator Author

mcclurgm commented Mar 6, 2021

Alright, I think this is ready to go. I messed with the TimeManager a bit to separate it from DBus in a testing mode, which you may or may not want. I'd also appreciate some help testing that the new logic to preserve the original timezone works as intended, since there seem to be some pitfalls there. (You can check and modify timezones in Evolution.)

@mcclurgm
Copy link
Collaborator Author

mcclurgm commented Apr 9, 2021

Ok, there's one thing that I want to discuss here. I just went ahead and implemented converting the timezone back to the original, but thinking back on it I'm not convinced that was a great idea. My hope was to make our lack of timezone support invisible: it displays in the system timezone at all times in Calendar, but if you go to another app that does support timezones, the original timezone info would be intact. Ideally, this would all work together: there could be no issues with this conversion, and it would be truly transparent. However, it's possible (I don't understand time calculations well enough) that this could cause some discrepancies. There's also the question of whether we want to do these implicit conversions at all, or if we should save the time into the event in exactly the way it's presented to the user. Does anyone have thoughts on this? If we wanted to change the saved timezone to the system timezone, that would be a very quick change to make.

@mcclurgm
Copy link
Collaborator Author

Since I guess I can do this now, can I get some input from @elementary/ux please? Before code review I need to know whether we want to implicitly convert timezones back and forth or not. This currently converts the original timezone to local, displays it for editing, and converts the result back to the original timezone. I can think of two options here: we could either convert to local and then not convert back (reset the event's timezone to the system's timezone on save), or we could present everything in the event's timezone in the dialog. Thoughts?

@mcclurgm mcclurgm requested review from a team May 26, 2021 03:13
@mcclurgm
Copy link
Collaborator Author

mcclurgm commented May 26, 2021

Sorry to spam the comments in my own PR, but I also realized another potential issue with the current method: we'd also have to deal with the recurrence rules, which can have time components. We only display the date, but that's a potential issue I hadn't considered.

Overall, it will be more work (including design) to get everything to work in the original timezone instead of local, but could prevent some odd edge cases. There are examples of other apps that hide time zones though, so it is possible. Mac Calendar displays everything in local time by default and has a setting to turn on explicit time zones, for example.

@mcclurgm mcclurgm marked this pull request as draft June 18, 2021 16:16
Currently, we only support one time zone in the editor.
This is necessary for that assumption, since it's possible
to create events with different start/end zones.
@mcclurgm
Copy link
Collaborator Author

mcclurgm commented Aug 28, 2021

Ok, I think this is ready to go. Sorry it's taken me so long to get it in this state.

I would ideally like to test the editor behavior to make sure things are working properly, but that's super complicated since it depends on multiple EDS objects that I don't know how I would mock. This could probably use some testing, to make sure it saves data properly.

I would appreciate input on two things in particular:

  • As discussed on Slack, I convert events with multiple time zones (different for start and end) to the same time zone. This change is permanent (and destructive of the multiple-time zone data) when you save the event. Does this sound ok? Also, I made the arbitrary decision to convert the end time to the same time zone as the start time, instead of the other way around.
  • The timezone display could use some design work. The label is just what I threw together as a proof of concept, but I think it could be a lot nicer in the final version. (@elementary/ux)

@mcclurgm mcclurgm marked this pull request as ready for review August 28, 2021 21:58
Copy link
Member

@marbetschar marbetschar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty dope - thanks for digging into the Time Zone Limbo!! Also, it's really great to see you backed all of this with tests!

Unfortunately I'm not able to verify this from a functional perspective, since I don't have to deal with multiple timezones. Therefore I just looked at the code and left some nitpicking comments :)

core/Services/Calendar/TimeManager.vala Outdated Show resolved Hide resolved
core/Services/Calendar/Util/DateTime.vala Outdated Show resolved Hide resolved
core/Tests/util-tests.vala Show resolved Hide resolved
core/Tests/util-tests.vala Show resolved Hide resolved
@mcclurgm
Copy link
Collaborator Author

mcclurgm commented Sep 2, 2021

Thanks for the suggestions, especially about the tests. It definitely feels a little strange, but it's the best I could come up with.

As for testing multiple timezones: if you want, you can create events in Evolution with any time zone you choose. They'll transfer over to elementary, so then you can make sure they work. It may not be the same as working with a full calendar, but it is something 🙂

Copy link
Member

@tintou tintou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for dealing with this, it looks good to me 🚀

@marbetschar
Copy link
Member

marbetschar commented Sep 16, 2021

@mcclurgm did the functional testing and it works as expected. One small thing I came across is when adding new events: There the timezone information is not displayed at my end - it only appears after saving the event and editing it. Can we either display the system timezone when creating a new event - or remove the whole timezone information completely there since its not editable anyways?

The following screenshot shows how creating a new event looks like on my end:

Screenshot from 2021-09-16 08-19-55

@marbetschar
Copy link
Member

@mcclurgm another thing which I came across is more from a design point of view: Since the timezone information is not editable anyways, any chance we can move it below the "All day" switch? Something like this:

Screenshot from 2021-09-16 08-25-33

@mcclurgm
Copy link
Collaborator Author

Thanks all. Marco, I'll have to dig in to creating new events. That's a big oversight on my part, I've only tested with pre-existing events. I'll get to work on that.

As for moving the time zone, that sounds like a nice idea, but I'm not sure how well it would work in practice. Not all time zones are that short, especially in Windows format. (We can't use those now, but I have a local branch that's working on it.) In the future I'd also like to make a selector, which I don't know it would look squeezed in over there.
Perhaps since we now have 2 controls that affect both times, we could move both the all day switch and the time zone to a new row?
I'll keep experimenting.

@mcclurgm
Copy link
Collaborator Author

I just pushed a commit to fix the empty timezone issue. Turns out that to make that work nicely, I also made the code a little cleaner and set the stage for if we want to add a time zone selector, so that's nice.

Copy link
Member

@marbetschar marbetschar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editing an event from Google Calendar changes the time by the UTC offset
4 participants