Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various fixes to make this build & work on Windows
A number of things didn't work on Windows: we were using gettimeofday() which doesn't exist, localtime_r() doesn't exist, the tm_zone field in struct tm doesn't exist, etc. * timestuff.{c,h} is now cbits/HsTime.c and includes/HsTime.h, for consistency with other packages * There's a configure script. Hence, a default Setup.hs will be required for using Cabal (I haven't added this yet, I think we were going to make some more changes in Cabal to make it optional). * fixed various problems in package.conf.in. I haven't tested time.cabal, I expect it doesn't work on Windows, but it might still work on Unix. * We get the current time from the native Win32 API. This requires the Win32 library, hence a conditional dependency on Win32. * some cursory testing on Win32, we can get the local time and the timezone looks ok. darcs-hash:20060529122523-760e2-1707aeb6dcf612f6c7c134b1eab52c1187a8305f
- Loading branch information
Simon Marlow
committed
May 29, 2006
1 parent
e5ea873
commit 4b425ec
Showing
12 changed files
with
158 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# FP_DECL_ALTZONE | ||
# --------------- | ||
# Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise. | ||
# | ||
# Used by base package. | ||
AC_DEFUN([FP_DECL_ALTZONE], | ||
[AC_REQUIRE([AC_HEADER_TIME])dnl | ||
AC_CHECK_HEADERS([sys/time.h]) | ||
AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME | ||
# include <sys/time.h> | ||
# include <time.h> | ||
#else | ||
# if HAVE_SYS_TIME_H | ||
# include <sys/time.h> | ||
# else | ||
# include <time.h> | ||
# endif | ||
#endif]) | ||
])# FP_DECL_ALTZONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "HsTime.h" | ||
#include <stdio.h> | ||
|
||
long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname) | ||
{ | ||
struct tm* ptm; | ||
long gmtoff; | ||
int dst; | ||
char *name; | ||
|
||
#if HAVE_LOCALTIME_R | ||
struct tm tmd; | ||
ptm = localtime_r(&t,&tmd); | ||
#else | ||
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; | ||
#if HAVE_TM_ZONE | ||
name = ptm -> tm_zone; | ||
gmtoff = ptm -> tm_gmtoff; | ||
#else | ||
|
||
# if mingw32_HOST_OS | ||
name = dst ? _tzname[1] : _tzname[0]; | ||
printf("dst: %d, tzname0: %s, tzname1: %s\n", dst, _tzname[0], _tzname[1]); | ||
# elif HAVE_TZNAME | ||
name = *tzname; | ||
# else | ||
# error "Don't know how to get at timezone name on your OS" | ||
# endif | ||
|
||
# if mingw32_HOST_OS | ||
gmtoff = dst ? _timezone - 3600 : _timezone; | ||
# elif HAVE_DECL_ALTZONE | ||
gmtoff = dst ? altzone : timezone; | ||
# else | ||
gmtoff = dst ? timezone - 3600 : timezone; | ||
# endif | ||
|
||
#endif // HAVE_TM_ZONE | ||
*pdst = dst; | ||
*pname = name; | ||
return gmtoff; | ||
|
||
} | ||
else return 0x80000000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
AC_INIT([Haskell time package], [0.3.1], [ashley@semantic.org], [time]) | ||
|
||
# Safety check: Ensure that we are in the correct source directory. | ||
AC_CONFIG_SRCDIR([include/HsTime.h]) | ||
|
||
AC_CONFIG_HEADERS([include/HsTimeConfig.h]) | ||
|
||
AC_CHECK_FUNCS([gmtime_r localtime_r]) | ||
|
||
AC_STRUCT_TM | ||
AC_STRUCT_TIMEZONE | ||
|
||
FP_DECL_ALTZONE | ||
|
||
AC_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __HSTIME_H__ | ||
#define __HSTIME_H__ | ||
|
||
#include "ghcconfig.h" | ||
#include "HsTimeConfig.h" | ||
|
||
#if HAVE_TIME_H | ||
#include <time.h> | ||
#endif | ||
|
||
long int get_current_timezone_seconds (time_t,int* dst,char const* * name); | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.