pymensago/mdate.py
def from_string(self, date: str) -> bool:
		'''Assigns a value to the object from a string. The format must be one of the following: 
		YYYY-MM-DD, YYYY-MM, MM-DD, or YYYY. The year may be from 1 to 9999.'''
		y = 0
		m = 0
		d = 0
		
		parts = date.split('-')
		if len(parts) == 3:
			try:
				y = int(parts[0])
				m = int(parts[1])
				d = int(parts[2])
			except:
				return False

			if len(parts[0]) != 4 or len(parts[1]) != 2 or len(parts[2]) != 2:
				return False
			
		elif len(parts) == 2:
			try:
				first = int(parts[0])
				second = int(parts[1])
			except:
				return False

			if len(parts[0]) == 4 and len(parts[1]) == 2:
				y = first
				m = second
			elif len(parts[0]) == 2 and len(parts[1]) == 2:
				m = first
				d = second
			else:
				return False

		elif len(parts) == 1:		
			try:
				y = int(parts[0])
			except:
				return False
			
			if len(parts[0]) != 4:
				return False
		
		else:
			return False
		
		status = _validate_date(y, m, d)
		if not status:
			return False
		
		self.year = y
		self.month = m
		self.day = d
		self.format = _get_format_type(y,m,d)
		
		return True
Assigns a value to the object from a string. The format must be one of the following: 
		YYYY-MM-DD, YYYY-MM, MM-DD, or YYYY. The year may be from 1 to 9999.
Assigns a value to the object from a string. The format must be one of the following:
YYYY-MM-DD, YYYY-MM, MM-DD, or YYYY. The year may be from 1 to 9999.
Assigns a value to the object from a string . The format must be one of the following : YYYY - MM - DD YYYY - MM MM - DD or YYYY . The year may be from 1 to 9999 .
def from_string(self, date: str) -> bool:
		y = 0
		m = 0
		d = 0
		parts = date.split('-')
		if len(parts) == 3:
			try:
				y = int(parts[0])
				m = int(parts[1])
				d = int(parts[2])
			except:
				return False
			if len(parts[0]) != 4 or len(parts[1]) != 2 or len(parts[2]) != 2:
				return False
		elif len(parts) == 2:
			try:
				first = int(parts[0])
				second = int(parts[1])
			except:
				return False
			if len(parts[0]) == 4 and len(parts[1]) == 2:
				y = first
				m = second
			elif len(parts[0]) == 2 and len(parts[1]) == 2:
				m = first
				d = second
			else:
				return False
		elif len(parts) == 1:		
			try:
				y = int(parts[0])
			except:
				return False
			if len(parts[0]) != 4:
				return False
		else:
			return False
		status = _validate_date(y, m, d)
		if not status:
			return False
		self.year = y
		self.month = m
		self.day = d
		self.format = _get_format_type(y,m,d)
		return True
def from_string ( self , date : str ) -> bool : y = 0 m = 0 d = 0 parts = date . split ( '-' ) if len ( parts ) == 3 : try : y = int ( parts [ 0 ] ) m = int ( parts [ 1 ] ) d = int ( parts [ 2 ] ) except : return False if len ( parts [ 0 ] ) != 4 or len ( parts [ 1 ] ) != 2 or len ( parts [ 2 ] ) != 2 : return False elif len ( parts ) == 2 : try : first = int ( parts [ 0 ] ) second = int ( parts [ 1 ] ) except : return False if len ( parts [ 0 ] ) == 4 and len ( parts [ 1 ] ) == 2 : y = first m = second elif len ( parts [ 0 ] ) == 2 and len ( parts [ 1 ] ) == 2 : m = first d = second else : return False elif len ( parts ) == 1 : try : y = int ( parts [ 0 ] ) except : return False if len ( parts [ 0 ] ) != 4 : return False else : return False status = _validate_date ( y , m , d ) if not status : return False self . year = y self . month = m self . day = d self . format = _get_format_type ( y , m , d ) return True
Assigns a value to the object from a string.
Assigns a value to the object from a string .
'''Assigns a value to the object from a string. The format must be one of the following: 
		YYYY-MM-DD, YYYY-MM, MM-DD, or YYYY. The year may be from 1 to 9999.'''
self
date
str