# GNSS

Industry: GNSS

GNSS is satellite navigation time. Every system keeps its own continuous clock, counts weeks on a counter that wraps, and differs from UTC by a number of seconds that grew with every leap second. This layer reads those clocks and weeks for all six systems alike, without an offset kept by hand.

## What these functions solve

- **A receiver's week number repeats.** [`gnssWeekToUtc`](/gmt/reference/gnss/convert/gnssWeekToUtc/) takes the counter and the rollover era by name, and [`utcToGnssWeek`](/gmt/reference/gnss/convert/utcToGnssWeek/) returns the week, the time of week and the era. See [guide](/gmt/guides/industries/gnss-system-time-and-week-rollover/), [GNSS Week Decoder](/gmt/tools/gnss-week-decoder/), [GNSS Rollover Checker](/gmt/tools/gnss-rollover-checker/), [scenario](/gmt/scenarios/gnss-week-that-wrapped/).
- **Satellite time is not UTC, and the gap grew with each leap second.** [`utcToGnss`](/gmt/reference/gnss/convert/utcToGnss/) and [`gnssToUtc`](/gmt/reference/gnss/convert/gnssToUtc/) read each system's gap from the built-in leap-second table, for every system alike. See [Satellite Clock Converter](/gmt/tools/satellite-clock-converter/), [scenario](/gmt/scenarios/gnss-offset-hardcoded/).
- **A week in a RINEX navigation file is not the week a satellite sends.** [`rinexWeekToUtc`](/gmt/reference/gnss/convert/rinexWeekToUtc/) and [`utcToRinexWeek`](/gmt/reference/gnss/convert/utcToRinexWeek/) read the continuous count. See [scenario](/gmt/scenarios/rinex-week-read-as-broadcast/), [GNSS Week Decoder](/gmt/tools/gnss-week-decoder/).
- **A logged second sixty may not be a real leap second.** [`isLeapSecond`](/gmt/reference/timescale/validate/isLeapSecond/) checks the table, and [`toTAI`](/gmt/reference/timescale/convert/toTAI/) and [`fromTAI`](/gmt/reference/timescale/convert/fromTAI/) carry an inserted second through. See [scenario](/gmt/scenarios/a-leap-second-that-never-happened/), [guide](/gmt/guides/core-date-operations/leap-seconds-and-tai/).

Start with the guide: [GNSS: System Time and Week Rollover](/gmt/guides/industries/gnss-system-time-and-week-rollover/).

## Its own functions

### [`gnss`](/gmt/reference/gnss/)

**[convert](/gmt/reference/gnss/convert/)**

- [`gnssToUtc`](/gmt/reference/gnss/convert/gnssToUtc/): Convert a satellite system's time-scale string to a UTC instant string.
- [`gnssWeekToUtc`](/gmt/reference/gnss/convert/gnssWeekToUtc/): Convert a week number and time of week, as a receiver reports them, to a UTC instant string.
- [`rinexWeekToUtc`](/gmt/reference/gnss/convert/rinexWeekToUtc/): Convert a week number from a RINEX navigation file, and the seconds of that week, to a UTC instant string.
- [`utcToGnss`](/gmt/reference/gnss/convert/utcToGnss/): Convert a UTC instant to a satellite system's own time, as a time-scale string.
- [`utcToGnssWeek`](/gmt/reference/gnss/convert/utcToGnssWeek/): Return the week, time of week and era of a UTC instant on a satellite week counter.
- [`utcToRinexWeek`](/gmt/reference/gnss/convert/utcToRinexWeek/): Return the RINEX navigation-file week and seconds of week of a UTC instant.

## Functions it draws on

### [`timescale`](/gmt/reference/timescale/)

**[calculate](/gmt/reference/timescale/calculate/)**

- [`leapSecondsBetween`](/gmt/reference/timescale/calculate/leapSecondsBetween/): Return how many leap seconds start between two UTC instants, signed.
- [`nextLeapSecond`](/gmt/reference/timescale/calculate/nextLeapSecond/): Return the first leap second after a UTC instant, as its UTC label `…T23:59:60Z`.
- [`taiMinusUtc`](/gmt/reference/timescale/calculate/taiMinusUtc/): Return TAI − UTC, in whole seconds, at a UTC instant.
- [`tcgMinusTt`](/gmt/reference/timescale/calculate/tcgMinusTt/): Return TCG − TT, in seconds, at a UTC instant.

**[convert](/gmt/reference/timescale/convert/)**

