from datetime import datetime

class User:
    """User model for authentication and profile ownership"""
    
    TABLE_NAME = "users"
    
    def __init__(self, id, username, email, hashed_password, created_at=None, updated_at=None):
        self.id = id
        self.username = username
        self.email = email
        self.hashed_password = hashed_password
        self.created_at = created_at or datetime.utcnow()
        self.updated_at = updated_at or datetime.utcnow()
    
    def to_dict(self):
        return {
            "id": self.id,
            "username": self.username,
            "email": self.email,
            "created_at": self.created_at.isoformat() if self.created_at else None,
            "updated_at": self.updated_at.isoformat() if self.updated_at else None,
        }
