def timeZone(): """Returns a TimeZone object expressing the user's time-zone preference.""" global _gotTZ, _tz # If we already got it, just return it. if _gotTZ: return _tz # If the TZ environment variable is set, just use that. if envTZ: _logger.debug( f"time.timeZone(): Using environment variable TZ={envTZ}.") tz = gettz(envTZ) else: # Get the time zome preference from the system config. tzOff = tzOffset( ) # Retrieve user's time zone preference as hours vs. UTC. td = TimeDelta(hours=tzOff) # Convert to a timedelta object. tz = TimeZone(td) # Create the timezone object. _gotTZ = True _tz = tz return tz
def timeZones(draw: Callable) -> TimeZone: """ Strategy that generates :class:`TimeZone` values. """ offset = draw(integers(min_value=-(60 * 24) + 1, max_value=(60 * 24) - 1)) timeDelta = TimeDelta(minutes=offset) timeZone = TimeZone(offset=timeDelta, name=f"{offset}s") return timeZone
def timeZones(draw: Callable) -> TimeZone: offset = draw(integers(min_value=-(60 * 24) + 1, max_value=(60 * 24) - 1)) timeDelta = TimeDelta(minutes=offset) timeZone = TimeZone(offset=timeDelta, name=f"{offset}s") return timeZone