2019-08-06 01:51 AM
Dear Members,
How can I convert date on GPS ?
UTC date 60819
into
6-August-2019 ?
thanks
2019-08-06 04:34 AM
Couldn't you divide by 100 and 10000 to extract the DD, MM and YY fields, and add 1900 or 2000 depending if YY is below 80
2019-08-07 09:56 PM
correct me ?
day = date/10000;
month = date/100-(day*100);
year = date/100-((day*100)+month);
2019-08-08 07:15 PM
int day,month,year;
day = date/10000;
month = date/100-(day*100);
year = date/100-((day*100)+month);
printf("======================GPRMC PARSING =================\r\n");
printf("UTC date %x \r\n",date);
printf("Day %u-",day);
printf("Month %u-",month);
printf("Year %u-",year);
printf("\r\n");
printf("====================== D O N E !=================\r\n");
am I right ?
Thanks
2019-08-08 07:45 PM
>> am I right ? correct me ?
Put the code in a function, and run test cases against it.
The year computation is broken
2019-08-08 07:49 PM
thanks for the response,
what do I miss on year computation ?
thanks
2019-08-08 07:51 PM
UTC date 60819
Day 6 Month 8 Year 19
UTC date 60180
Day 6 Month 1 Year 80
UTC date 310517
Day 31 Month 5 Year 17
UTC date 60819
Day 6 Month 8 Year 2019
UTC date 60180
Day 6 Month 1 Year 1980
UTC date 310517
Day 31 Month 5 Year 2017
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
void test1(int date)
{
int day, month, year;
printf("UTC date %6d \r\n",date);
day = date/10000;
month = (date - (day*10000)) / 100;
year = date - (((day*100) + month) * 100);
printf("Day %2d Month %2d Year %2d\n",day, month, year);
}
void test2(int date)
{
int day, month, year;
printf("UTC date %6d \r\n",date);
day = date / 10000;
date = date % 10000;
month = date / 100;
year = date % 100;
if (year < 80) year += 2000; else year += 1900;
printf("Day %2d Month %2d Year %4d\n",day, month, year);
}
int main(int argc, char **argv)
{
test1(60819);
test1(60180);
test1(310517);
putchar('\n');
test2(60819);
test2(60180);
test2(310517);
putchar('\n');
return(1);
}
2019-08-08 07:54 PM
Thanks Clive, I will test it and keep posted, thank you...
2019-08-10 02:25 AM
I got output :
UTC date 1050649
Day 105 Month 6 Year 2049
for input 100819
2019-08-10 02:26 AM
sscanf(field[9],"%x",&date); // UTC date
test1(date);
test2(date);