Code: Select all
year = year % 100;
This is part of the date and time example in chapter 23. I understand that it’s getting the date from the ST, converting the bits and adding 80 to get the year, but what does the above code do?
Thanks!
Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
Code: Select all
year = year % 100;
Code: Select all
year = ((date >> 9) & 0x007f) + 80;
Code: Select all
strncpy ( s, &string[4] );
h= atoi ( s ) - 80;
h = h << 9;
date = date | h;
Code: Select all
strncpy ( s, &string[4], 2 );
Code: Select all
char s[3]; /* Temporary string storage. */
[...]
/* Extract "hours" portion and convert to integer. */
strncpy(s, string, 2);
h = atoi(s);
Users browsing this forum: No registered users and 1 guest