1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <stdio.h>
void gps2jma(int GPS_week, int GPS_time, int *j, int *m, int *a)
{
int t0, t1, t2, t3;
t0 = (2444245 + GPS_week * 7 + GPS_time / 86400) + 68569;
t1 = (4 * t0) / 146097;
t0 = t0 - (146097 * t1 + 3) / 4;
t2 = (4000 * (t0 + 1)) / 1461001;
t0 = t0 - (1461 * t2) / 4 + 31;
t3 = (80 * t0) / 2447;
*j = t0 - (2447 * t3) / 80;
*m = t3 + 2 - (12 * (t3 / 11));
*a = 100 * (t1 - 49) + t2 + (t3 / 11);
}
int main(void)
{
int jour,
mois,
annee,
GPS_week = 1524,
GPS_time = 345600;
gps2jma(GPS_week, GPS_time, &jour, &mois, &annee);
printf("\nGPS_week: %d\nGPS_time: %d\nResultat: %02d/%02d/%d\n", GPS_week, GPS_time, jour, mois, annee);
return 0;
} |
Partager