@classmethod
def from_string(cls, date_str):
    """Populate date components from date string of the format YYYY[-MM[-DD]]"""
    parts = date_str.split('-')
    obj = cls()
    if len(parts) > 0:
        obj.year = int(parts[0])
    if len(parts) > 1:
        obj.month = int(parts[1])
    if len(parts) > 2:
        obj.day = int(parts[2])
    return obj
