(self, datestr)
Return `datestr`, a datetime provided in one of ISO 8601 formats,
        parsed as a real number. Value 0 marks the Unix epoch, positive values
        are the dates after it, negative before.

        If date is unspecified, epoch date is assumed.

        If time is unspecified, 00:00:00.0 is assumed.

        If timezone is unspecified, local time is assumed.
Return `datestr`, a datetime provided in one of ISO 8601 formats,
        parsed as a real number. Value 0 marks the Unix epoch, positive values
        are the dates after it, negative before.
Return datestr a datetime provided in one of ISO 8601 formats parsed as a real number . Value 0 marks the Unix epoch positive values are the dates after it negative before .
def parse(self, datestr):
        """
        Return `datestr`, a datetime provided in one of ISO 8601 formats,
        parsed as a real number. Value 0 marks the Unix epoch, positive values
        are the dates after it, negative before.

        If date is unspecified, epoch date is assumed.

        If time is unspecified, 00:00:00.0 is assumed.

        If timezone is unspecified, local time is assumed.
        """
        if datestr in MISSING_VALUES:
            return Unknown
        datestr = datestr.strip().rstrip('Z')
        datestr = self._tzre_sub(datestr)

        if not self._matches_iso_format(datestr):
            try:
                # If it is a number, assume it is a unix timestamp
                value = float(datestr)
                self.have_date = self.have_time = 1
                return value
            except ValueError:
                raise self.InvalidDateTimeFormatError(datestr)

        try_order = self.__ISO_FORMATS_PROBE_SEQ
        for i, (have_date, have_time, fmt) in enumerate(
                map(self._ISO_FORMATS.__getitem__, try_order)):
            try:
                dt = datetime.strptime(datestr, fmt)
            except ValueError:
                continue
            else:
                # Pop this most-recently-used format index to front,
                # excluding last 2
                if 0 < i < len(try_order) - 2:
                    try_order = try_order.copy()
                    try_order[i], try_order[0] = try_order[0], try_order[i]
                    TimeVariable.__ISO_FORMATS_PROBE_SEQ = try_order
                self.have_date |= have_date
                self.have_time |= have_time
                if not have_date:
                    dt = dt.replace(self.UNIX_EPOCH.year,
                                    self.UNIX_EPOCH.month,
                                    self.UNIX_EPOCH.day)
                break
        else:
            raise self.InvalidDateTimeFormatError(datestr)

        offset = dt.utcoffset()
        self.timezone = timezone(offset) if offset is not None else None

        # Convert time to UTC timezone. In dates without timezone,
        # localtime is assumed. See also:
        # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp
        if dt.tzinfo:
            dt -= dt.utcoffset()
        dt = dt.replace(tzinfo=timezone.utc)

        # Unix epoch is the origin, older dates are negative
        try:
            return dt.timestamp()
        except OverflowError:
            return -(self.UNIX_EPOCH - dt).total_seconds()
def parse ( self , datestr ) : if datestr in MISSING_VALUES : return Unknown datestr = datestr . strip ( ) . rstrip ( 'Z' ) datestr = self . _tzre_sub ( datestr ) if not self . _matches_iso_format ( datestr ) : try : # If it is a number, assume it is a unix timestamp value = float ( datestr ) self . have_date = self . have_time = 1 return value except ValueError : raise self . InvalidDateTimeFormatError ( datestr ) try_order = self . __ISO_FORMATS_PROBE_SEQ for i , ( have_date , have_time , fmt ) in enumerate ( map ( self . _ISO_FORMATS . __getitem__ , try_order ) ) : try : dt = datetime . strptime ( datestr , fmt ) except ValueError : continue else : # Pop this most-recently-used format index to front, # excluding last 2 if 0 < i < len ( try_order ) - 2 : try_order = try_order . copy ( ) try_order [ i ] , try_order [ 0 ] = try_order [ 0 ] , try_order [ i ] TimeVariable . __ISO_FORMATS_PROBE_SEQ = try_order self . have_date |= have_date self . have_time |= have_time if not have_date : dt = dt . replace ( self . UNIX_EPOCH . year , self . UNIX_EPOCH . month , self . UNIX_EPOCH . day ) break else : raise self . InvalidDateTimeFormatError ( datestr ) offset = dt . utcoffset ( ) self . timezone = timezone ( offset ) if offset is not None else None # Convert time to UTC timezone. In dates without timezone, # localtime is assumed. See also: # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp if dt . tzinfo : dt -= dt . utcoffset ( ) dt = dt . replace ( tzinfo = timezone . utc ) # Unix epoch is the origin, older dates are negative try : return dt . timestamp ( ) except OverflowError : return - ( self . UNIX_EPOCH - dt ) . total_seconds ( )