Example #1
0
    def tz_validate(self):
        """
        For a localized time zone, verify that there are no DST ambiguities
        (using pytz)

        Returns
        -------
        result : boolean
            True if there are no DST ambiguities
        """
        import pytz

        if self.tz is None or self.tz is pytz.utc:
            return True

        # See if there are any DST resolution problems
        try:
            lib.tz_localize_array(self.asi8, self.tz)
        except:
            return False

        return True
Example #2
0
    def tz_localize(self, tz):
        """
        Localize tz-naive DatetimeIndex to given time zone (using pytz)

        Returns
        -------
        localized : DatetimeIndex
        """
        if self.tz is not None:
            raise ValueError("Already have timezone info, " "use tz_normalize to convert.")

        new_dates = lib.tz_localize_array(self.asi8, tz)
        new_dates = new_dates.view("M8[us]")
        new_dates = new_dates.view(self.__class__)
        new_dates.offset = self.offset
        new_dates.tz = tz
        new_dates.name = self.name
        return new_dates