- [`fromJ2000Seconds`](/gmt/reference/timescale/convert/fromJ2000Seconds/): Convert seconds since J2000.0 on a time scale to a UTC instant string.
- [`fromJulianDate`](/gmt/reference/timescale/convert/fromJulianDate/): Convert a single Julian Date on a time scale to a UTC instant string.
- [`fromJulianDateParts`](/gmt/reference/timescale/convert/fromJulianDateParts/): Convert a two-part Julian Date on a time scale to a UTC instant string.
- [`fromModifiedJulianDate`](/gmt/reference/timescale/convert/fromModifiedJulianDate/): Convert a Modified Julian Date on a time scale to a UTC instant string.
- [`fromTAI`](/gmt/reference/timescale/convert/fromTAI/): Convert a TAI time-scale string to a UTC instant string.
- [`fromTai64n`](/gmt/reference/timescale/convert/fromTai64n/): Convert a TAI64, TAI64N or TAI64NA label in hex text to a UTC instant string.
- [`fromTCG`](/gmt/reference/timescale/convert/fromTCG/): Convert a Geocentric Coordinate Time string to a UTC instant string.
- [`fromTT`](/gmt/reference/timescale/convert/fromTT/): Convert a Terrestrial Time string to a UTC instant string.
- [`toJ2000Seconds`](/gmt/reference/timescale/convert/toJ2000Seconds/): Convert a UTC instant to seconds since J2000.0 on a time scale.
- [`toJulianDate`](/gmt/reference/timescale/convert/toJulianDate/): Convert a UTC instant to a single Julian Date on a time scale.
- [`toJulianDateParts`](/gmt/reference/timescale/convert/toJulianDateParts/): Convert a UTC instant to a two-part Julian Date `{ jd1, jd2 }` on a time scale, exact to the nanosecond.
- [`toModifiedJulianDate`](/gmt/reference/timescale/convert/toModifiedJulianDate/): Convert a UTC instant to a Modified Julian Date on a time scale.
- [`toTAI`](/gmt/reference/timescale/convert/toTAI/): Convert a UTC instant to a TAI time-scale string, `YYYY-MM-DDTHH:MM:SS[.fraction] TAI`.
- [`toTai64n`](/gmt/reference/timescale/convert/toTai64n/): Convert a UTC instant to its TAI64N label in the daemontools text form, `@` and 24 lowercase hex digits.
- [`toTCG`](/gmt/reference/timescale/convert/toTCG/): Convert a UTC instant to a Geocentric Coordinate Time string, `YYYY-MM-DDTHH:MM:SS[.fraction] TCG`.
- [`toTT`](/gmt/reference/timescale/convert/toTT/): Convert a UTC instant to a Terrestrial Time string, `YYYY-MM-DDTHH:MM:SS[.fraction] TT`.

**[format](/gmt/reference/timescale/format/)**

- [`formatCcsdsAsciiA`](/gmt/reference/timescale/format/formatCcsdsAsciiA/): Write an instant as a CCSDS ASCII Time Code A string (`YYYY-MM-DDThh:mm:ss.d…dZ`).
- [`formatCcsdsAsciiB`](/gmt/reference/timescale/format/formatCcsdsAsciiB/): Write an instant as a CCSDS ASCII Time Code B string (`YYYY-DDDThh:mm:ss.d…dZ`, day of year).

**[parse](/gmt/reference/timescale/parse/)**

- [`parseCcsdsAsciiA`](/gmt/reference/timescale/parse/parseCcsdsAsciiA/): Read a CCSDS ASCII Time Code A (`YYYY-MM-DDThh:mm:ss.d…dZ`) as an ISO 8601 UTC instant string.
- [`parseCcsdsAsciiB`](/gmt/reference/timescale/parse/parseCcsdsAsciiB/): Read a CCSDS ASCII Time Code B (`YYYY-DDDThh:mm:ss.d…dZ`, day of year) as an ISO 8601 UTC instant string in calendar form.

**[validate](/gmt/reference/timescale/validate/)**

- [`isLeapSecond`](/gmt/reference/timescale/validate/isLeapSecond/): Return true when a UTC instant string is one of the 27 inserted leap seconds.

## Guides

- [GNSS: System Time and Week Rollover](/gmt/guides/industries/gnss-system-time-and-week-rollover/): utcToGnss, gnssToUtc, gnssWeekToUtc, utcToGnssWeek, rinexWeekToUtc and utcToRinexWeek — the six satellite system times as they differ from UTC, the week counters that wrap, and the continuous weeks of a RINEX navigation file.

## Tools

- [GNSS Rollover Checker](/gmt/tools/gnss-rollover-checker/): Check whether a satellite receiver's firmware will report the wrong date, and when. Pick a counter and how the firmware counts, and see the date it reports, the date it goes wrong from and the next wrap of every counter.
- [GNSS Week Decoder](/gmt/tools/gnss-week-decoder/): Turn a satellite week number into a date. Say which counter and which era, or give a RINEX week or a UTC instant, and see the answer on every era and the same moment on every counter.
- [Satellite Clock Converter](/gmt/tools/satellite-clock-converter/): Read a time on one clock and see it on seven more. Give a UTC instant or a TAI, GPS, Galileo, BeiDou, QZSS, GLO or NavIC reading, and see how far each clock is from UTC.

## Scenarios

- [A 13-Bit Week Read as 10-Bit](/gmt/scenarios/thirteen-bit-week-read-as-ten-bit/): A full week number of 2295 from a QZSS civil message is fed to the 10-bit counter, and the library refuses it.
- [A Fixed Gap Applied to an Old Log](/gmt/scenarios/gnss-offset-hardcoded/): A log from June 2016 is converted with today's gap between Galileo time and UTC, and every line is a second off.
- [A RINEX Week Read as a Broadcast Week](/gmt/scenarios/rinex-week-read-as-broadcast/): A NavIC record in a RINEX navigation file shows week 2295, and the log reads it as the L1NV counter, 19 years out.
- [The Week That Wrapped](/gmt/scenarios/gnss-week-that-wrapped/): A receiver reports week 247, and the log reads it as a date in 1984.

## Mistakes

- [GNSS](/gmt/mistakes/gnss/): Common mistakes with satellite system times, the leap-second gap to UTC, week counters, rollover eras and RINEX weeks in GMT's GNSS layer.
