@classmethod
    def from_string(cls, string):
        """
        Constructs a :class:`mw.Timestamp` from a MediaWiki formatted string.
        This method is provides a convenient way to construct from common
        MediaWiki timestamp formats. E.g., ``%Y%m%d%H%M%S`` and
        ``%Y-%m-%dT%H:%M:%SZ``.

        :Parameters:
            string : str
                A formatted timestamp

        :Returns:
            :class:`mw.Timestamp`
        """
        if type(string) == bytes:
            string = str(string, 'utf8')
        else:
            string = str(string)

        try:
            return cls.strptime(string, SHORT_MW_TIME_STRING)
        except ValueError as e:
            try:
                return cls.strptime(string, LONG_MW_TIME_STRING)
            except __HOLE__ as e:
                raise ValueError(
                    "{0} is not a valid Wikipedia date format".format(
                        repr(string)
                    )
                )

        return cls.from_time_struct(time_struct)
dataset/ETHPy150Open mediawiki-utilities/python-mediawiki-utilities/mw/types/timestamp.py/Timestamp.from_string