[PATCH 18/39] win32: add gettimeofday()
Dan Fandrich
dan at coneharvesters.com
Fri Apr 16 07:48:05 UTC 2010
On Thu, Apr 15, 2010 at 10:00:53PM +0200, Nguy�n Thái Ng�c Duy wrote:
> +int gettimeofday(struct timeval *tv, void *tz)
> +{
> + SYSTEMTIME st;
> + struct tm tm;
> + GetSystemTime(&st);
> + tm.tm_year = st.wYear-1900;
> + tm.tm_mon = st.wMonth-1;
> + tm.tm_mday = st.wDay;
> + tm.tm_hour = st.wHour;
> + tm.tm_min = st.wMinute;
> + tm.tm_sec = st.wSecond;
> + tv->tv_sec = tm_to_time_t(&tm);
> + if (tv->tv_sec < 0)
> + return -1;
errno is supposed to be set here when an error is indicated.
> + tv->tv_usec = st.wMilliseconds*1000;
> + return 0;
> +}
It's probably a good idea to also return an error if tz != NULL just in
case anyone tries to use it.
>>> Dan
--
http://www.MoveAnnouncer.com The web change of address service
Let webmasters know that your web site has moved
More information about the busybox
mailing list