[commit: packages/time] format-widths, improve-leapseconds, master, posix-perf, tasty, wip/travis: clean up HsTime (696f384)

git at git.haskell.org git at git.haskell.org
Mon Feb 20 21:12:17 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: format-widths,improve-leapseconds,master,posix-perf,tasty,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/696f384f00c6a33e0114fe30cd3a80e2e93dc3dc

>---------------------------------------------------------------

commit 696f384f00c6a33e0114fe30cd3a80e2e93dc3dc
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Mon Feb 19 18:01:29 2007 -0800

    clean up HsTime
    
    darcs-hash:20070220020129-ac6dd-8b7a4cfbded155623c93ee1b26bafe5f801fd1c6


>---------------------------------------------------------------

696f384f00c6a33e0114fe30cd3a80e2e93dc3dc
 cbits/HsTime.c   | 44 ++++++++++++++++----------------------------
 include/HsTime.h |  2 +-
 2 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/cbits/HsTime.c b/cbits/HsTime.c
index f9651e9..58b7d06 100644
--- a/cbits/HsTime.c
+++ b/cbits/HsTime.c
@@ -3,50 +3,38 @@
 
 long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)
 {
-	struct tm* ptm;
-	long gmtoff;
-	int dst;
-	const char *name;
-
 #if HAVE_LOCALTIME_R
 	struct tm tmd;
-	ptm = localtime_r(&t,&tmd);
+	struct tm* ptm = localtime_r(&t,&tmd);
 #else
-	ptm = localtime(&t);
+	struct tm* ptm = localtime(&t);
 #endif
-	// We don't have a better API to use on Windows, the logic to
-	// decide whether a given data/time falls within DST is
-	// implemented as part of localtime() in the CRT.  This is_dst
-	// flag is all we need here.
-
 	if (ptm)
 	{
-	        dst = ptm -> tm_isdst;
+		int dst = ptm -> tm_isdst;
+		*pdst = dst;
 #if HAVE_TM_ZONE
-		name = ptm -> tm_zone;
-		gmtoff = ptm -> tm_gmtoff;
+		*pname = ptm -> tm_zone;
+		return ptm -> tm_gmtoff;
 #elif defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
-		name = dst ? _tzname[1] : _tzname[0];
-		gmtoff = dst ? _timezone - 3600 : _timezone;
+		// We don't have a better API to use on Windows, the logic to
+		// decide whether a given date/time falls within DST is
+		// implemented as part of localtime() in the CRT.  This is_dst
+		// flag is all we need here.
+		*pname = dst ? _tzname[1] : _tzname[0];
+		return dst ? _timezone - 3600 : _timezone;
 #else
-
 # if HAVE_TZNAME
-		name = *tzname;
+		*pname = *tzname;
 # else
-#  error "Don't know how to get at timezone name on your OS"
+#  error "Don't know how to get timezone name on your OS"
 # endif
-
 # if HAVE_DECL_ALTZONE
-		gmtoff = dst ? altzone : timezone;
+		return dst ? altzone : timezone;
 # else
-		gmtoff = dst ? timezone - 3600 : timezone;
+		return dst ? timezone - 3600 : timezone;
 # endif
-
 #endif // HAVE_TM_ZONE
-	        *pdst  = dst;
-		*pname = name;
-		return gmtoff;
-
 	}
 	else return 0x80000000;
 }
diff --git a/include/HsTime.h b/include/HsTime.h
index b8da946..059cbc0 100644
--- a/include/HsTime.h
+++ b/include/HsTime.h
@@ -7,6 +7,6 @@
 #include <time.h>
 #endif
 
-long int get_current_timezone_seconds (time_t,int* dst,char const* * name);
+long int get_current_timezone_seconds (time_t,int* pdst,char const* * pname);
 
 #endif



More information about the ghc-commits mailing list