(tzinfo, allowUTC=False)
Given a tzinfo class, use known APIs to determine TZID, or use tzname.
Given a tzinfo class, use known APIs to determine TZID, or use tzname.
Given a tzinfo class use known APIs to determine TZID or use tzname .
def pickTzid(tzinfo, allowUTC=False):
        """
        Given a tzinfo class, use known APIs to determine TZID, or use tzname.
        """
        if tzinfo is None or (not allowUTC and tzinfo_eq(tzinfo, utc)):
            # If tzinfo is UTC, we don't need a TZID
            return None
        # try PyICU's tzid key
        if hasattr(tzinfo, 'tzid'):
            return toUnicode(tzinfo.tzid)

        # try pytz zone key
        if hasattr(tzinfo, 'zone'):
            return toUnicode(tzinfo.zone)

        # try tzical's tzid key
        elif hasattr(tzinfo, '_tzid'):
            return toUnicode(tzinfo._tzid)
        else:
            # return tzname for standard (non-DST) time
            notDST = datetime.timedelta(0)
            for month in range(1, 13):
                dt = datetime.datetime(2000, month, 1)
                if tzinfo.dst(dt) == notDST:
                    return toUnicode(tzinfo.tzname(dt))
        # there was no standard time in 2000!
        raise VObjectError("Unable to guess TZID for tzinfo {0!s}"
                           .format(tzinfo))
def pickTzid ( tzinfo , allowUTC = False ) : if tzinfo is None or ( not allowUTC and tzinfo_eq ( tzinfo , utc ) ) : # If tzinfo is UTC, we don't need a TZID return None # try PyICU's tzid key if hasattr ( tzinfo , 'tzid' ) : return toUnicode ( tzinfo . tzid ) # try pytz zone key if hasattr ( tzinfo , 'zone' ) : return toUnicode ( tzinfo . zone ) # try tzical's tzid key elif hasattr ( tzinfo , '_tzid' ) : return toUnicode ( tzinfo . _tzid ) else : # return tzname for standard (non-DST) time notDST = datetime . timedelta ( 0 ) for month in range ( 1 , 13 ) : dt = datetime . datetime ( 2000 , month , 1 ) if tzinfo . dst ( dt ) == notDST : return toUnicode ( tzinfo . tzname ( dt ) ) # there was no standard time in 2000! raise VObjectError ( "Unable to guess TZID for tzinfo {0!s}" . format ( tzinfo ) )