parameters: (dt: datetime.datetime, tzstr: str,
                      precision: DateTimePrecision,
                      primitive_cls: Type[_T])
return_statement: return result
docstring: Constructs an instance of Date/DateTime given a naive Python datetime.
docstring_summary: Constructs an instance of Date/DateTime given a naive Python datetime.
docstring_tokens: Constructs an instance of Date / DateTime given a naive Python datetime .
function: def build_date_like(dt: datetime.datetime, tzstr: str,
                      precision: DateTimePrecision,
                      primitive_cls: Type[_T]) -> _T:
    """Constructs an instance of Date/DateTime given a naive Python datetime."""
    tzinfo = timezone_info_for_timezone(tzstr)
    aware_dt = dt.replace(tzinfo=tzinfo).astimezone(tz.UTC)
    delta = (aware_dt - UNIX_EPOCH)
  
    # Note: Per the Python documentation, `total_seconds` will lose microsecond
    # precision for very large time intervals (greater than 270 years on most
    # platforms).
    value_us = int(delta.total_seconds() * 1e6)
    result = cast(Any, primitive_cls)(
        value_us=value_us,
        timezone=tzstr,
        precision=cast(Any, primitive_cls).Precision.Value(precision.name))
    return result
function_tokens: def build_date_like ( dt : datetime . datetime , tzstr : str , precision : DateTimePrecision , primitive_cls : Type [ _T ] ) -> _T : tzinfo = timezone_info_for_timezone ( tzstr ) aware_dt = dt . replace ( tzinfo = tzinfo ) . astimezone ( tz . UTC ) delta = ( aware_dt - UNIX_EPOCH ) # Note: Per the Python documentation, `total_seconds` will lose microsecond # precision for very large time intervals (greater than 270 years on most # platforms). value_us = int ( delta . total_seconds ( ) * 1e6 ) result = cast ( Any , primitive_cls ) ( value_us = value_us , timezone = tzstr , precision = cast ( Any , primitive_cls ) . Precision . Value ( precision . name ) ) return result