final class AtTimeZone
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A time converted to or from a time zone: a AT TIME ZONE zone.

The parser reads it as a call of pg_catalog.timezone(zone, a).

Rule: PG-AT-TIME-ZONE-001. Facts: timestamp with time zone gives timestamp, timestamp gives timestamp with time zone, a time with or without zone gives time with time zone, and an unknown-typed constant is read as the preferred timestamp with time zone; the zone is text or an interval; NULL when an operand can be. Both operands must keep their place (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT. Status: Implemented.

Converting a timestamp with time zonedoctest
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT '2024-01-01 00:00+00'::timestamptz AT TIME ZONE 'UTC'", [])->field(0)->type->descriptor->name() // => 'timestamp without time zone'

Properties§

public Scalar $operand
public Scalar $zone

Methods§

public function __construct(public Scalar $operand, public Scalar $zone)

Parameters

$operandScalarThe time value
$zoneScalarThe time zone
Calls 5
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands and the converted type.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 6
public function render(Output $out): void

Writes the value, AT TIME ZONE and the zone.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 3§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3

Relations§

Instantiated in 1
Type checks 1