import pytz
from django.utils import timezone

def get_current_company_time(user):
    """
    Returns the current datetime in the active company's timezone.
    """
    if not hasattr(user, 'active_company') or not user.active_company:
        return timezone.now()

    company_tz = pytz.timezone(user.active_company.timezone)
    return timezone.now().astimezone(company_tz)