Skip to content

timestamp

pixeltable.functions.timestamp

Pixeltable UDFs for TimestampType.

Usage example:

import pixeltable as pxt

t = pxt.get_table(...)
t.select(t.timestamp_col.year, t.timestamp_col.weekday()).collect()

astimezone

astimezone(self: Timestamp, tz: String) -> Timestamp

Convert the datetime to the given time zone.

Parameters:

  • tz (String) –

    The time zone to convert to. Must be a valid time zone name from the IANA Time Zone Database.

day

day(self: Timestamp) -> Int

Between 1 and the number of days in the given month of the given year.

Equivalent to datetime.day.

hour

hour(self: Timestamp) -> Int

Between 0 and 23 inclusive.

Equivalent to datetime.hour.

isocalendar

isocalendar(self: Timestamp) -> Json

Return a dictionary with three entries: 'year', 'week', and 'weekday'.

Equivalent to datetime.isocalendar().

isoformat

isoformat(
    self: Timestamp, sep: String = "T", timespec: String = "auto"
) -> String

Return a string representing the date and time in ISO 8601 format.

Equivalent to datetime.isoformat().

Parameters:

  • sep (String, default: 'T' ) –

    Separator between date and time.

  • timespec (String, default: 'auto' ) –

    The number of additional terms in the output. See the datetime.isoformat() documentation for more details.

isoweekday

isoweekday(self: Timestamp) -> Int

Return the day of the week as an integer, where Monday is 1 and Sunday is 7.

Equivalent to datetime.isoweekday().

make_timestamp

make_timestamp(
    year: Int,
    month: Int,
    day: Int,
    hour: Int = 0,
    minute: Int = 0,
    second: Int = 0,
    microsecond: Int = 0,
) -> Timestamp

Create a timestamp.

Equivalent to datetime().

microsecond

microsecond(self: Timestamp) -> Int

Between 0 and 999999 inclusive.

Equivalent to datetime.microsecond.

minute

minute(self: Timestamp) -> Int

Between 0 and 59 inclusive.

Equivalent to datetime.minute.

month

month(self: Timestamp) -> Int

Between 1 and 12 inclusive.

Equivalent to datetime.month.

posix_timestamp

posix_timestamp(self: Timestamp) -> Float

Return POSIX timestamp corresponding to the datetime instance.

Equivalent to datetime.timestamp().

replace

replace(
    self: Timestamp,
    year: Optional[Int] = None,
    month: Optional[Int] = None,
    day: Optional[Int] = None,
    hour: Optional[Int] = None,
    minute: Optional[Int] = None,
    second: Optional[Int] = None,
    microsecond: Optional[Int] = None,
) -> Timestamp

Return a datetime with the same attributes, except for those attributes given new values by whichever keyword arguments are specified.

Equivalent to datetime.replace().

second

second(self: Timestamp) -> Int

Between 0 and 59 inclusive.

Equivalent to datetime.second.

strftime

strftime(self: Timestamp, format: String) -> String

Return a string representing the date and time, controlled by an explicit format string.

Equivalent to datetime.strftime().

Parameters:

toordinal

toordinal(self: Timestamp) -> Int

Return the proleptic Gregorian ordinal of the date, where January 1 of year 1 has ordinal 1.

Equivalent to datetime.toordinal().

weekday

weekday(self: Timestamp) -> Int

Between 0 (Monday) and 6 (Sunday) inclusive.

Equivalent to datetime.weekday().

year

year(self: Timestamp) -> Int

Between MINYEAR and MAXYEAR inclusive.

Equivalent to datetime.year.