Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/runtime/c-libs/smlnj-date/gmtime.c
ViewVC logotype

Annotation of /sml/trunk/src/runtime/c-libs/smlnj-date/gmtime.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download) (as text)

1 : monnier 249 /* gmtime.c
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     */
5 :    
6 :     #include <time.h>
7 :     #include "ml-base.h"
8 :     #include "ml-objects.h"
9 :     #include "cfun-proto-list.h"
10 :    
11 :     /* _ml_Date_gmtime : Int32.int -> (int * int * int * int * int * int * int * int * int)
12 :     *
13 :     * Takes a UTC time value (in seconds), and converts it to a 9-tuple with
14 :     * the fields: tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday,
15 :     * tm_yday, and tm_isdst.
16 :     */
17 :     ml_val_t _ml_Date_gmtime (ml_state_t *msp, ml_val_t arg)
18 :     {
19 :     time_t t = (time_t)INT32_MLtoC(arg);
20 :     struct tm *tm;
21 :    
22 :     tm = gmtime (&t);
23 :    
24 :     ML_AllocWrite(msp, 0, MAKE_DESC(DTAG_record, 9));
25 :     ML_AllocWrite(msp, 1, INT_CtoML(tm->tm_sec));
26 :     ML_AllocWrite(msp, 2, INT_CtoML(tm->tm_min));
27 :     ML_AllocWrite(msp, 3, INT_CtoML(tm->tm_hour));
28 :     ML_AllocWrite(msp, 4, INT_CtoML(tm->tm_mday));
29 :     ML_AllocWrite(msp, 5, INT_CtoML(tm->tm_mon));
30 :     ML_AllocWrite(msp, 6, INT_CtoML(tm->tm_year));
31 :     ML_AllocWrite(msp, 7, INT_CtoML(tm->tm_wday));
32 :     ML_AllocWrite(msp, 8, INT_CtoML(tm->tm_yday));
33 :     ML_AllocWrite(msp, 9, INT_CtoML(tm->tm_isdst));
34 :    
35 :     return ML_Alloc(msp, 9);
36 :    
37 :     } /* end of _ml_Date_gmtime */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0