Const// Concatenate with other patterns
const dateTimeRE = new RegExp(
`(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})${TimezoneOffsetRE.source}`
)
// Use standalone
const match = TimezoneOffsetRE.exec("2023-01-15T10:30:00-08:00")
if (match?.groups) {
const { tz_sign, tz_hours, tz_minutes } = match.groups
// tz_sign = "-", tz_hours = "08", tz_minutes = "00"
}
Composable regex pattern for matching timezone offsets.
Designed for embedding in larger patterns (no ^ or $ anchors). Matches UTC/GMT/Z or signed offsets like +08:00, -05:30.
Named capture groups:
tz_utc: Matches "Z", "UTC", or "GMT"tz_sign: The sign character (+, -, or Unicode minus −)tz_hours: Hour offset (1-2 digits)tz_minutes: Optional minute offset (2 digits)