blob: 15df955a4841b6a30deb444c21e5400eb9f8a6f0 [file] [log] [blame]
Alexandre Julliardaf0bae51995-10-03 17:06:08 +00001/*
2 * Win32 kernel functions
3 *
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 */
6
7#include <string.h>
8#include <time.h>
Alexandre Julliardd4719651995-12-12 18:49:11 +00009#include <sys/time.h>
Alexandre Julliardaf0bae51995-10-03 17:06:08 +000010#include <unistd.h>
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000011#include "file.h"
Alexandre Julliardaf0bae51995-10-03 17:06:08 +000012#include "winerror.h"
Alexandre Julliard15657091999-05-23 10:25:25 +000013#include "debugtools.h"
Alexandre Julliardaf0bae51995-10-03 17:06:08 +000014
Dimitrie O. Paun529da542000-11-27 23:54:25 +000015DEFAULT_DEBUG_CHANNEL(win32);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000016
Alexandre Julliardaf0bae51995-10-03 17:06:08 +000017/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +000018 * GetLocalTime (KERNEL32.@)
Alexandre Julliardd4719651995-12-12 18:49:11 +000019 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +000020VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
Alexandre Julliardd4719651995-12-12 18:49:11 +000021{
22 time_t local_time;
23 struct tm *local_tm;
24 struct timeval tv;
25
Alexandre Julliardd4719651995-12-12 18:49:11 +000026 gettimeofday(&tv, NULL);
Alexandre Julliard02ed4c21996-03-02 19:34:10 +000027 local_time = tv.tv_sec;
28 local_tm = localtime(&local_time);
Alexandre Julliardd4719651995-12-12 18:49:11 +000029
30 systime->wYear = local_tm->tm_year + 1900;
31 systime->wMonth = local_tm->tm_mon + 1;
32 systime->wDayOfWeek = local_tm->tm_wday;
33 systime->wDay = local_tm->tm_mday;
34 systime->wHour = local_tm->tm_hour;
35 systime->wMinute = local_tm->tm_min;
36 systime->wSecond = local_tm->tm_sec;
37 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
38}
39
Andreas Mohr973cc742000-09-12 23:39:10 +000040/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +000041 * GetSystemTime (KERNEL32.@)
Alexandre Julliardd7d4fdf1995-12-26 15:05:24 +000042 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +000043VOID WINAPI GetSystemTime(LPSYSTEMTIME systime)
Alexandre Julliardd7d4fdf1995-12-26 15:05:24 +000044{
45 time_t local_time;
46 struct tm *local_tm;
47 struct timeval tv;
48
Alexandre Julliardd7d4fdf1995-12-26 15:05:24 +000049 gettimeofday(&tv, NULL);
Alexandre Julliard02ed4c21996-03-02 19:34:10 +000050 local_time = tv.tv_sec;
51 local_tm = gmtime(&local_time);
Alexandre Julliardd7d4fdf1995-12-26 15:05:24 +000052
53 systime->wYear = local_tm->tm_year + 1900;
54 systime->wMonth = local_tm->tm_mon + 1;
55 systime->wDayOfWeek = local_tm->tm_wday;
56 systime->wDay = local_tm->tm_mday;
57 systime->wHour = local_tm->tm_hour;
58 systime->wMinute = local_tm->tm_min;
59 systime->wSecond = local_tm->tm_sec;
60 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
61}