mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	issue13666 - merge from 3.2
This commit is contained in:
		
						commit
						13c668229c
					
				
					 1 changed files with 9 additions and 10 deletions
				
			
		| 
						 | 
					@ -1203,14 +1203,14 @@ Using datetime with tzinfo:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> from datetime import timedelta, datetime, tzinfo
 | 
					    >>> from datetime import timedelta, datetime, tzinfo
 | 
				
			||||||
    >>> class GMT1(tzinfo):
 | 
					    >>> class GMT1(tzinfo):
 | 
				
			||||||
    ...     def __init__(self):         # DST starts last Sunday in March
 | 
					    ...     def utcoffset(self, dt):
 | 
				
			||||||
 | 
					    ...         return timedelta(hours=1) + self.dst(dt)
 | 
				
			||||||
 | 
					    ...     def dst(self, dt):
 | 
				
			||||||
 | 
					    ...         # DST starts last Sunday in March
 | 
				
			||||||
    ...         d = datetime(dt.year, 4, 1)   # ends last Sunday in October
 | 
					    ...         d = datetime(dt.year, 4, 1)   # ends last Sunday in October
 | 
				
			||||||
    ...         self.dston = d - timedelta(days=d.weekday() + 1)
 | 
					    ...         self.dston = d - timedelta(days=d.weekday() + 1)
 | 
				
			||||||
    ...         d = datetime(dt.year, 11, 1)
 | 
					    ...         d = datetime(dt.year, 11, 1)
 | 
				
			||||||
    ...         self.dstoff = d - timedelta(days=d.weekday() + 1)
 | 
					    ...         self.dstoff = d - timedelta(days=d.weekday() + 1)
 | 
				
			||||||
    ...     def utcoffset(self, dt):
 | 
					 | 
				
			||||||
    ...         return timedelta(hours=1) + self.dst(dt)
 | 
					 | 
				
			||||||
    ...     def dst(self, dt):
 | 
					 | 
				
			||||||
    ...         if self.dston <=  dt.replace(tzinfo=None) < self.dstoff:
 | 
					    ...         if self.dston <=  dt.replace(tzinfo=None) < self.dstoff:
 | 
				
			||||||
    ...             return timedelta(hours=1)
 | 
					    ...             return timedelta(hours=1)
 | 
				
			||||||
    ...         else:
 | 
					    ...         else:
 | 
				
			||||||
| 
						 | 
					@ -1219,16 +1219,15 @@ Using datetime with tzinfo:
 | 
				
			||||||
    ...          return "GMT +1"
 | 
					    ...          return "GMT +1"
 | 
				
			||||||
    ...
 | 
					    ...
 | 
				
			||||||
    >>> class GMT2(tzinfo):
 | 
					    >>> class GMT2(tzinfo):
 | 
				
			||||||
    ...     def __init__(self):
 | 
					    ...     def utcoffset(self, dt):
 | 
				
			||||||
 | 
					    ...         return timedelta(hours=2) + self.dst(dt)
 | 
				
			||||||
 | 
					    ...     def dst(self, dt):
 | 
				
			||||||
    ...         d = datetime(dt.year, 4, 1)
 | 
					    ...         d = datetime(dt.year, 4, 1)
 | 
				
			||||||
    ...         self.dston = d - timedelta(days=d.weekday() + 1)
 | 
					    ...         self.dston = d - timedelta(days=d.weekday() + 1)
 | 
				
			||||||
    ...         d = datetime(dt.year, 11, 1)
 | 
					    ...         d = datetime(dt.year, 11, 1)
 | 
				
			||||||
    ...         self.dstoff = d - timedelta(days=d.weekday() + 1)
 | 
					    ...         self.dstoff = d - timedelta(days=d.weekday() + 1)
 | 
				
			||||||
    ...     def utcoffset(self, dt):
 | 
					 | 
				
			||||||
    ...         return timedelta(hours=1) + self.dst(dt)
 | 
					 | 
				
			||||||
    ...     def dst(self, dt):
 | 
					 | 
				
			||||||
    ...         if self.dston <=  dt.replace(tzinfo=None) < self.dstoff:
 | 
					    ...         if self.dston <=  dt.replace(tzinfo=None) < self.dstoff:
 | 
				
			||||||
    ...             return timedelta(hours=2)
 | 
					    ...             return timedelta(hours=1)
 | 
				
			||||||
    ...         else:
 | 
					    ...         else:
 | 
				
			||||||
    ...             return timedelta(0)
 | 
					    ...             return timedelta(0)
 | 
				
			||||||
    ...     def tzname(self,dt):
 | 
					    ...     def tzname(self,dt):
 | 
				
			||||||
| 
						 | 
					@ -1628,7 +1627,7 @@ When DST starts (the "start" line), the local wall clock leaps from 1:59 to
 | 
				
			||||||
3:00.  A wall time of the form 2:MM doesn't really make sense on that day, so
 | 
					3:00.  A wall time of the form 2:MM doesn't really make sense on that day, so
 | 
				
			||||||
``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST
 | 
					``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST
 | 
				
			||||||
begins.  In order for :meth:`astimezone` to make this guarantee, the
 | 
					begins.  In order for :meth:`astimezone` to make this guarantee, the
 | 
				
			||||||
:meth:`rzinfo.dst` method must consider times in the "missing hour" (2:MM for
 | 
					:meth:`tzinfo.dst` method must consider times in the "missing hour" (2:MM for
 | 
				
			||||||
Eastern) to be in daylight time.
 | 
					Eastern) to be in daylight time.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
When DST ends (the "end" line), there's a potentially worse problem: there's an
 | 
					When DST ends (the "end" line), there's a potentially worse problem: there's an
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue