Skip to main content
antonius
Associate III
August 6, 2019
Question

Converting date on GPS ?

  • August 6, 2019
  • 15 replies
  • 2070 views

Dear Members,

How can I convert date on GPS ?

UTC date 60819

into

6-August-2019 ?

thanks

    This topic has been closed for replies.

    15 replies

    Tesla DeLorean
    Guru
    August 6, 2019

    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

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    August 9, 2019
    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

    Tesla DeLorean
    Guru
    August 9, 2019

    >> am I right ? correct me ?

    Put the code in a function, and run test cases against it.

    The year computation is broken

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    August 8, 2019

    correct me ?

       day = date/10000;

             month = date/100-(day*100);

             year = date/100-((day*100)+month);

    antonius
    antoniusAuthor
    Associate III
    August 12, 2019

    How can I get the day name ? (Monday,Tuesday, etc ), still using divider ?

    Thanks

    Tesla DeLorean
    Guru
    August 12, 2019

    It gets significantly more complicated,​ you'd need to convert into a Julian date number or Unix time, and extract the day from that.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    August 12, 2019

    I got this formula but if it's outside if, it's changing the date, I try inside if

     if (year < 80) year += 2000; else year += 1900;
     
     printf("Day %2d Month %2d Year %4d\n",day, month, year);
    	printf("Month Name: ");printf(month_name[month-1]);printf("\r\n");
    	printf("Date : %2d-",day);printf(month_name[month-1]);printf("-%2d",year);printf("\r\n");
    	//weekday name
    	int weekday = (day += month < 3 ? year-- : year - 2, 23*month/9 + day + 4 + year/4- year/100 + year/400)%7;
    		printf("Weekday : %d \r\n",weekday);
    	 printf("Weekday name : %s \r\n",weekday_name[weekday-1]);

    what do you reckon ?