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
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
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
    )