ObjFW  Check-in [f5c8495a33]

Overview
Comment:Fix leap year calculation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f5c8495a338108e1c959cb938ce42655aa4c27cd904390b90c5e6ebbb60f87a5
User & Date: js on 2011-10-28 22:03:50
Other Links: manifest | tags
Context
2011-10-29
00:00
Make the parameter for +[stringWith{Unicode,UTF16}String:] const. check-in: 49cf155269 user: js tags: trunk
2011-10-28
22:03
Fix leap year calculation. check-in: f5c8495a33 user: js tags: trunk
21:30
Parse struct tm ourselves. check-in: 4fc7884fb1 user: js tags: trunk
Changes

Modified src/OFDate.m from [396325df1e] to [11883eeeee].

252
253
254
255
256
257
258
259

260
261



262
263
264
265
266
267
268
252
253
254
255
256
257
258

259
260

261
262
263
264
265
266
267
268
269
270







-
+

-
+
+
+







#ifdef STRUCT_TM_HAS_TM_GMTOFF
		if (tm.tm_gmtoff != 0)
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];
#endif

		/* Years */
		seconds = (tm.tm_year - 70) * 31536000;
		seconds = (time_t)(tm.tm_year - 70) * 31536000;
		/* Leap years */
		seconds += ((tm.tm_year / 4) - 17) * 86400;
		seconds += (((tm.tm_year + 1900) / 4) - 492) * 86400;
		seconds -= (((tm.tm_year + 1900) / 100) - 19) * 86400;
		seconds += (((tm.tm_year + 1900) / 400) - 4) * 86400;
		/* Months */
		if (tm.tm_mon < 0 || tm.tm_mon > 12)
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];
		seconds += month_to_day_of_year[tm.tm_mon - 1] * 86400;
		/* Days */
		seconds += (tm.tm_mday - 1) * 86400;