5e630450b4a94cef34e214b38c5cc1646c92f448
[reactos.git] / reactos / lib / sdk / crt / time_new / ftime.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS CRT library
4 * FILE: lib/sdk/crt/time/ftime.c
5 * PURPOSE: Deprecated BSD library call
6 * PROGRAMERS: Timo Kreuzer
7 */
8 #include <precomp.h>
9 #include <sec_api/time_s.h>
10 #include <sys/timeb.h>
11 #include "bitsfixup.h"
12
13 /******************************************************************************
14 * \name _ftime_s
15 * \brief Get the current time.
16 * \param [out] ptimeb Pointer to a structure of type struct _timeb that
17 * recieves the current time.
18 * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
19 */
20 errno_t
21 _ftime_s(struct _timeb *ptimeb)
22 {
23 DWORD ret;
24 TIME_ZONE_INFORMATION TimeZoneInformation;
25 FILETIME SystemTime;
26
27 /* Validate parameters */
28 if (!ptimeb)
29 {
30 _invalid_parameter(0,
31 0,//__FUNCTION__,
32 _CRT_WIDE(__FILE__),
33 __LINE__,
34 0);
35 return EINVAL;
36 }
37
38 ret = GetTimeZoneInformation(&TimeZoneInformation);
39 ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0;
40 ptimeb->timezone = TimeZoneInformation.Bias;
41
42 GetSystemTimeAsFileTime(&SystemTime);
43 ptimeb->time = FileTimeToUnixTime(&SystemTime, &ptimeb->millitm);
44
45 return 0;
46 }
47
48 /******************************************************************************
49 * \name _ftime
50 * \brief Get the current time.
51 * \param [out] ptimeb Pointer to a structure of type struct _timeb that
52 * recieves the current time.
53 * \note This function is for compatability and simply calls the secure
54 * version _ftime_s().
55 * \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx
56 */
57 void
58 _ftime(struct _timeb *ptimeb)
59 {
60 _ftime_s(ptimeb);
61 }