1
// Copyright 2011 Google Inc.
2
// Copyright 2011 Conrad Steenberg <conrad.steenberg@gmail.com>
4
// This Source Code Form is subject to the terms of the Mozilla Public
5
// License, v. 2.0. If a copy of the MPL was not distributed with this
6
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
24
17
return (InternalDate *)calloc(1, sizeof(InternalDate));
20
int64_t crk_getSeconds(InternalDate *d) {
21
// have to wrap this to correctly convert from time_t to int64.
27
25
InternalDate *crk_localtime(InternalDate *d, int64_t t){
28
26
const time_t lt = (const time_t)t;
29
27
return localtime_r(<, d);
90
88
crack::ext::Type *type_bool = mod->getBoolType();
91
89
crack::ext::Type *type_byteptr = mod->getByteptrType();
92
90
crack::ext::Type *type_byte = mod->getByteType();
91
crack::ext::Type *type_int16 = mod->getInt16Type();
93
92
crack::ext::Type *type_int32 = mod->getInt32Type();
94
93
crack::ext::Type *type_int64 = mod->getInt64Type();
94
crack::ext::Type *type_uint16 = mod->getUint16Type();
95
95
crack::ext::Type *type_uint32 = mod->getUint32Type();
96
96
crack::ext::Type *type_uint64 = mod->getUint64Type();
97
97
crack::ext::Type *type_int = mod->getIntType();
126
126
type_InternalDate->addInstVar(type_byteptr, "tm_zone",
127
127
CRACK_OFFSET(InternalDate, tm_zone));
128
128
f = type_InternalDate->addConstructor("init",
129
(void *)crk_create_date
132
f = type_InternalDate->addMethod(type_int64, "getSeconds",
136
f = type_InternalDate->addMethod(type_void, "setLocalSeconds",
137
(void *)crk_localtime
139
f->addArg(type_int64, "t");
141
f = type_InternalDate->addMethod(type_void, "setLocalNow",
142
(void *)crk_localtime_now
145
f = type_InternalDate->addMethod(type_void, "setUTCSeconds",
148
f->addArg(type_int64, "t");
150
f = type_InternalDate->addMethod(type_void, "setUTCNow",
151
(void *)crk_gmtime_now
154
f = type_InternalDate->addMethod(type_void, "setEpoch",
158
f = type_InternalDate->addMethod(type_void, "_toBufferRaw",
161
f->addArg(type_byteptr, "buf");
129
(void *)crk_create_date
133
f = type_InternalDate->addMethod(
136
(void *)crk_getSeconds
140
f = type_InternalDate->addMethod(
143
(void *)crk_localtime
145
f->addArg(type_int64,
150
f = type_InternalDate->addMethod(
153
(void *)crk_localtime_now
157
f = type_InternalDate->addMethod(
162
f->addArg(type_int64,
167
f = type_InternalDate->addMethod(
170
(void *)crk_gmtime_now
174
f = type_InternalDate->addMethod(
181
f = type_InternalDate->addMethod(
186
f->addArg(type_byteptr,
163
190
type_InternalDate->finish();