def tz_from_string(_option, _opt_str, value, parser):
 if (value is not None):
  if (value[0] in ['+', '-']):
   valarray = [value[i:(i + 2)] for i in range(1, len(value), 2)]
   multipliers = [3600, 60]
   offset = 0
   for i in range(min(len(valarray), len(multipliers))):
    offset += (int(valarray[i]) * multipliers[i])
   if (value[0] == '-'):
    offset = (- offset)
   timezone = OffsetTzInfo(offset=offset)
  elif tz_pytz:
   try:
    timezone = pytz.timezone(value)
   except pytz.UnknownTimeZoneError:
    debug.error('Unknown display timezone specified')
  else:
   if (not hasattr(time, 'tzset')):
    debug.error("This operating system doesn't support tzset, please either specify an offset (eg. +1000) or install pytz")
   timezone = value
  parser.values.tz = timezone

def tz_from_string ( _option , _opt_str , value , parser ) : if ( value is not None ) : if ( value [ 0 ] in [ '+' , '-' ] ) : valarray = [ value [ i : ( i + 2 ) ] for i in range ( 1 , len ( value ) , 2 ) ] multipliers = [ 3600 , 60 ] offset = 0 for i in range ( min ( len ( valarray ) , len ( multipliers ) ) ) : offset += ( int ( valarray [ i ] ) * multipliers [ i ] ) if ( value [ 0 ] == '-' ) : offset = ( - offset ) timezone = OffsetTzInfo ( offset = offset ) elif tz_pytz : try : timezone = pytz . timezone ( value ) except pytz . UnknownTimeZoneError : debug . error ( 'Unknown display timezone specified' ) else : if ( not hasattr ( time , 'tzset' ) ) : debug . error ( "This operating system doesn't support tzset, please either specify an offset (eg. +1000) or install pytz" ) timezone = value parser . values . tz = timezone
stores a tzinfo object from a string .