3  * This file is a part of LEMON, a generic C++ optimization library
 
     5  * Copyright (C) 2003-2007
 
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
 
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
 
     9  * Permission to use, modify and distribute this software is granted
 
    10  * provided that this copyright notice appears in all copies. For
 
    11  * precise terms see the accompanying LICENSE file.
 
    13  * This software is provided "AS IS" with no warranty of any kind,
 
    14  * express or implied, and with no claim as to its suitability for any
 
    21 #include <lemon/bits/mingw32_time.h>
 
    27 static const char days[] = 
 
    28 "Sun Mon Tue Wed Thu Fri Sat ";
 
    29 static const char months[] = 
 
    30 "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
 
    32 void num2str(char *c,int i) {
 
    37 char *asctime_r(const struct tm *t, char *buf) {
 
    38   *(int*)buf=*(int*)(days+(t->tm_wday<<2));
 
    39   *(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2));
 
    40   num2str(buf+8,t->tm_mday);
 
    41   if (buf[8]=='0') buf[8]=' ';
 
    43   num2str(buf+11,t->tm_hour);
 
    45   num2str(buf+14,t->tm_min);
 
    47   num2str(buf+17,t->tm_sec);
 
    49   num2str(buf+20,(t->tm_year+1900)/100);
 
    50   num2str(buf+22,(t->tm_year+1900)%100);
 
    51   buf[24]='\n'; buf[25]='\0';
 
    55 struct tm * localtime_r (const time_t *t, struct tm *tm) {
 
    58   if ((tmp = localtime(t)) && tm)
 
    66 char *ctime_r(const time_t * tim_p , char * result) {
 
    68   return asctime_r (localtime_r (tim_p, &tm), result);
 
    72 int gettimeofday(struct timeval * tp, struct timezone *) {
 
    77     time_t theTime = time(NULL);
 
    80     tmrec = *localtime(&theTime);
 
    81     tp->tv_sec = mktime(&tmrec);
 
    82     GetLocalTime(&systime); /* system time */
 
    84     tp->tv_usec = systime.wMilliseconds * 1000;
 
    89 long filetime_to_clock(FILETIME *ft)
 
    91   __int64 qw = ft->dwHighDateTime;
 
    93   qw |= ft->dwLowDateTime;
 
    99 int times(struct tms *tmbuf)
 
   101   FILETIME create, exit, kernel, user;
 
   102   if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
 
   103     tmbuf->tms_utime = filetime_to_clock(&user);
 
   104     tmbuf->tms_stime = filetime_to_clock(&kernel);
 
   105     tmbuf->tms_cutime = 0;
 
   106     tmbuf->tms_cstime = 0;
 
   109     tmbuf->tms_utime = clock();
 
   110     tmbuf->tms_stime = 0;
 
   111     tmbuf->tms_cutime = 0;
 
   112     tmbuf->tms_cstime = 0;