-
Notifications
You must be signed in to change notification settings - Fork 129
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
Time zone conversion support #161
Comments
I guess we should first your PR #159 but afterwards, if it's still needed yes it would be nice :) |
Also, maybe i made a mistake to represent dates in all-day events as datetimes and not just date. Maybe we could also change that. (But then, |
Phew, though question! I also already put some thought into this, also wanting to split off the In general, having two different datatypes for begin and end would probably make using the library a lot harder, because you need to use an if-check everytime you want to access the time, so defaulting to midnight seems to be a good approach. Additionally, using two seperate classes would make conversion problematic if the event is contained in some other datastructure (i.e. a Calendar). As the current API is completely focussed on making changes inplace instead of working on immutable datastructures (which is perfectly fine in our case), this would break the overall semantics and make use cases like toggling all-day events in an UI pretty hard to realize (as long as there is no So probably staying with the date+time+timezone self.assertEqual(precission_day.begin.time, time(0, 0))
self.assertEqual(precission_day.begin.tzinfo, None)
self.assertEqual(precission_day.begin, arrow.get(precission_day.begin.date)) # make sure the Arrow objects contains nothing more than the date information This raises the question on how the begin/end setters should react when receiving an |
This is now implemented for all Events and ToDos in a Calendar in #294 using calendar.normalize(
Timezone.from_tzid("America/Toronto"), # target timezone
normalize_floating=NormalizationAction.REPLACE, # replace tz of floating events, use IGNORE to skip those
normalize_with_tz=NormalizationAction.CONVERT) # convert tz of events that know their tz See |
The project I'm working on deals with timezones, so I've ended up writing code that convert events to a timezone by changing the timezones on the start & end times; standard and all-day events get handled differently, since a time-based event changes displayed times as it moves timezones, but all-day events always run midnight to midnight in whatever timezone they are in, based on their dates.
I think these might be useful to the library. I was thinking following the datetime manner, so
Event.astimezone(tz=zone)
and, to do everything in a calendar,Calendar.astimezone(tz=zone)
.If these would be utilitarian, I'd be glad to add them.
The text was updated successfully, but these errors were encountered: