def local_tz(func):
 @functools.wraps(func)
 def wrapper(*args, **kwargs):
  tz = os.environ.get('TZ', '')
  try:
   os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
   time.tzset()
   return func(*args, **kwargs)
  finally:
   os.environ['TZ'] = tz
   time.tzset()
 return wrapper

def local_tz ( func ) : @ functools . wraps ( func ) def wrapper ( * args , ** kwargs ) : tz = os . environ . get ( 'TZ' , '' ) try : os . environ [ 'TZ' ] = 'EST+05EDT,M4.1.0,M10.5.0' time . tzset ( ) return func ( * args , ** kwargs ) finally : os . environ [ 'TZ' ] = tz time . tzset ( ) return wrapper
decorator to change the timezone when running a test .