mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-30 09:43:02 +00:00
datetime: don't crash if localtime failed
This commit is contained in:
parent
60698c787a
commit
6c1720e328
1 changed files with 3 additions and 0 deletions
|
@ -384,7 +384,10 @@ static Uint8
|
||||||
datetime_dei(Device *d, Uint8 port)
|
datetime_dei(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
time_t seconds = time(NULL);
|
time_t seconds = time(NULL);
|
||||||
|
struct tm zt = {0};
|
||||||
struct tm *t = localtime(&seconds);
|
struct tm *t = localtime(&seconds);
|
||||||
|
if(t == NULL)
|
||||||
|
t = &zt;
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x0: return (t->tm_year + 1900) >> 8;
|
case 0x0: return (t->tm_year + 1900) >> 8;
|
||||||
case 0x1: return (t->tm_year + 1900);
|
case 0x1: return (t->tm_year + 1900);
|
||||||
|
|
Loading…
Reference in a new issue