Index: lemon/CMakeLists.txt
===================================================================
--- lemon/CMakeLists.txt	(revision 474)
+++ lemon/CMakeLists.txt	(revision 492)
@@ -15,5 +15,7 @@
   lp_base.cc
   lp_skeleton.cc
-  random.cc)
+  random.cc
+  bits/windows.cc
+)
 
 IF(HAVE_GLPK)
Index: lemon/Makefile.am
===================================================================
--- lemon/Makefile.am	(revision 469)
+++ lemon/Makefile.am	(revision 492)
@@ -13,5 +13,6 @@
 	lemon/lp_base.cc \
 	lemon/lp_skeleton.cc \
-	lemon/random.cc
+        lemon/random.cc \
+	lemon/bits/windows.cc
 
 
@@ -91,5 +92,6 @@
 	lemon/time_measure.h \
 	lemon/tolerance.h \
-	lemon/unionfind.h
+	lemon/unionfind.h \
+	lemon/bits/windows.h
 
 bits_HEADERS += \
Index: lemon/bits/windows.cc
===================================================================
--- lemon/bits/windows.cc	(revision 491)
+++ lemon/bits/windows.cc	(revision 491)
@@ -0,0 +1,136 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2009
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+///\file
+///\brief Some basic non-inline functions and static global data.
+
+#include<lemon/bits/windows.h>
+
+#ifdef WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <ctime>
+#include <sys/times.h>
+#include <sys/time.h>
+#endif
+
+#include <cmath>
+#include <sstream>
+
+namespace lemon {
+  namespace bits {
+    void getWinProcTimes(double &rtime,
+                         double &utime, double &stime,
+                         double &cutime, double &cstime)
+    {
+#ifdef WIN32
+      static const double ch = 4294967296.0e-7;
+      static const double cl = 1.0e-7;
+
+      FILETIME system;
+      GetSystemTimeAsFileTime(&system);
+      rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
+
+      FILETIME create, exit, kernel, user;
+      if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
+        utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
+        stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
+        cutime = 0;
+        cstime = 0;
+      } else {
+        rtime = 0;
+        utime = 0;
+        stime = 0;
+        cutime = 0;
+        cstime = 0;
+      }
+#else
+      timeval tv;
+      gettimeofday(&tv, 0);
+      rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
+
+      tms ts;
+      double tck=sysconf(_SC_CLK_TCK);
+      times(&ts);
+      utime=ts.tms_utime/tck;
+      stime=ts.tms_stime/tck;
+      cutime=ts.tms_cutime/tck;
+      cstime=ts.tms_cstime/tck;
+#endif
+    }
+
+    std::string getWinFormattedDate()
+    {
+      std::ostringstream os;
+#ifdef WIN32
+      SYSTEMTIME time;
+      GetSystemTime(&time);
+#if defined(_MSC_VER) && (_MSC_VER < 1500)
+      LPWSTR buf1, buf2, buf3;
+      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
+                        L"ddd MMM dd", buf1, 11) &&
+          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
+                        L"HH':'mm':'ss", buf2, 9) &&
+          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
+                        L"yyyy", buf3, 5)) {
+        os << buf1 << ' ' << buf2 << ' ' << buf3;
+      }
+#else
+      char buf1[11], buf2[9], buf3[5];
+      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
+                        "ddd MMM dd", buf1, 11) &&
+          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
+                        "HH':'mm':'ss", buf2, 9) &&
+          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
+                        "yyyy", buf3, 5)) {
+        os << buf1 << ' ' << buf2 << ' ' << buf3;
+      }
+#endif
+      else os << "unknown";
+#else
+      timeval tv;
+      gettimeofday(&tv, 0);
+
+      char cbuf[26];
+      ctime_r(&tv.tv_sec,cbuf);
+      os << cbuf;
+#endif
+      return os.str();
+    }
+
+    int getWinRndSeed()
+    {
+#ifdef WIN32
+      FILETIME time;
+      GetSystemTimeAsFileTime(&time);
+      return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime;
+#else
+      timeval tv;
+      gettimeofday(&tv, 0);
+      return getpid() + tv.tv_sec + tv.tv_usec;
+#endif
+    }
+  }
+}
Index: lemon/bits/windows.h
===================================================================
--- lemon/bits/windows.h	(revision 491)
+++ lemon/bits/windows.h	(revision 491)
@@ -0,0 +1,34 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2009
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_WINDOWS_H
+#define LEMON_WINDOWS_H
+
+#include <string>
+
+namespace lemon {
+  namespace bits {
+    void getWinProcTimes(double &rtime,
+                         double &utime, double &stime,
+                         double &cutime, double &cstime);
+    std::string getWinFormattedDate();
+    int getWinRndSeed();
+  }
+}
+
+#endif
Index: lemon/graph_to_eps.h
===================================================================
--- lemon/graph_to_eps.h	(revision 485)
+++ lemon/graph_to_eps.h	(revision 492)
@@ -30,11 +30,5 @@
 #include<ctime>
 #else
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-#include<windows.h>
+#include<lemon/bits/windows.h>
 #endif
 
