File: Date.c

package info (click to toggle)
mlton 20061107-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,828 kB
  • ctags: 61,118
  • sloc: ansic: 11,446; makefile: 1,339; sh: 1,160; lisp: 900; pascal: 256; asm: 97
file content (108 lines) | stat: -rw-r--r-- 1,778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "platform.h"

#ifndef DEBUG
#define DEBUG FALSE
#endif

static struct tm tm;
static struct tm *tmp;

Int Date_Tm_sec() {
        return tmp->tm_sec;
}

Int Date_Tm_min() {
        return tmp->tm_min;
}

Int Date_Tm_hour() {
        return tmp->tm_hour;
}

Int Date_Tm_mday() {
        return tmp->tm_mday;
}

Int Date_Tm_mon() {
        return tmp->tm_mon;
}

Int Date_Tm_year() {
        return tmp->tm_year;
}

Int Date_Tm_wday() {
        return tmp->tm_wday;
}

Int Date_Tm_yday() {
        return tmp->tm_yday;
}

Int Date_Tm_isdst() {
        return tmp->tm_isdst;
}

void Date_Tm_setSec(Int x) {
        tm.tm_sec = x;
}

void Date_Tm_setMin(Int x) {
        tm.tm_min = x;
}

void Date_Tm_setHour(Int x) {
        tm.tm_hour = x;
}

void Date_Tm_setMday(Int x) {
        tm.tm_mday = x;
}

void Date_Tm_setMon(Int x) {
        tm.tm_mon = x;
}

void Date_Tm_setYear(Int x) {
        tm.tm_year = x;
}

void Date_Tm_setWday(Int x) {
        tm.tm_wday = x;
}

void Date_Tm_setYday(Int x) {
        tm.tm_yday = x;
}

void Date_Tm_setIsdst(Int x) {
        tm.tm_isdst = x;
}

void Date_gmTime(Pointer p) {
        tmp = gmtime((time_t*)p);
}

/* The idea for Date_localOffset comes from KitV3 src/Runtime/Time.c */
Int Date_localOffset() {
        time_t t1, t2;

        t1 = time(NULL);
        t2 = mktime(gmtime(&t1));
        return difftime(t2, t1);
}

void Date_localTime(Pointer p) {
        tmp = localtime((time_t*)p);
        if (DEBUG)
                fprintf (stderr, "0x%08x = Date_localTime (0x%08x)\n", 
                                (unsigned int)tmp, (unsigned int)p);
}

Int Date_mkTime() {
        return mktime(&tm);
}

Int Date_strfTime(Pointer buf, Int n, NullString fmt) {
        return strftime((char*)(buf), n, (char*)(fmt), &tm);
}