Skip to content

daft.functions.convert_timezone#

convert_timezone #

convert_timezone(target_timezone: str, source_timestamp: Expression) -> Expression

Spark-style alias for :func:convert_time_zone.

Note Spark's argument order is (target_timezone, source_timestamp) which is the reverse of Daft's :func:convert_time_zone. The source timestamp must already carry a timezone (this alias does not accept a from_timezone argument).

Parameters:

Name Type Description Default
target_timezone str

Target timezone name.

required
source_timestamp Expression

A tz-aware Timestamp expression.

required

Returns:

Name Type Description
Expression Expression

Timestamp expression in the target timezone.

Source code in daft/functions/datetime.py
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
def convert_timezone(target_timezone: str, source_timestamp: Expression) -> Expression:
    """Spark-style alias for :func:`convert_time_zone`.

    Note Spark's argument order is ``(target_timezone, source_timestamp)`` which is the
    reverse of Daft's :func:`convert_time_zone`. The source timestamp must already carry
    a timezone (this alias does not accept a ``from_timezone`` argument).

    Args:
        target_timezone: Target timezone name.
        source_timestamp: A tz-aware Timestamp expression.

    Returns:
        Expression: Timestamp expression in the target timezone.
    """
    return convert_time_zone(source_timestamp, target_timezone)