/* -----------------------------------------------------------------------------
- * $Id: stgio.h,v 1.20 2000/05/18 11:33:21 panne Exp $
+ * $Id: stgio.h,v 1.21 2000/05/28 17:47:27 panne Exp $
*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
*
char* get_ZONE ( StgAddr );
/* toLocalTime.c */
-StgAddr toLocalTime (StgInt, StgByteArray, StgByteArray);
+StgInt toLocalTime (StgInt, StgByteArray, StgByteArray);
StgInt prim_toLocalTime ( StgInt64,StgByteArray );
/* toUTCTime.c */
-StgAddr toUTCTime (StgInt, StgByteArray, StgByteArray);
+StgInt toUTCTime (StgInt, StgByteArray, StgByteArray);
StgInt prim_toUTCTime ( StgInt64,StgByteArray );
/* toClockSec.c */
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: toLocalTime.c,v 1.4 1999/11/26 16:25:56 simonmar Exp $
+ * $Id: toLocalTime.c,v 1.5 2000/05/28 17:47:27 panne Exp $
*
* toCalendarTime Runtime Support
*/
#include "stgio.h"
#include "timezone.h"
-StgAddr
+StgInt
toLocalTime(I_ size, StgByteArray d, StgByteArray res)
{
- struct tm *tm,*tmp=(struct tm *)res;
time_t t;
+ struct tm *tm,*tmp=(struct tm *)res;
switch(size) {
default:
- return NULL;
+ return 0;
case 0:
t = 0;
break;
case -1:
t = - (time_t) ((StgInt *)d)[0];
if (t > 0)
- return NULL;
+ return 0;
break;
case 1:
t = (time_t) ((StgInt *)d)[0];
if (t < 0)
- return NULL;
+ return 0;
break;
}
tm = localtime(&t);
if (tm == NULL)
- return NULL;
+ return 0;
/*
localtime() may return a ptr to statically allocated storage,
tmp->tm_gmtoff = tm->tm_gmtoff;
#endif
- return (StgAddr)res;
+ return 1;
}
-/* Note that we DO NOT return res as a result.
- * res is typically a MutableByteArray and it seems very dubious
- * to return a pointer into the middle of it.
- */
-StgInt prim_toLocalTime ( StgInt64 d, StgByteArray res)
+StgInt
+prim_toLocalTime(StgInt64 d, StgByteArray res)
{
+ time_t t;
struct tm *tm,*tmp=(struct tm *)res;
- time_t t = (time_t) d;
+ t = (time_t) d;
if (t < 0)
return 0;
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: toUTCTime.c,v 1.4 1999/11/26 16:25:57 simonmar Exp $
+ * $Id: toUTCTime.c,v 1.5 2000/05/28 17:47:27 panne Exp $
*
* toUTCTime Runtime Support
*/
#include "stgio.h"
#include "timezone.h"
-StgAddr
+StgInt
toUTCTime(I_ size, StgByteArray d, StgByteArray res)
{
time_t t;
switch(size) {
default:
- return NULL;
+ return 0;
case 0:
t = 0;
break;
case -1:
t = - (time_t) ((StgInt *)d)[0];
if (t > 0)
- return NULL;
+ return 0;
break;
case 1:
t = (time_t) ((StgInt *)d)[0];
if (t < 0)
- return NULL;
+ return 0;
break;
}
tm = gmtime(&t);
if (tm == NULL)
- return NULL;
+ return 0;
/*
gmtime() may return a ptr to statically allocated storage,
tmp->tm_gmtoff = tm->tm_gmtoff;
#endif
- return (StgAddr)res;
+ return 1;
}
StgInt
t = (time_t) d;
if (t < 0)
- return 0;
+ return 0;
tm = gmtime(&t);