ObjFW  Check-in [bb9a6fb0da]

Overview
Comment:Add -[earlierDate:] and -[laterDate:] to OFDate.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bb9a6fb0daf7116d561b92edb556360df1c448d42a109ebeb270c6536c5fe609
User & Date: js on 2010-12-31 00:30:09
Other Links: manifest | tags
Context
2011-01-01
14:20
Don't include microseconds in -[OFDate description].
This way, it conforms to ISO 8601.
check-in: 65111e7409 user: js tags: trunk
2010-12-31
00:30
Add -[earlierDate:] and -[laterDate:] to OFDate. check-in: bb9a6fb0da user: js tags: trunk
2010-12-29
16:40
Add methods for local time to OFDate. check-in: 172e8f39da user: js tags: trunk
Changes

Modified src/OFDate.h from [7de007fe1b] to [8a0f20777b].

154
155
156
157
158
159
160












161
 *
 * See the manpage for strftime for information on the format.
 *
 * \param fmt The format for the date string
 * \return A new, autoreleased OFString
 */
- (OFString*)localDateStringWithFormat: (OFString*)fmt;












@end







>
>
>
>
>
>
>
>
>
>
>
>

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
 *
 * See the manpage for strftime for information on the format.
 *
 * \param fmt The format for the date string
 * \return A new, autoreleased OFString
 */
- (OFString*)localDateStringWithFormat: (OFString*)fmt;

/**
 * \param date Another date
 * \return The earlier date of the two dates
 */
- (OFDate*)earlierDate: (OFDate*)date;

/**
 * \param date Another date
 * \return The later date of the two dates
 */
- (OFDate*)laterDate: (OFDate*)date;
@end

Modified src/OFDate.m from [992907b8e8] to [4a813140c4].

342
343
344
345
346
347
348
















349
			@throw [OFOutOfRangeException newWithClass: isa];

		return [OFString stringWithCString: buf];
	} @finally {
		[self freeMemory: buf];
	}
}
















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
			@throw [OFOutOfRangeException newWithClass: isa];

		return [OFString stringWithCString: buf];
	} @finally {
		[self freeMemory: buf];
	}
}

- (OFDate*)earlierDate: (OFDate*)date
{
	if ([self compare: date] == OF_ORDERED_DESCENDING)
		return [[date retain] autorelease];

	return [[self retain] autorelease];
}

- (OFDate*)laterDate: (OFDate*)date
{
	if ([self compare: date] == OF_ORDERED_ASCENDING)
		return [[date retain] autorelease];

	return [[self retain] autorelease];
}
@end

Modified tests/OFDateTests.m from [02a5df98fb] to [f6f7311378].

57
58
59
60
61
62
63




64
65
66
67
	TEST(@"-[monthOfYear]", [d1 monthOfYear] == 1 && [d2 monthOfYear] == 1)

	TEST(@"-[year]", [d1 year] == 1970 && [d2 year] == 1970)

	TEST(@"-[dayOfWeek]", [d1 dayOfWeek] == 4 && [d2 dayOfWeek] == 5)

	TEST(@"-[dayOfYear]", [d1 dayOfYear] == 1 && [d2 dayOfYear] == 2)





	[pool drain];
}
@end







>
>
>
>




57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
	TEST(@"-[monthOfYear]", [d1 monthOfYear] == 1 && [d2 monthOfYear] == 1)

	TEST(@"-[year]", [d1 year] == 1970 && [d2 year] == 1970)

	TEST(@"-[dayOfWeek]", [d1 dayOfWeek] == 4 && [d2 dayOfWeek] == 5)

	TEST(@"-[dayOfYear]", [d1 dayOfYear] == 1 && [d2 dayOfYear] == 2)

	TEST(@"-[earlierDate:]", [[d1 earlierDate: d2] isEqual: d1])

	TEST(@"-[laterDate:]", [[d1 laterDate: d2] isEqual: d2])

	[pool drain];
}
@end