Source

ISO 8601 parser/unparser / ISO8601DateFormatter.m

Author Commit Message Labels Comments Date
Peter Hosey
This should be an NSInteger, not an NSTimeInterval. Thanks to Rudy Richter for bringing this to my attention.
Comments 2
Peter Hosey
Added a method to drop the cache if you get a memory warning.
Peter Hosey
Cache time zones by offset. Gets another speed-up of about 1.5×, and makes this now faster than C stdlib.
Peter Hosey
Two calendars are better than one. Previous 5× speed-up required assistance from the test program (setting the default output time zone to the time zone returned from an initial parse). Now it's official: ISO8601DateFormatter gets its 5× speed-up from calendar-caching without assistance from the test app.
Peter Hosey
Oh yeah. Let's not leak the calendar while we're at it.
Peter Hosey
Another 5× speed-up: Create and always use a single calendar per date formatter, instead of creating them and throwing them away, and make sure it always has our default time zone.
Peter Hosey
Made this almost ten times as fast by holding onto the date formatter we use for unparsing.
Peter Hosey
Change the minutes over to use precision the same as the hour does, for consistency with the hours. References #4.
Peter Hosey
Fixed #4 by amending the time string format to use a different method of zero-padding that is compatible, in Apple's implementation, with the + flag.
Peter Hosey
Fix implicit-cast warnings by using the correct formatter and explicitly casting to its type. Sparks submitted a patch for this, but it approached this differently, by explicitly casting to unsigned int and leaving the formatters as they were. This change solves the problem the compiler was warning about, which was the risk of truncating numbers that are out of unsigned int range.
Peter Hosey
Initialize more variables, fixing some warnings. Thanks to Sparks for this patch.
Peter Hosey
Fixed a couple of 64-to-32 warnings that occurred when building for i386.
Peter Hosey
Fix all warnings.
Peter Hosey
Pass a date, not the ISO 8601 date formatter (oops), to the time formatter.
Peter Hosey
When not parsing strictly, allow a space before the time-zone specification, as expected by NSDate's +dateWithString: and -initWithString: methods and emitted by its -description method.
wildwobby
Variable set, but never read, and is set to something else a few lines down
Peter Hosey
Fix week dates for certain weekdays. One of these subtractions gave a negative result for certain weekdays, and since all of these variables were unsigned, that change to the interpretation of the result threw a comparison out of whack. The fix is simply to make all of these signed integers.
Peter Hosey
Massive rewrite. The parser and unparser are now together in a single NSFormatter subclass, and are now based on NSCalendar and NSDateComponents instead of NSCalendarDate. The parser remains more or less unchanged. Two-thirds of the unparser is now based on NSDateFormatter, which handles that portion of ISO 8601 string-formatting more or less for free; the part not handled for free is week dates (because NSCalendar has a different idea of when the week starts), and that unparser also remains more or less unchanged.