"""
Date Calculator
Generated by Eden via recursive self-improvement
2025-10-27 20:34:51.201292
"""

from datetime import date, timedelta
from dateutil.relativedelta import relativedelta

class DateCalculator:
    """
    A class for performing various date calculations.
    
    Methods:
    - add_days(start_date: str, days_to_add: int) -> str:
        Adds a specified number of days to the given start date.
        
    - calculate_difference(start_date: str, end_date: str) -> int:
        Calculates the difference in days between two dates.
    """
    
    def __init__(self):
        pass
    
    def add_days(self, start_date: str, days_to_add: int) -> str:
        """
        Adds a specified number of days to the given start date.
        
        Args:
            start_date: A string representing the start date in ISO format (YYYY-MM-DD).
            days_to_add: An integer representing the number of days to add.
            
        Returns:
            A string representing the new date in ISO format.
            
        Raises:
            ValueError: If the start_date is not a valid date.
        """
        try:
            start = date.fromisoformat(start_date)
            delta = relativedelta(days=days_to_add)
            new_date = start + delta
            return new_date.isoformat()
        except ValueError as e:
            raise ValueError(f"Invalid date format: {e}")
    
    def calculate_difference(self, start_date: str, end_date: str) -> int:
        """
        Calculates the difference in days between two dates.
        
        Args:
            start_date: A string representing the start date in ISO format (YYYY-MM-DD).
            end_date: A string representing the end date in ISO format (YYYY-MM-DD).
            
        Returns:
            An integer representing the number of days between the two dates.
            
        Raises:
            ValueError: If either date is not a valid date or if end_date is earlier than start_date.
        """
        try:
            start = date.fromisoformat(start_date)
            end = date.fromisoformat(end_date)
            
            if end < start:
                raise ValueError("End date cannot be before start date.")
                
            difference = (end - start).days
            return difference
        except ValueError as e:
            raise ValueError(f"Invalid date format: {e}")

# Example usage:
if __name__ == "__main__":
    calculator = DateCalculator()
    
    # Add 5 days to '2023-10-05'
    new_date = calculator.add_days("2023-10-05", 5)
    print(f"New date after adding 5 days: {new_date}")
    
    # Calculate difference between '2023-10-05' and '2023-10-10'
    diff = calculator.calculate_difference("2023-10-05", "2023-10-10")
    print(f"Number of days difference: {diff}")