Skip to content

daft.functions.make_timestamp_ltz#

make_timestamp_ltz #

make_timestamp_ltz(year: Expression, month: Expression, day: Expression, hour: Expression, minute: Expression, second: Expression, timezone: str | None = None) -> Expression

Creates a UTC timestamp from individual date/time components.

When timezone is provided, the components are interpreted in that timezone and converted to UTC. Without a timezone the components are treated as UTC directly.

Parameters:

Name Type Description Default
year Expression

integer expression for the year.

required
month Expression

integer expression for the month (1-12).

required
day Expression

integer expression for the day (1-31).

required
hour Expression

integer expression for the hour (0-23).

required
minute Expression

integer expression for the minute (0-59).

required
second Expression

numeric expression for the second (0-59, may include fractional part).

required
timezone str | None

optional source timezone string (e.g. "US/Eastern").

None

Returns:

Name Type Description
Expression Expression

a Timestamp(microseconds, UTC) expression.

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import make_timestamp_ltz
>>> make_timestamp_ltz(
...     daft.col("y"), daft.col("m"), daft.col("d"), daft.col("h"), daft.col("mi"), daft.col("s")
... )
make_timestamp_ltz(col(y), col(m), col(d), col(h), col(mi), col(s))
Source code in daft/functions/datetime.py
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
def make_timestamp_ltz(
    year: Expression,
    month: Expression,
    day: Expression,
    hour: Expression,
    minute: Expression,
    second: Expression,
    timezone: str | None = None,
) -> Expression:
    """Creates a UTC timestamp from individual date/time components.

    When ``timezone`` is provided, the components are interpreted in that
    timezone and converted to UTC. Without a timezone the components are
    treated as UTC directly.

    Args:
        year: integer expression for the year.
        month: integer expression for the month (1-12).
        day: integer expression for the day (1-31).
        hour: integer expression for the hour (0-23).
        minute: integer expression for the minute (0-59).
        second: numeric expression for the second (0-59, may include fractional part).
        timezone: optional source timezone string (e.g. ``"US/Eastern"``).

    Returns:
        Expression: a Timestamp(microseconds, UTC) expression.

    Examples:
        >>> import daft
        >>> from daft.functions import make_timestamp_ltz
        >>> make_timestamp_ltz(
        ...     daft.col("y"), daft.col("m"), daft.col("d"), daft.col("h"), daft.col("mi"), daft.col("s")
        ... )
        make_timestamp_ltz(col(y), col(m), col(d), col(h), col(mi), col(s))
    """
    year = Expression._to_expression(year)
    month = Expression._to_expression(month)
    day = Expression._to_expression(day)
    hour = Expression._to_expression(hour)
    minute = Expression._to_expression(minute)
    second = Expression._to_expression(second)
    return Expression._call_builtin_scalar_fn(
        "make_timestamp_ltz", year, month, day, hour, minute, second, timezone=timezone
    )