classAtTimeZone
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.
$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 $operandpublic Text $zonepublic bool $interval = falsepublic string|null $precision = nullMethods§
public function __construct(
public Scalar $operand,
public Text $zone,
public bool $interval = false,
public string|null $precision = null,
)Parameters
$operand | Scalar | The converted TIMESTAMP value |
$zone | Text | The time zone |
$interval | bool | Whether INTERVAL is written before the zone |
$precision | string|null | The fractional seconds precision of the DATETIME exactly as written |
Calls 2
- static-call Check::input() line 49
- function-call
preg_matchline 50
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand; the result is a DATETIME.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Operands::single() line 58
- new Operands line 58
- method-call Derivation::scalar() line 58
- new ScalarFact line 60
- new Known line 60
- new Temporal line 60
- class-const TemporalKind::DateTime() line 60
public function render(Output $out): voidWrites the cast at the time zone.
Parameters
$out | Output |
Test cases 1
Calls 4
- method-call Output::keyword() line 68
- method-call Output::node() line 72
- method-call Output::glue() line 74
- method-call Output::symbol() line 76
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.