Exemplo n.º 1
0
 def timezone_offset(self):
     """
     Return minutes the user's timezone is offset from UTC.  E.g. if user is
     4 hours behind UTC, returns -240.
     If user has not set a timezone, returns None (not 0).
     """
     if self.timezone:
         return offset_of_timezone(self.timezone)
Exemplo n.º 2
0
 def timezone_offset(self):
     """
     Return minutes the user's timezone is offset from UTC.  E.g. if user is
     4 hours behind UTC, returns -240.
     If user has not set a timezone, returns None (not 0).
     """
     if self.timezone:
         return offset_of_timezone(self.timezone)
Exemplo n.º 3
0
 def test_offset_of_timezone(self):
     # offset_of_timezone returns the offset in minutes of the named timezone as of now
     # Construct a time in UTC that will be "now"
     utc_time = datetime(1972, 1, 1, 3, 4, 5).replace(tzinfo=utc)
     tz_name = "US/Eastern"  # 5 hours difference from UTC on 1/1/1972
     with patch('mozillians.common.helpers.aware_utcnow') as mock_aware_now:
         mock_aware_now.return_value = utc_time
         result = helpers.offset_of_timezone(tz_name)
     eq_(-300, result)
Exemplo n.º 4
0
 def test_offset_of_timezone(self):
     # offset_of_timezone returns the offset in minutes of the named timezone as of now
     # Construct a time in UTC that will be "now"
     utc_time = datetime(1972, 1, 1, 3, 4, 5).replace(tzinfo=utc)
     tz_name = "US/Eastern"  # 5 hours difference from UTC on 1/1/1972
     with patch('mozillians.common.helpers.aware_utcnow') as mock_aware_now:
         mock_aware_now.return_value = utc_time
         result = helpers.offset_of_timezone(tz_name)
     eq_(-300, result)