# utcToGnssWeek

Industry: GNSS

## Signature

```ts
utcToGnssWeek(counter: GnssWeekCounter, utcString: string): GnssWeek | null
```

Return the week, time of week and era of a UTC instant on a satellite week counter.

- The inverse of `gnssWeekToUtc`: `week` is what the counter shows, `era` how often it has wrapped.
- Time of week is a `number` of seconds; a fraction is the nearest double to the exact value.
- A listed leap second (`…T23:59:60Z`) falls in its own second of the week.
- `null` before the system's epoch, for an instant past 9999-12-31T23:59:59.999999999Z (the inverse writes four-digit years only), and on invalid input.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `counter` | `GnssWeekCounter` | the week counter: "GPS-LNAV", "GPS-CNAV", "GAL", "BDT", "QZS-LNAV", "QZS-CNAV", "IRN-LNAV" or "IRN-L1NV" |
| `utcString` | `string` | ISO 8601 instant string; a listed leap second is accepted |

## Returns

`{ week, timeOfWeekSeconds, era }`, or null on invalid input, before the system's epoch or past year 9999

## Types

### GnssWeek

A week and time of week on one satellite week counter.

```ts
import type { GnssWeek } from "@northguild/gmt";
```

| Member | Type | Description |
| --- | --- | --- |
| `week` | `number` | The week number as the counter shows it, from 0 to the counter's modulus − 1. |
| `timeOfWeekSeconds` | `number` | Seconds since the start of the week, from 0 up to but not including 604 800. |
| `era` | `number` | How many times the counter has wrapped since the system's epoch. |

## Related types

- [`GnssWeekCounter`](/gmt/reference/types/GnssWeekCounter/)

## Examples

```ts
import { utcToGnssWeek } from "@northguild/gmt/gnss/convert";

utcToGnssWeek("GPS-LNAV", "2019-04-07T00:00:00Z") // { week: 0, timeOfWeekSeconds: 18, era: 2 }
```

## Source

[gnss/convert/utcToGnssWeek.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/gnss/convert/utcToGnssWeek.ts)
