2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: toUTCTime.c,v 1.4 1999/11/26 16:25:57 simonmar Exp $
6 * toUTCTime Runtime Support
14 toUTCTime(I_ size, StgByteArray d, StgByteArray res)
17 struct tm *tm,*tmp=(struct tm *)res;
26 t = - (time_t) ((StgInt *)d)[0];
31 t = (time_t) ((StgInt *)d)[0];
42 gmtime() may return a ptr to statically allocated storage,
43 so to make toUTCTime reentrant, we manually copy
44 the structure into the (struct tm *) passed in.
46 tmp->tm_sec = tm->tm_sec;
47 tmp->tm_min = tm->tm_min;
48 tmp->tm_hour = tm->tm_hour;
49 tmp->tm_mday = tm->tm_mday;
50 tmp->tm_mon = tm->tm_mon;
51 tmp->tm_year = tm->tm_year;
52 tmp->tm_wday = tm->tm_wday;
53 tmp->tm_yday = tm->tm_yday;
54 tmp->tm_isdst = tm->tm_isdst;
56 If you don't have tm_zone in (struct tm), but
57 you get at it via the shared tmzone[], you'll
58 lose. Same goes for the tm_gmtoff field.
62 strcpy(tmp->tm_zone,tm->tm_zone);
63 tmp->tm_gmtoff = tm->tm_gmtoff;
70 prim_toUTCTime(StgInt64 d, StgByteArray res)
73 struct tm *tm,*tmp=(struct tm *)res;
85 gmtime() may return a ptr to statically allocated storage,
86 so to make toUTCTime reentrant, we manually copy
87 the structure into the (struct tm *) passed in.
89 tmp->tm_sec = tm->tm_sec;
90 tmp->tm_min = tm->tm_min;
91 tmp->tm_hour = tm->tm_hour;
92 tmp->tm_mday = tm->tm_mday;
93 tmp->tm_mon = tm->tm_mon;
94 tmp->tm_year = tm->tm_year;
95 tmp->tm_wday = tm->tm_wday;
96 tmp->tm_yday = tm->tm_yday;
97 tmp->tm_isdst = tm->tm_isdst;
99 If you don't have tm_zone in (struct tm), but
100 you get at it via the shared tmzone[], you'll
101 lose. Same goes for the tm_gmtoff field.
105 strcpy(tmp->tm_zone,tm->tm_zone);
106 tmp->tm_gmtoff = tm->tm_gmtoff;