ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

localtime.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   LGPL, See LGPL.txt in the top level directory
00003  * PROJECT:     ReactOS CRT library
00004  * FILE:        lib/sdk/crt/time/localtime.c
00005  * PURPOSE:     Implementation of localtime, localtime_s
00006  * PROGRAMERS:  Timo Kreuzer
00007  *              Samuel Serapión
00008  */
00009 #include <precomp.h>
00010 #include <time.h>
00011 #include "bitsfixup.h"
00012 
00013 //fix me: header?
00014 #define _MAX__TIME64_T     0x793406fffLL     /* number of seconds from
00015                                                  00:00:00, 01/01/1970 UTC to
00016                                                  23:59:59. 12/31/3000 UTC */
00017 
00018 errno_t
00019 localtime_s(struct tm* _tm, const time_t *ptime)
00020 {
00021     /* check for NULL */
00022     if (!_tm || !ptime )
00023     {
00024         if(_tm) memset(_tm, 0xFF, sizeof(struct tm));
00025         _invalid_parameter(NULL,
00026                            0,//__FUNCTION__, 
00027                            _CRT_WIDE(__FILE__), 
00028                            __LINE__, 
00029                            0);
00030         _set_errno(EINVAL);
00031         return EINVAL;
00032     }
00033 
00034     /* Validate input */
00035     if (*ptime < 0 || *ptime > _MAX__TIME64_T)
00036     {
00037         memset(_tm, 0xFF, sizeof(struct tm));
00038         _set_errno(EINVAL);
00039         return EINVAL;
00040     }
00041 
00042     _tm = localtime(ptime);
00043     return 0;
00044 }
00045 
00046 extern char _tz_is_set;
00047 
00048 struct tm *
00049 localtime(const time_t *ptime)
00050 {
00051     time_t time = *ptime;
00052     struct tm * ptm;
00053 
00054     /* Check for invalid time value */
00055     if (time < 0)
00056     {
00057         return 0;
00058     }
00059 
00060     /* Never without */
00061     if (!_tz_is_set)
00062         _tzset();
00063 
00064     /* Check for overflow */
00065 
00066     /* Correct for timezone */
00067     time -= _timezone;
00068 #if 0
00069     /* Correct for daylight saving */
00070     if (_isdstime(time))
00071     {
00072         ptm->tm_isdst = 1;
00073         time -= _dstbias;
00074     }
00075 #endif
00076     ptm = gmtime(&time);
00077 
00078     return ptm;
00079 }
00080 

Generated on Sun May 27 2012 04:36:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.