Browse code

Fixed wrong numbers in date handling.

Andrew Alderwick authored on 27/03/2021 22:32:47
Showing 1 changed files
... ...
@@ -424,6 +424,7 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
424 424
 	Uint8 *m = u->ram.dat;
425 425
 	time_t seconds = time(NULL);
426 426
 	struct tm *t = localtime(&seconds);
427
+	t->tm_year += 1900;
427 428
 	m[ptr + 0] = (t->tm_year & 0xff00) >> 8;
428 429
 	m[ptr + 1] = t->tm_year & 0xff;
429 430
 	m[ptr + 2] = t->tm_mon;
... ...
@@ -432,8 +433,8 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
432 433
 	m[ptr + 5] = t->tm_min;
433 434
 	m[ptr + 6] = t->tm_sec;
434 435
 	m[ptr + 7] = t->tm_wday;
435
-	m[ptr + 8] = (t->tm_yday & 0x100) >> 8;
436
-	m[ptr + 9] = t->tm_yday && 0xff;
436
+	m[ptr + 8] = (t->tm_yday & 0xff00) >> 8;
437
+	m[ptr + 9] = t->tm_yday & 0xff;
437 438
 	m[ptr + 10] = t->tm_isdst;
438 439
 	return b1;
439 440
 }