#include <assert.h>
#include "Date.h"
#include "Hash.h"
Go to the source code of this file.
◆ _Class
◆ _Date()
Definition at line 222 of file Date.c.
222 {
225
228 .name = "Date",
230 .instanceSize =
sizeof(
Date),
231 .interfaceOffset = offsetof(
Date, interface),
232 .interfaceSize = sizeof(DateInterface),
234 });
235 });
236
237 return clazz;
238}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
static void initialize(Class *clazz)
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
Microsecond-precision immutable dates.
Class * _Object(void)
The Object archetype.
◆ compareTo()
Definition at line 74 of file Date.c.
74 {
75
76 if (other) {
77 const long seconds = self->
time.tv_sec - other->
time.tv_sec;
78 if (seconds == 0) {
79
80 const long microseconds = self->
time.tv_usec - other->
time.tv_usec;
81 if (microseconds == 0) {
83 }
84
86 }
87
89 }
90
92}
◆ date()
static Date * date |
( |
void |
| ) |
|
|
static |
Definition at line 98 of file Date.c.
98 {
99
101}
Date * dateWithTimeSinceNow(const Time interval)
Returns a new Date with the given Time since now.
◆ dateWithTimeSinceNow()
static Date * dateWithTimeSinceNow |
( |
const Time * |
interval | ) |
|
|
static |
Definition at line 107 of file Date.c.
107 {
108
111 if (interval) {
112 date->
time.tv_sec += interval->tv_sec;
113 date->
time.tv_usec += interval->tv_usec;
117 }
else if (
date->
time.tv_usec < 0) {
120 }
121 }
122 }
123
125}
#define alloc(type)
Allocate and initialize and instance of type.
#define MSEC_PER_SEC
Microseconds per second.
Condition * init(Condition *self)
Initializes this Condition.
Date * date(void)
Returns a new Date with the current Time.
◆ hash()
static int hash |
( |
const Object * |
self | ) |
|
|
static |
- See also
- Object::hash(const Object *)
Definition at line 36 of file Date.c.
36 {
37
39
41
44
46}
int HashForInteger(int hash, const long integer)
Accumulates the hash value of integer into hash.
#define HASH_SEED
The hash seed value.
int hash(const Object *self)
◆ init()
Definition at line 131 of file Date.c.
131 {
133}
Date * initWithTime(Date *self, const Time *time)
◆ initialize()
static void initialize |
( |
Class * |
clazz | ) |
|
|
static |
- See also
- Class::initialize(Class *)
Definition at line 203 of file Date.c.
203 {
204
207
216}
ident interface
The interface of the Class.
Time timeSinceTime(const Date *self, const Time *time)
Time timeSinceNow(const Date *self)
Order compareTo(const Date *self, const Date *other)
Compares this Date to another.
Time timeSinceDate(const Date *self, const Date *date)
_Bool isEqual(const Object *self, const Object *other)
Tests equality of the other Object.
◆ initWithTime()
static Date * initWithTime |
( |
Date * |
self, |
|
|
const Time * |
time |
|
) |
| |
|
static |
Definition at line 139 of file Date.c.
139 {
140
142 if (self) {
143 if (time) {
145 } else {
146 gettimeofday(&self->
time, NULL);
147 }
148 }
149
150 return self;
151}
#define super(type, obj, method,...)
Object is the root Class of The Objectively Class hierarchy.
◆ isEqual()
static _Bool isEqual |
( |
const Object * |
self, |
|
|
const Object * |
other |
|
) |
| |
|
static |
- See also
- Object::isEqual(const Object *, const Object *)
Definition at line 51 of file Date.c.
51 {
52
54 return true;
55 }
56
58
61
63 }
64
65 return false;
66}
Class * _Date(void)
The Date archetype.
_Bool isKindOfClass(const Object *self, const Class *clazz)
Tests for Class hierarchy membership.
◆ timeSinceDate()
static Time timeSinceDate |
( |
const Date * |
self, |
|
|
const Date * |
date |
|
) |
| |
|
static |
◆ timeSinceNow()
static Time timeSinceNow |
( |
const Date * |
self | ) |
|
|
static |
Definition at line 168 of file Date.c.
168 {
169
171
173
175
176 return time;
177}
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
struct timeval Time
Time (seconds and microseconds).
◆ timeSinceTime()
static Time timeSinceTime |
( |
const Date * |
self, |
|
|
const Time * |
time |
|
) |
| |
|
static |
Definition at line 183 of file Date.c.
183 {
184
186 .tv_sec = self->
time.tv_sec - time->tv_sec,
187 .tv_usec = self->
time.tv_usec - time->tv_usec
188 };
189
190 if (delta.tv_usec < 0) {
191 delta.tv_sec--;
193 }
194
195 return delta;
196}