From be6e909c5bda0ae2d1ff2ea057127e099356c232 Mon Sep 17 00:00:00 2001
From: iceman1001 <iceman@iuse.se>
Date: Sat, 23 Apr 2016 13:02:20 +0200
Subject: [PATCH] FIX: time printing,  like difftime in MINGW enviroments needs
 to use 32b time.

---
 client/cmdhfmf.c   | 4 ++--
 client/proxmark3.h | 4 ++++
 client/uart.h      | 1 -
 client/ui.h        | 1 +
 client/util.h      | 2 +-
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c
index 2e1b2186..0e3024a0 100644
--- a/client/cmdhfmf.c
+++ b/client/cmdhfmf.c
@@ -1230,10 +1230,10 @@ int CmdHF14AMfChk(const char *Cmd) {
 	t1 = clock() - t1;
 	time(&end);
 	unsigned long elapsed_time = difftime(end, start);	
-
 	if ( t1 > 0 )
-		printf("\nTime in checkkeys: %.0f ticks %u seconds\n", (float)t1, elapsed_time);
+		PrintAndLog("\nTime in checkkeys: %.0f ticks %u seconds\n", (float)t1, elapsed_time);
 
+		
 	// 20160116 If Sector A is found, but not Sector B,  try just reading it of the tag?
 	if ( keyType != 1 ) {
 		PrintAndLog("testing to read key B...");
diff --git a/client/proxmark3.h b/client/proxmark3.h
index 6665b75b..89cac878 100644
--- a/client/proxmark3.h
+++ b/client/proxmark3.h
@@ -12,6 +12,10 @@
 #ifndef PROXMARK3_H__
 #define PROXMARK3_H__
 
+#ifdef __WIN32
+// for MINGW32 environments
+   #define _USE_32BIT_TIME_T 1
+#endif   
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 #define lx  PRIx32
diff --git a/client/uart.h b/client/uart.h
index 747c0f26..d520e7f4 100644
--- a/client/uart.h
+++ b/client/uart.h
@@ -37,7 +37,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-
 #include <stdint.h>
 #include <stdbool.h>
 
diff --git a/client/ui.h b/client/ui.h
index b5133ab4..3417f362 100644
--- a/client/ui.h
+++ b/client/ui.h
@@ -10,6 +10,7 @@
 
 #ifndef UI_H__
 #define UI_H__
+
 #define _USE_MATH_DEFINES
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/client/util.h b/client/util.h
index 22156db9..e492fd49 100644
--- a/client/util.h
+++ b/client/util.h
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <time.h>
+#include <time.h> 
 #include "data.h"    //for FILE_PATH_SIZE
 
 #ifndef ROTR
-- 
2.39.5