Ignore:
Timestamp:
17 Apr 2012, 11:19:55 (13 years ago)
Author:
uli
Message:

Let to_timezone ignore not-datetimes.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/utils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r8185 r8192  
    569569
    570570    If no `tz` is given, shift to UTC is performed.
    571     """
     571
     572    If `dt` is not a datetime.datetime, the input value is returned
     573    unchanged.
     574    """
     575    if not isinstance(dt, datetime.datetime):
     576        return dt
    572577    if tz is None:
    573578        tz = pytz.utc
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py

    r8185 r8192  
    304304        return
    305305
     306    def test_to_timezone_no_dt(self):
     307        # the to_timezone function copes with dates (!= datetimes)
     308        d = datetime.date(2012, 12, 1)
     309        result1 = helpers.to_timezone(d)
     310        result2 = helpers.to_timezone(d, pytz.utc)
     311        self.assertEqual(result1, d)
     312        self.assertEqual(result2, d)
     313        return
    306314
    307315def test_suite():
Note: See TracChangeset for help on using the changeset viewer.