ReactOS 0.4.15-dev-7958-gcd0bb1a
ftime.c
Go to the documentation of this file.
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 */
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 */
53void
55_ftime(struct _timeb *ptimeb)
56{
57 _ftime_s(ptimeb);
58}
#define EINVAL
Definition: acclib.h:90
int errno_t
Definition: crtdefs.h:374
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
__kernel_time_t time_t
Definition: linux.h:252
unsigned long DWORD
Definition: ntddk_ex.h:95
errno_t CDECL _ftime_s(struct _timeb *ptimeb)
Definition: ftime.c:21
void CDECL _ftime(struct _timeb *ptimeb)
Definition: ftime.c:55
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:254
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:17
static __inline __time64_t FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
Definition: time.h:14
Definition: timeb.h:24
short dstflag
Definition: timeb.h:28
time_t time
Definition: timeb.h:25
unsigned short millitm
Definition: timeb.h:26
short timezone
Definition: timeb.h:27
int ret