Repository: pretalx/pretalx

Issue:
Setting speaker availibilty to "all day" for the last day of the conference triggers an error message of "Submitted availability is not within the event timeframe."
## Expected Behavior
Setting the availibilty to "All Day" should be possible for all days of the conference, even if it ends at some point during this day.

## Current Behavior
Setting the availibility to "All Day" on all days of the conference (in our case monday to sunday) triggers an error message of "Submitted availability is not within the event timeframe."


## Steps to Reproduce

1. Set the conference date to start at 2018-10-22 and end at 2018-10-28
2. Edit a speaker
3. Set the availability to all day for all conference days
4. On the bottom of the page, you the the error message "Submitted availability is not within the event timeframe."

if needed, we can provide a speaker account on the instance for testing.

## Your Environment
* Version used: 0.7.1
* Environment name and version (e.g. Chrome 39, python 3.5): Firefox 61
* Operating System and version (desktop or mobile): Linux Desktop (Debian Unstable)
* Link to your instance, if in production: https://conference.c3w.at



Discussion:
Good catch, thank you for the report! Definitely a bug – I may take a few days to look into it, since I'm travelling rn, but I'll issue a bugfix release once it's fixed.
haha, well, the last day of privacyweek is the day Austria switches back to standard time.. soo, well, [timezones](https://youtu.be/-5wpm-gesOY) ;) m) I will take a deeper look tomorrow, just know that this only affects a single day or two a year.
A single day, most likely, as it's only affecting shortened days.

Resolving patch:
diff --git a/src/pretalx/schedule/forms.py b/src/pretalx/schedule/forms.py
--- a/src/pretalx/schedule/forms.py
+++ b/src/pretalx/schedule/forms.py
@@ -91,8 +91,11 @@ def _validate_availability(self, rawavail):
         try:
             timeframe_start = tz.localize(datetime.datetime.combine(self.event.date_from, datetime.time()))
             assert rawavail['start'] >= timeframe_start
-            timeframe_end = tz.localize(datetime.datetime.combine(self.event.date_to, datetime.time()))
-            timeframe_end += datetime.timedelta(days=1)
+
+            # add 1 day, not 24 hours, https://stackoverflow.com/a/25427822/2486196
+            timeframe_end = datetime.datetime.combine(self.event.date_to, datetime.time())
+            timeframe_end = timeframe_end + datetime.timedelta(days=1)
+            timeframe_end = tz.localize(timeframe_end, is_dst=None)
             assert rawavail['end'] <= timeframe_end
         except AssertionError:
             raise forms.ValidationError("Submitted availability is not within the event timeframe.")


Test patch:
diff --git a/src/tests/unit/schedule/test_availabilities_mixin.py b/src/tests/unit/schedule/test_availabilities_mixin.py
--- a/src/tests/unit/schedule/test_availabilities_mixin.py
+++ b/src/tests/unit/schedule/test_availabilities_mixin.py
@@ -131,6 +131,20 @@ def test_validate_availability_tz_success(availabilitiesform, avail):
         pytest.fail("Unexpected ValidationError")
 
 
+@pytest.mark.django_db
+def test_validate_availability_daylightsaving(availabilitiesform):
+    # https://github.com/pretalx/pretalx/issues/460
+    availabilitiesform.event.timezone = 'Europe/Berlin'
+    availabilitiesform.event.date_from = datetime.date(2018, 10, 22)
+    availabilitiesform.event.date_to = datetime.date(2018, 10, 28)
+    availabilitiesform.event.save()
+
+    try:
+        availabilitiesform._validate_availability(({'start': '2018-10-22 00:00:00', 'end': '2018-10-29 00:00:00'}))
+    except ValidationError:
+        pytest.fail("Unexpected ValidationError")
+
+
 @pytest.mark.django_db
 @pytest.mark.parametrize('avail', (
     ({'start': '2016-12-31 23:00:00', 'end': '2017-01-01 08:00:00'}),  # local time, start