From 0d9f2bb886dc442589cf77b5f246b916a22d4e8f Mon Sep 17 00:00:00 2001 From: superturbocat2001 Date: Thu, 4 Feb 2021 15:26:06 +0000 Subject: [PATCH] Fixed date in time() function newlibc git-svn-id: svn://kolibrios.org@8573 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/sdk/sources/newlib/libc/sys/gettod.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/sdk/sources/newlib/libc/sys/gettod.c b/contrib/sdk/sources/newlib/libc/sys/gettod.c index f1aa3c8f1d..cb9c13c345 100644 --- a/contrib/sdk/sources/newlib/libc/sys/gettod.c +++ b/contrib/sdk/sources/newlib/libc/sys/gettod.c @@ -27,11 +27,16 @@ _DEFUN (gettimeofday, (ptimeval, ptimezone), BCD_TO_BIN(tmblk.tm_min); BCD_TO_BIN(tmblk.tm_hour); __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29)); - tmblk.tm_mday = (xtmp>>16)&0xff; - tmblk.tm_mon = ((xtmp>>8)&0xff)-1; - tmblk.tm_year = ((xtmp&0xff)+2000)-1900; - tmblk.tm_wday = tmblk.tm_yday = 0; - tmblk.tm_isdst = -1; + + int bcd_day = (xtmp >> 16); + int bcd_mon = ((xtmp & 0xFF00) >> 8); + int bcd_year = (xtmp & 0xFF); + + tmblk.tm_mday = ((bcd_day & 0xF0)>>4)*10 + (bcd_day & 0x0F); + tmblk.tm_mon = ((bcd_mon & 0xF0)>>4)*10 + (bcd_mon & 0x0F) - 1; + tmblk.tm_year = ((bcd_year & 0xF0)>>4)*10 + (bcd_year & 0x0F) + 100; + + tmblk.tm_wday = tmblk.tm_yday = tmblk.tm_isdst = -1; ptimeval->tv_sec = mktime(&tmblk); return 0; }