[Python-checkins] python/dist/src/Lib _strptime.py,1.16,1.17

bcannon@users.sourceforge.net bcannon@users.sourceforge.net
Sat, 10 May 2003 23:23:38 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv17013/Lib

Modified Files:
	_strptime.py 
Log Message:
Beefed up timezone support.  UTC and GMT are now always recognized timezones
with values of 0.  Also now check time.daylight to see if time.tzname[1]
should be used in timezone checking.


Index: _strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/_strptime.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** _strptime.py	28 Apr 2003 21:30:11 -0000	1.16
--- _strptime.py	11 May 2003 06:23:36 -0000	1.17
***************
*** 284,290 ****
          # Set self.__timezone by using time.tzname.
          #
!         # Empty string used for matching when timezone is not used/needed such
!         # as with UTC.
!         self.__timezone = self.__pad(time.tzname, 0)
  
      def __calc_lang(self):
--- 284,294 ----
          # Set self.__timezone by using time.tzname.
          #
!         # Empty string used for matching when timezone is not used/needed.
!         time_zones = ["UTC", "GMT"]
!         if time.daylight:
!             time_zones.extend(time.tzname)
!         else:
!             time_zones.append(time.tzname[0])
!         self.__timezone = self.__pad(time_zones, 0)
  
      def __calc_lang(self):
***************
*** 491,504 ****
              julian = int(found_dict['j'])
          elif group_key == 'Z':
              found_zone = found_dict['Z'].lower()
              if locale_time.timezone[0] == locale_time.timezone[1]:
                  pass #Deals with bad locale setup where timezone info is
                       # the same; first found on FreeBSD 4.4.
!             elif locale_time.timezone[0].lower() == found_zone:
                  tz = 0
-             elif locale_time.timezone[1].lower() == found_zone:
-                 tz = 1
              elif locale_time.timezone[2].lower() == found_zone:
!                 tz = -1
      # Cannot pre-calculate datetime_date() since can change in Julian
      #calculation and thus could have different value for the day of the week
--- 495,512 ----
              julian = int(found_dict['j'])
          elif group_key == 'Z':
+             # Since -1 is default value only need to worry about setting tz if
+             # it can be something other than -1.
              found_zone = found_dict['Z'].lower()
              if locale_time.timezone[0] == locale_time.timezone[1]:
                  pass #Deals with bad locale setup where timezone info is
                       # the same; first found on FreeBSD 4.4.
!             elif found_zone in ("utc", "gmt"):
                  tz = 0
              elif locale_time.timezone[2].lower() == found_zone:
!                 tz = 0
!             elif time.daylight:
!                 if locale_time.timezone[3].lower() == found_zone:
!                     tz = 1
! 
      # Cannot pre-calculate datetime_date() since can change in Julian
      #calculation and thus could have different value for the day of the week