Revert "Merge pull request #13915 from edx/revert-13794-yro_implement-dateutil"

This reverts commit d59ab18b27, reversing
changes made to 0ebab35e89.
This commit is contained in:
Gregory Martin
2016-11-04 14:49:25 -04:00
parent 8ffc9197e8
commit f0cd29f02a
21 changed files with 294 additions and 190 deletions

View File

@@ -357,7 +357,6 @@ class CourseOverview(TimeStampedModel):
"""
Returns True if the course starts with-in given number of days otherwise returns False.
"""
return course_metadata_utils.course_starts_within(self.start, days)
def start_datetime_text(self, format_string="SHORT_DATE", time_zone=utc):
@@ -389,6 +388,7 @@ class CourseOverview(TimeStampedModel):
def end_datetime_text(self, format_string="SHORT_DATE", time_zone=utc):
"""
Returns the end date or datetime for the course formatted as a string.
"""
return course_metadata_utils.course_end_datetime_text(
self.end,

View File

@@ -1,12 +1,10 @@
"""Tests covering time zone utilities."""
from freezegun import freeze_time
from student.tests.factories import UserFactory
from openedx.core.djangoapps.user_api.preferences.api import set_user_preference
from openedx.core.lib.time_zone_utils import (
get_display_time_zone,
get_time_zone_abbr,
get_time_zone_offset,
get_user_time_zone,
)
from pytz import timezone, utc
from unittest import TestCase
@@ -25,20 +23,6 @@ class TestTimeZoneUtils(TestCase):
self.user = UserFactory.build()
self.user.save()
def test_get_user_time_zone(self):
"""
Test to ensure get_user_time_zone() returns the correct time zone
or UTC if user has not specified time zone.
"""
# User time zone should be UTC when no time zone has been chosen
user_tz = get_user_time_zone(self.user)
self.assertEqual(user_tz, utc)
# User time zone should change when user specifies time zone
set_user_preference(self.user, 'time_zone', 'Asia/Tokyo')
user_tz = get_user_time_zone(self.user)
self.assertEqual(user_tz, timezone('Asia/Tokyo'))
def _display_time_zone_helper(self, time_zone_string):
"""
Helper function to return all info from get_display_time_zone()

View File

@@ -2,19 +2,9 @@
Utilities related to timezones
"""
from datetime import datetime
from pytz import common_timezones, timezone, utc
def get_user_time_zone(user):
"""
Returns pytz time zone object of the user's time zone if available or UTC time zone if unavailable
"""
#TODO: exception for unknown timezones?
time_zone = user.preferences.model.get_value(user, "time_zone", 'utc')
return timezone(time_zone)
def _format_time_zone_string(time_zone, date_time, format_string):
"""
Returns a string, specified by format string, of the current date/time of the time zone.