cancel
Showing results for 
Search instead for 
Did you mean: 

Converting date on GPS ?

antonius
Senior

Dear Members,

How can I convert date on GPS ?

UTC date 60819

into

6-August-2019 ?

thanks

15 REPLIES 15

 char *month_name[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

printf("Month Name: %c",month_name[month]);

Am I right ?

Don't use hexadecimal, the math works on decimal numbers.

>>Am I right ?

You know it doesn't work.

Strings would be %s

C arrays index from zero.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior

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

Thanks

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
Up vote any posts that you find helpful, it shows what's working..

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 ?

>>what do you reckon ?

Reckon you could test it quite easily.

The modulo 7 gives you a zero based index, don't subtract one from it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..