# isValidMetarTime

Industry: Aviation

:::caution[Unreleased]
Not in `@northguild/gmt` 1.21.0 on npm yet. It is on `main` and ships in the next release.
:::

## Signature

```ts
isValidMetarTime(value: string, referenceInstant: string): boolean
```

Return true when `value` is a METAR, SPECI or TAF time group (`YYGGggZ`) that resolves against `referenceInstant`.

- **True exactly when `parseMetarTime` returns an instant** for the same arguments. It calls the parser, so the two cannot disagree.
- **It needs the reference.** The group has no month or year, so a well-formed group against a reference that is not an ISO 8601 instant is false.
- **UTC, no locale.** The group is read as fixed ASCII text in UTC, never through `Intl`.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | The value to check |
| `referenceInstant` | `string` | An ISO 8601 instant with `Z` or an offset: the time the report was received or the archive's timestamp |

## Returns

`true` for a time group that resolves against the reference, or `false` on invalid input

## Examples

```ts
import { isValidMetarTime } from "@northguild/gmt/aviation/validate";

isValidMetarTime("302350Z", "2024-07-01T00:05:00Z") // true
```

## Source

[aviation/validate/isValidMetarTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/aviation/validate/isValidMetarTime.ts)
