#NEWLINE# @ classmethod #NEWLINE# def from_string( cls , string ) : #NEWLINE# #INDENT# '\n        Constructs a :class:`mw.Timestamp` from a MediaWiki formatted string.\n        This method is provides a convenient way to construct from common\n        MediaWiki timestamp formats. E.g., ``%Y%m%d%H%M%S`` and\n        ``%Y-%m-%dT%H:%M:%SZ``.\n\n        :Parameters:\n            string : str\n                A formatted timestamp\n\n        :Returns:\n            :class:`mw.Timestamp`\n        ' #NEWLINE# if ( type ( string ) == bytes ) : #NEWLINE# #INDENT# string = str ( string , 'utf8' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# string = str ( e ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return cls . strptime ( string , SHORT_MW_TIME_STRING ) #NEWLINE# #UNINDENT# except ValueError as e : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return cls . strptime ( string , LONG_MW_TIME_STRING ) #NEWLINE# #UNINDENT# except ValueError as e : #NEWLINE# #INDENT# raise ValueError ( '{0} is not a valid Wikipedia date format' . format ( repr ( string ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return cls . from_time_struct ( time_struct )