@@ -684,4 +678,5 @@
 
     {
+      os << "%%CreationDate: ";
 #ifndef WIN32
       timeval tv;
@@ -690,33 +685,10 @@
       char cbuf[26];
       ctime_r(&tv.tv_sec,cbuf);
-      os << "%%CreationDate: " << cbuf;
+      os << cbuf;
 #else
-      SYSTEMTIME time;
-      GetSystemTime(&time);
-#if defined(_MSC_VER) && (_MSC_VER < 1500)
-      LPWSTR buf1, buf2, buf3;
-      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"ddd MMM dd", buf1, 11) &&
-          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"HH':'mm':'ss", buf2, 9) &&
-          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"yyyy", buf3, 5)) {
-        os << "%%CreationDate: " << buf1 << ' '
-           << buf2 << ' ' << buf3 << std::endl;
-      }
-#else
-        char buf1[11], buf2[9], buf3[5];
-        if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                          "ddd MMM dd", buf1, 11) &&
-            GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
-                          "HH':'mm':'ss", buf2, 9) &&
-            GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                          "yyyy", buf3, 5)) {
-          os << "%%CreationDate: " << buf1 << ' '
-             << buf2 << ' ' << buf3 << std::endl;
-        }
+      os << bits::getWinFormattedDate();
 #endif
-#endif
-    }
+    }
+    os << std::endl;
 
     if (_autoArcWidthScale) {
Index: lemon/random.h
===================================================================
--- lemon/random.h	(revision 440)
+++ lemon/random.h	(revision 492)
@@ -78,5 +78,5 @@
 #include <unistd.h>
 #else
-#include <windows.h>
+#include <lemon/bits/windows.h>
 #endif
 
@@ -663,7 +663,5 @@
       seed(getpid() + tv.tv_sec + tv.tv_usec);
 #else
-      FILETIME time;
-      GetSystemTimeAsFileTime(&time);
-      seed(GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime);
+      seed(bits::getWinRndSeed());
 #endif
       return true;
Index: lemon/time_measure.h
===================================================================
--- lemon/time_measure.h	(revision 485)
+++ lemon/time_measure.h	(revision 492)
@@ -25,12 +25,5 @@
 
 #ifdef WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-#include <windows.h>
-#include <cmath>
+#include <lemon/bits/windows.h>
 #else
 #include <unistd.h>
@@ -93,24 +86,5 @@
       cstime=ts.tms_cstime/tck;
 #else
-      static const double ch = 4294967296.0e-7;
-      static const double cl = 1.0e-7;
-
-      FILETIME system;
-      GetSystemTimeAsFileTime(&system);
-      rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
-
-      FILETIME create, exit, kernel, user;
-      if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
-        utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
-        stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
-        cutime = 0;
-        cstime = 0;
-      } else {
-        rtime = 0;
-        utime = 0;
-        stime = 0;
-        cutime = 0;
-        cstime = 0;
-      }
+      bits::getWinProcTimes(rtime, utime, stime, cutime, cstime);
 #endif
     }
