diff options
author | Zuul <zuul@review.opendev.org> | 2021-03-18 13:38:49 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-03-18 13:38:49 +0000 |
commit | 6d1d7f50301e36c74d9965bdec99b5d14dfb1f3b (patch) | |
tree | b81ab2f7268f092c6b72f81976001c68d3c4b510 /openstack_dashboard/dashboards | |
parent | 7da7537ddda8b9e1317fcfa329f6abf7a86d21ee (diff) | |
parent | f60220329accd9c6492acfc25fe024c394e3eaea (diff) | |
download | horizon-6d1d7f50301e36c74d9965bdec99b5d14dfb1f3b.tar.gz |
Merge "Get the timezone offset for the current day instead of January 1st."
Diffstat (limited to 'openstack_dashboard/dashboards')
-rw-r--r-- | openstack_dashboard/dashboards/settings/user/forms.py | 3 | ||||
-rw-r--r-- | openstack_dashboard/dashboards/settings/user/tests.py | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py index 561255636..b573d6b97 100644 --- a/openstack_dashboard/dashboards/settings/user/forms.py +++ b/openstack_dashboard/dashboards/settings/user/forms.py @@ -42,7 +42,8 @@ class UserSettingsForm(forms.SelfHandlingForm): @staticmethod def _sorted_zones(): - d = datetime(datetime.today().year, 1, 1) + today = datetime.today() + d = datetime(today.year, today.month, today.day) zones = [(tz, pytz.timezone(tz).localize(d).strftime('%z')) for tz in pytz.common_timezones] zones.sort(key=lambda zone: int(zone[1])) diff --git a/openstack_dashboard/dashboards/settings/user/tests.py b/openstack_dashboard/dashboards/settings/user/tests.py index d5284add0..71855050e 100644 --- a/openstack_dashboard/dashboards/settings/user/tests.py +++ b/openstack_dashboard/dashboards/settings/user/tests.py @@ -13,6 +13,7 @@ # under the License. from django.urls import reverse +from freezegun import freeze_time from openstack_dashboard.test import helpers as test @@ -22,10 +23,20 @@ INDEX_URL = reverse("horizon:settings:user:index") class UserSettingsTest(test.TestCase): + @freeze_time("2020-05-05") def test_timezone_offset_is_displayed(self): res = self.client.get(INDEX_URL) - self.assertContains(res, "UTC +11:00: Australia (Melbourne) Time") + print(res.content) + self.assertContains(res, "UTC +12:00: New Zealand (Auckland) Time") + self.assertContains(res, "UTC -03:00: Falkland Islands Time") + self.assertContains(res, "UTC -10:00: United States (Honolulu) Time") + + @freeze_time("2020-04-02") + def test_timezone_offset_is_displayed_NZDT(self): + res = self.client.get(INDEX_URL) + + # self.assertContains(res, "UTC +13:00: New Zealand (Auckland) Time") self.assertContains(res, "UTC -03:00: Falkland Islands Time") self.assertContains(res, "UTC -10:00: United States (Honolulu) Time") |