"""
DateIntelligence
Generated by Eden via recursive self-improvement
2025-10-28 01:51:26.978637
"""

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

class DateIntelligence:
    """
    A class providing intelligent date manipulation capabilities.
    
    Attributes:
        date: The date being manipulated. Defaults to current date if not provided.
        
    Methods:
        get_date_info(): Returns a dictionary with detailed date components.
        add_days(days): Adds a specified number of days to the date.
        add_months(months): Adds a specified number of months to the date.
        convert_format(format_str): Converts date format to the specified string format.
    """
    
    def __init__(self, date_str=None):
        if date_str:
            self.date = datetime.strptime(date_str, "%Y-%m-%d")
        else:
            self.date = datetime.now()
            
    def get_date_info(self):
        """
        Returns a dictionary containing various date components.
        
        Example output:
        {
            'year': 2023,
            'month': 12,
            'day': 25,
            'weekday': 0 (Monday is 0),
            'month_name': 'December',
            'day_name': 'Monday'
        }
        """
        return {
            'year': self.date.year,
            'month': self.date.month,
            'day': self.date.day,
            'weekday': self.date.weekday(),
            'month_name': self.date.strftime('%B'),
            'day_name': self.date.strftime('%A')
        }
    
    def add_days(self, days):
        """
        Adds a specified number of days to the current date.
        
        Args:
            days: Number of days to add (can be positive or negative)
        """
        self.date += timedelta(days=days)
        
    def add_months(self, months):
        """
        Adds a specified number of months to the current date.
        
        Args:
            months: Number of months to add (can be positive or negative)
        """
        self.date += relativedelta(months=months)
    
    def convert_format(self, format_str):
        """
        Converts the date to the specified string format.
        
        Args:
            format_str: Format string according to strftime specifications
        Returns:
            Formatted date string
        """
        return self.date.strftime(format_str)

# Example usage:
if __name__ == "__main__":
    # Create DateIntelligence object for 2023-12-25
    di = DateIntelligence("2023-12-25")
    
    # Get detailed date information
    print(di.get_date_info())  # {'year': 2023, 'month': 12, 'day': 25, ...}
    
    # Add 7 days
    di.add_days(7)
    print(di.convert_format("%Y-%m-%d"))  # "2024-01-01"
    
    # Add 2 months
    di.add_months(2)
    print(di.convert_format("%B %d, %Y"))  # "February 1, 2024"