13,048,584 members (91,301 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I need help. Actually I do not know how to calculate a GPS time and GPS week, GPS day of the week.

I would like the current date calculated GPS date, GPS week and GPS time in seconds.

thanks for the help, if there is some sample code to help me out a lot.
Posted 30-Sep-12 22:20pm

## 3 solutions

Rate this:
Please Sign up or sign in to vote.

## Solution 1

See here[^].
Rate this:
Please Sign up or sign in to vote.

## Solution 2

Rate this:
Please Sign up or sign in to vote.

## Solution 3

```// racunam gps nedelju
// prvo racunam julijanski dan
// koriscen algoritam "Practical Ephemeris Calculations" - oliver Montenbruck
// Springer - Verlag, 1989)
double yr = Convert.ToDouble(godina);
double mn = Convert.ToDouble(mesec);
double dy = Convert.ToDouble(datumUmesecu);
double y = 0;
double m = 0;
double b = 0;
double jd = 0;

if (mn > 2)
{
y = yr;
m = mn;
}
else
{
y = yr - 1;
m = mn + 12;
}

double date0 = dy + 31 * (mn + 12 * yr);
double date1 = 4 + 31 * (10 + 12 * 1582);
double date2 = 15 + 31 * (10 + 12 * 1582);

if (date0 < date1)
{
b = -2;
}
else
{
b = y / 400 - y / 100;
}

if ( y > 0)
{
jd = 365.25 * y + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
}
else
{
jd = 365.25 * y - 0.75 + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
}

double mjd = jd - 2400000.5;// modifikovvani julijanski datum

// GPS nedelja racunam
double jd1 = 0;
yr = 1980;
mn = 1;
dy = 6;
if (mn > 2)
{
y = yr;
m = mn;
}
else
{
y = yr - 1;
m = mn + 12;
}
date0 = dy + 31 * (mn + 12 * yr);
date1 = 4 + 31 * (10 + 12 * 1582);
date2 = 15 + 31 * (10 + 12 * 1582);

if (date0 < date1)
{
b = -2;
}
else
{
b = y / 400 - y / 100;
}

if (y > 0)
{
jd1 = 365.25 * y + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
}
else
{
jd1 = 365.25 * y - 0.75 + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
}
double jdgps = jd1 - 2400000.5;// modifikovani julijanski datum
double gpsWeek = (jd - jd1) / 7;// gps nedelja
double sow = (jd - (jd1 + Convert.ToInt32(gpsWeek) * 7)) * 3600 * 24;// sekunda u nedelji
// kraj racunanja gps nedelje```

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Satya Prakash Swain 130 Richard MacCutchan 114 Atlapure Ambrish 95 OriginalGriff 95 Jochen Arndt 85
 OriginalGriff 4,963 RickZeeland 1,924 ppolymorphe 1,753 F-ES Sitecore 1,553 Dave Kreskowiak 1,379

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100