commit 633c593a512c1c8b70bf596860b375d70b7e7085
parent da54bf506c49521148a7fb547feee2388ebee2d1
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Sat, 27 Mar 2021 22:32:47 +0000
Fixed wrong numbers in date handling.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
@@ -424,6 +424,7 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
Uint8 *m = u->ram.dat;
time_t seconds = time(NULL);
struct tm *t = localtime(&seconds);
+ t->tm_year += 1900;
m[ptr + 0] = (t->tm_year & 0xff00) >> 8;
m[ptr + 1] = t->tm_year & 0xff;
m[ptr + 2] = t->tm_mon;
@@ -432,8 +433,8 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
m[ptr + 5] = t->tm_min;
m[ptr + 6] = t->tm_sec;
m[ptr + 7] = t->tm_wday;
- m[ptr + 8] = (t->tm_yday & 0x100) >> 8;
- m[ptr + 9] = t->tm_yday && 0xff;
+ m[ptr + 8] = (t->tm_yday & 0xff00) >> 8;
+ m[ptr + 9] = t->tm_yday & 0xff;
m[ptr + 10] = t->tm_isdst;
return b1;
}