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

A TIMESTAMP value converted to a DATETIME at a time zone: CAST(expr AT TIME ZONE [INTERVAL] 'zone' AS DATETIME[(p)]) (Item_func_at_time_zone, MySQL 8.0.22 and later).

The server accepts the zone 'UTC', and '+00:00' written with INTERVAL; the INTERVAL keyword is kept because it decides which spelling is accepted.

Rule: MYSQL-AT-TIME-ZONE-001. Facts: a DATETIME of the given precision; NULL when the operand is. Terminates: the operand is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/cast-functions.html#function_cast. Status: Implemented.

Reading the zonedoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM t WHERE CAST(a AT TIME ZONE 'UTC' AS DATETIME(6))");
    [$query->statement->where->zone->value, $query->statement->where->precision] // => ['UTC', '6']

Properties§

public Scalar $operand
public Text $zone
public bool $interval = false
public string|null $precision = null

Methods§

public function __construct(
    public Scalar $operand,
    public Text $zone,
    public bool $interval = false,
    public string|null $precision = null,
)

Parameters

$operandScalarThe converted TIMESTAMP value
$zoneTextThe time zone
$intervalboolWhether INTERVAL is written before the zone
$precisionstring|nullThe fractional seconds precision of the DATETIME exactly as written
Calls 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operand; the result is a DATETIME.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the cast at the time zone.

Parameters

$outOutput
Test cases 1
Calls 4

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 declarations 1