diff options
Diffstat (limited to 'ghc/runtime/io/toUTCTime.lc')
-rw-r--r-- | ghc/runtime/io/toUTCTime.lc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ghc/runtime/io/toUTCTime.lc b/ghc/runtime/io/toUTCTime.lc new file mode 100644 index 0000000000..1442993ea0 --- /dev/null +++ b/ghc/runtime/io/toUTCTime.lc @@ -0,0 +1,47 @@ +% +% (c) The GRASP/AQUA Project, Glasgow University, 1995 +% +\subsection[toUTCTime.lc]{toUTCTime Runtime Support} + +\begin{code} + +#include "rtsdefs.h" +#include "stgio.h" +#include "timezone.h" + +StgAddr +toUTCTime(size, d) +StgInt size; +StgByteArray d; +{ + time_t t; + struct tm *tm; + static struct tm cache_tm; + + switch(size) { + default: + return NULL; + case 0: + t = 0; + break; + case -1: + t = - (time_t) ((StgInt *)d)[0]; + if (t > 0) + return NULL; + break; + case 1: + t = (time_t) ((StgInt *)d)[0]; + if (t < 0) + return NULL; + break; + } + tm = gmtime(&t); + + if (tm == NULL) + return NULL; + + cache_tm = *tm; + return &cache_tm; +} + +\end{code} |