Skip to content

Commit

Permalink
Merge pull request #5750 from markotoplak/timezone-deprecation
Browse files Browse the repository at this point in the history
Remove deprecated UTC offsets
  • Loading branch information
PrimozGodec authored Dec 22, 2021
2 parents ee9a416 + ec24a14 commit 7f4dcf4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
9 changes: 0 additions & 9 deletions Orange/data/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,6 @@ def varcls_modified(self, name):
var.have_time = 1
return var

def test_remove_deprecated_utc_offset(self):
""" When this test start to fail:
- remove all marked locations in TimeVariable class
- uncomment new implementation for setting timezones in parse method
- remove this test
"""
import Orange # pylint: disable=import-outside-toplevel
self.assertLess(Orange.__version__, "3.32")


PickleContinuousVariable = create_pickling_tests(
"PickleContinuousVariable",
Expand Down
33 changes: 3 additions & 30 deletions Orange/data/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,35 +931,15 @@ def __init__(self, date_string):

_matches_iso_format = re.compile(REGEX).match

# UTC offset and associated timezone. If parsed datetime values provide an
# offset, it is used for display. If not all values have the same offset,
# +0000 (=UTC) timezone is used and utc_offset is set to False.
_utc_offset = None # deprecated - remove in 3.32
# If parsed datetime values provide an offset or timzone, it is used for display.
# If not all values have the same offset, +0000 (=UTC) timezone is used
_timezone = None

def __init__(self, *args, have_date=0, have_time=0, **kwargs):
super().__init__(*args, **kwargs)
self.have_date = have_date
self.have_time = have_time

# deprecated - remove in 3.32 - from here
@property
def utc_offset(self):
warnings.warn(
"utc_offset is deprecated and will be removed in Orange 3.32",
OrangeDeprecationWarning
)
return self._utc_offset

@utc_offset.setter
def utc_offset(self, val):
warnings.warn(
"utc_offset is deprecated and will be removed in Orange 3.32ß",
OrangeDeprecationWarning
)
self._utc_offset = val
# remove to here

@property
def timezone(self):
if self._timezone is None or self._timezone == "different timezones":
Expand All @@ -971,7 +951,7 @@ def timezone(self):
def timezone(self, tz):
"""
Set timezone value:
- if self._timezone is None set it to new timezone
- if self._timezone is None set it to new timezone
- if current timezone is different that new indicate that TimeVariable
have two date-times with different timezones
- if timezones are same keep it
Expand Down Expand Up @@ -1069,13 +1049,6 @@ def parse(self, datestr):

offset = dt.utcoffset()
self.timezone = timezone(offset) if offset is not None else None
# deprecated - remove in 3.32 - from here
if self._utc_offset is not False:
if offset and self._utc_offset is None:
self._utc_offset = offset
elif self._utc_offset != offset:
self._utc_offset = False
# remove to here

# Convert time to UTC timezone. In dates without timezone,
# localtime is assumed. See also:
Expand Down

0 comments on commit 7f4dcf4

Please sign in to comment.