1 /* 2 * COPYRIGHT: LGPL, See LGPL.txt 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 <sys/timeb.h> 10 #include "bitsfixup.h" 11 12 /****************************************************************************** 13 * \name _ftime_s 14 * \brief Get the current time. 15 * \param [out] ptimeb Pointer to a structure of type struct _timeb that 16 * receives the current time. 17 * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx 18 */ 19 errno_t 20 CDECL 21 _ftime_s(struct _timeb *ptimeb) 22 { 23 DWORD ret; 24 TIME_ZONE_INFORMATION TimeZoneInformation; 25 FILETIME SystemTime; 26 27 /* Validate parameters */ 28 if (!MSVCRT_CHECK_PMT( ptimeb != NULL )) 29 { 30 *_errno() = EINVAL; 31 return EINVAL; 32 } 33 34 ret = GetTimeZoneInformation(&TimeZoneInformation); 35 ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0; 36 ptimeb->timezone = (short)TimeZoneInformation.Bias; 37 38 GetSystemTimeAsFileTime(&SystemTime); 39 ptimeb->time = (time_t)FileTimeToUnixTime(&SystemTime, &ptimeb->millitm); 40 41 return 0; 42 } 43 44 /****************************************************************************** 45 * \name _ftime 46 * \brief Get the current time. 47 * \param [out] ptimeb Pointer to a structure of type struct _timeb that 48 * receives the current time. 49 * \note This function is for compatability and simply calls the secure 50 * version _ftime_s(). 51 * \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx 52 */ 53 void 54 CDECL 55 _ftime(struct _timeb *ptimeb) 56 { 57 _ftime_s(ptimeb); 58 } 59