-Deactivate _invalid_parameter for now, depends on the strsafe crt implementation...
[reactos.git] / reactos / lib / sdk / crt / time_new / localtime.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS CRT library
4 * FILE: lib/sdk/crt/time/localtime.c
5 * PURPOSE: Implementation of localtime, localtime_s
6 * PROGRAMERS: Timo Kreuzer
7 */
8 #include <precomp.h>
9 #include <time.h>
10 #include "bitsfixup.h"
11
12 errno_t
13 localtime_s(struct tm* _tm, const time_t *ptime)
14 {
15
16 /* Validate parameters */
17 if (!_tm || !ptime)
18 {
19 #if 0
20 _invalid_parameter(NULL,
21 0,//__FUNCTION__,
22 _CRT_WIDE(__FILE__),
23 __LINE__,
24 0);
25 #endif
26 return EINVAL;
27 }
28
29
30 return 0;
31 }
32
33 extern char _tz_is_set;
34
35 struct tm *
36 localtime(const time_t *ptime)
37 {
38 time_t time = *ptime;
39 struct tm * ptm;
40
41 /* Check for invalid time value */
42 if (time < 0)
43 {
44 return 0;
45 }
46
47 /* Never without */
48 if (!_tz_is_set)
49 _tzset();
50
51 /* Check for overflow */
52
53 /* Correct for timezone */
54 time -= _timezone;
55 #if 0
56 /* Correct for daylight saving */
57 if (_isdstime(time))
58 {
59 ptm->tm_isdst = 1;
60 time -= _dstbias;
61 }
62 #endif
63 ptm = gmtime(&time);
64
65 return ptm;
66 }
67