Changeset 3709 for branches/libc-0.6


Ignore:
Timestamp:
Mar 17, 2011, 2:00:53 AM (14 years ago)
Author:
bird
Message:

libc_back_timeUnix2FileTime: Dates prior to 1980 will be set to 1980-01-01T00:00:00. Fixes #198.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/sys/b_time.c

    r1972 r3709  
    77 *
    88 *
    9  * This file is part of kBuild.
     9 * This file is part of kLIBC.
    1010 *
    11  * kBuild is free software; you can redistribute it and/or modify
     11 * kLIBC is free software; you can redistribute it and/or modify
    1212 * it under the terms of the GNU General Public License as published by
    1313 * the Free Software Foundation; either version 2 of the License, or
    1414 * (at your option) any later version.
    1515 *
    16  * kBuild is distributed in the hope that it will be useful,
     16 * kLIBC is distributed in the hope that it will be useful,
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     
    2020 *
    2121 * You should have received a copy of the GNU General Public License
    22  * along with kBuild; if not, write to the Free Software
     22 * along with kLIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2424 *
    2525 */
    26 
    2726
    2827/*******************************************************************************
     
    3433#include "b_time.h"
    3534#include <time.h>
     35#include <emx/time.h>
    3636
    3737
     
    4646{
    4747    struct tm Tm;
     48   
     49    if (!_tzset_flag)
     50        tzset();
    4851    gmtime_r(&Time, &Tm);
    49 #if 0                                   /* This didn't work in GCC versions <= 2.4 */
    50     time->twosecs   = Tm.tm_sec / 2;
    51     time->minutes   = Tm.tm_min;
    52     time->hours     = Tm.tm_hour;
    53     date->day       = Tm.tm_mday;
    54     date->month     = Tm.tm_mon + 1;
    55     date->year      = Tm.tm_year - 1980 + 1900;
    56 #else
    57     USHORT us = (Tm.tm_sec / 2) + (Tm.tm_min << 5) + (Tm.tm_hour << 11);
    58     *(PUSHORT)pTime = us;
    59     us = Tm.tm_mday + ((Tm.tm_mon + 1) << 5) + ((Tm.tm_year - 80) << 9);
    60     *(PUSHORT)pDate = us;
    61 #endif
     52   
     53    if (Tm.tm_year >= 80)
     54    {
     55        pTime->twosecs   = Tm.tm_sec / 2;
     56        pTime->minutes   = Tm.tm_min;
     57        pTime->hours     = Tm.tm_hour;
     58        pDate->day       = Tm.tm_mday;
     59        pDate->month     = Tm.tm_mon + 1;
     60        pDate->year      = Tm.tm_year - 1980 + 1900;
     61    }
     62    else
     63    {
     64        pTime->twosecs   = 0;
     65        pTime->minutes   = 0;
     66        pTime->hours     = 0;
     67        pDate->day       = 1;
     68        pDate->month     = 1;
     69        pDate->year      = 0;
     70    }
    6271}
    6372
Note: See TracChangeset for help on using the changeset viewer.