12,452,015 members (25,806 online)
Rate this:
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

Rate this:

See here[^].
Rate this:

Rate this:

## 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```

Top Experts
Last 24hrsThis month
 ppolymorphe 174 Richard MacCutchan 115 OriginalGriff 110 Karthik Bangalore 85 Maciej Los 80
 OriginalGriff 6,123 ppolymorphe 3,755 Karthik Bangalore 3,545 Maciej Los 3,075 Richard Deeming 2,835