ObjFW  Diff

Differences From Artifact [f357555e03]:

To Artifact [8e1ed139e9]:


159
160
161
162
163
164
165
166

167
168
169
170
171
172

173
174
175
176
177
178
179
159
160
161
162
163
164
165

166
167
168
169
170
171

172
173
174
175
176
177
178
179







-
+





-
+







#endif

+ (instancetype)date
{
	return [[[self alloc] init] autorelease];
}

+ (instancetype)dateWithTimeIntervalSince1970: (double)seconds
+ (instancetype)dateWithTimeIntervalSince1970: (of_time_interval_t)seconds
{
	return [[[self alloc]
	    initWithTimeIntervalSince1970: seconds] autorelease];
}

+ (instancetype)dateWithTimeIntervalSinceNow: (double)seconds
+ (instancetype)dateWithTimeIntervalSinceNow: (of_time_interval_t)seconds
{
	return [[[self alloc]
	    initWithTimeIntervalSinceNow: seconds] autorelease];
}

+ (instancetype)dateWithDateString: (OFString*)string
			    format: (OFString*)format
206
207
208
209
210
211
212
213

214
215
216
217
218

219
220
221
222
223
224
225
226
227

228
229
230
231
232
233
234
206
207
208
209
210
211
212

213
214
215
216
217

218
219
220
221
222
223
224
225
226

227
228
229
230
231
232
233
234







-
+




-
+








-
+







	struct timeval t;

	self = [super init];

	OF_ENSURE(gettimeofday(&t, NULL) == 0);

	_seconds = t.tv_sec;
	_seconds += (double)t.tv_usec / 1000000;
	_seconds += (of_time_interval_t)t.tv_usec / 1000000;

	return self;
}

- initWithTimeIntervalSince1970: (double)seconds
- initWithTimeIntervalSince1970: (of_time_interval_t)seconds
{
	self = [super init];

	_seconds = seconds;

	return self;
}

- initWithTimeIntervalSinceNow: (double)seconds
- initWithTimeIntervalSinceNow: (of_time_interval_t)seconds
{
	self = [self init];

	_seconds += seconds;

	return self;
}
604
605
606
607
608
609
610
611

612
613
614
615
616

617
618
619
620
621

622
623
624

625
626
627
628
629

630
631
632
633
634

635
636
637
638
604
605
606
607
608
609
610

611
612
613
614
615

616
617
618
619
620

621
622
623

624
625
626
627
628

629
630
631
632
633

634
635
636
637
638







-
+




-
+




-
+


-
+




-
+




-
+





	if ([self compare: otherDate] == OF_ORDERED_ASCENDING)
		return [[otherDate retain] autorelease];

	return [[self retain] autorelease];
}

- (double)timeIntervalSince1970
- (of_time_interval_t)timeIntervalSince1970
{
	return _seconds;
}

- (double)timeIntervalSinceDate: (OFDate*)otherDate
- (of_time_interval_t)timeIntervalSinceDate: (OFDate*)otherDate
{
	return _seconds - otherDate->_seconds;
}

- (double)timeIntervalSinceNow
- (of_time_interval_t)timeIntervalSinceNow
{
	struct timeval t;
	double seconds;
	of_time_interval_t seconds;

	OF_ENSURE(!gettimeofday(&t, NULL));

	seconds = t.tv_sec;
	seconds += (double)t.tv_usec / 1000000;
	seconds += (of_time_interval_t)t.tv_usec / 1000000;

	return _seconds - seconds;
}

- (OFDate*)dateByAddingTimeInterval: (double)seconds
- (OFDate*)dateByAddingTimeInterval: (of_time_interval_t)seconds
{
	return [OFDate dateWithTimeIntervalSince1970: _seconds + seconds];
}
@end