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-10 02:45 AM
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 ?
2019-08-10 07:21 AM
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.
2019-08-11 08:50 PM
How can I get the day name ? (Monday,Tuesday, etc ), still using divider ?
Thanks
2019-08-11 09:23 PM
It gets significantly more complicated, you'd need to convert into a Julian date number or Unix time, and extract the day from that.
2019-08-11 09:28 PM
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 ?
2019-08-12 11:19 AM
>>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.