Skip to main content

Switch Gregorian date to GNSS calendar (GPS & BDS).

Project description

This module contains functions for converting between Gregorian date, day of year and GNSS calendar, now support GNSS calendar for GPS and BDS.

There are 3 functions for converting between Gregorian date and day of year (doy):

yrdoy2date(year, doy)

Using them like:

>>> from datetime import date

>>> date2doy(date(2017, 5, 17))

>>> date2yrdoy(date(2017, 5, 17))
(2017, 137)

>>> yrdoy2date(2017, 137), 5, 17)

There are 4 functions for converting between Gregorian date and GNSS calendars (GPS or BDS):

gpswd2date(gpsweek, dayofweek)
bdswd2date(bdsweek, dayofweek)

Using them like:

>>> from datetime import date

>>> date2gpswd(date(2017, 5, 17))
(1949, 3)

>>> date2bdswd(date(2017, 5, 17))
(593, 3)

>>> gpswd2date(1949, 3), 5, 17)

>>> bdswd2date(593, 3), 5, 17)

There are 4 functions for converting between year, day of year (doy) and GNSS calendars (GPS or BDS):

yrdoy2gpswd(year, doy)
yrdoy2bdswd(year, doy)
gpswd2yrdoy(gpsweek, dayofweek)
bdswd2yrdoy(bdsweek, dayofweek)

Using them like:

>>> yrdoy2gpswd(2017, 137)
(1949, 3)

>>> yrdoy2bdswd(2017, 137)
(593, 3)

>>> gpswd2yrdoy(1949, 3)
(2017, 137)

>>> bdswd2yrdoy(593, 3)
(2017, 137)

There are also 2 functions for converting between GPS calendar and BDS calendar:


Using them like:

>>> gpsw2bdsw(1949)

>>> bdsw2gpsw(593)

Where the type of date is and others are int or tuple of int.

Zero point of GPS and BDS are also given as module level constains in Gregorian date.


import gnsscal
from datetime import date

# Convert Gregorian date to GPS calendar
today =
gpsweek, days = gnsscal.date2gpswd(today)

# Convert GPS week to BDS week
gpsweek = 1812
bdsweek = gnsscal.gpsw2bdsw(gpsweek)

# Get zero point of GPS and BDS calendar
gps_zero = gnsscal.GPS_START_DATE
bds_zero = gnsscal.BDS_START_DATE

CLI mode

You can also using gnsscal in CLI mode:

$ python -m gnsscal [options]

Set input date using the optional arguments:

-h, --help                          show this help message and exit
-v, --version                       show program's version number and exit
-date <year> <month> <day>          year, month, day
-ydoy <year> <doy>                  year, day of year
-gpswd <GPS week> <day of week>     GPS week, day of week
-bdswd <BDS week> <day of week>     BDS week, day of week

Example, typing this command in terminal:

$ python -m gnsscal -date 2017 5 17

Then it will print:

Gregorian date: 2017-05-17
year, doy: 2017, 137
GPS week: 1949, 3
BDS week: 0593, 3


The module can be installed using pip:

$ pip install gnsscal


Test using command:

$ python


Released under BSD, see LICENSE for more details.

For comments and suggestions, please send email to: jiangyingming(at)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gnsscal, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size gnsscal-1.1.1-py2.py3-none-any.whl (7.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size gnsscal-1.1.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page