from datetime import datetime


def trim_microseconds(dt: datetime) -> datetime:
    """Trim microseconds from a datetime as per ECMA-262."""
    return dt.replace(microsecond=((dt.microsecond // 1000) * 1000))