boredzo / iso-8601-date-formatter

A Cocoa NSFormatter subclass to convert dates to and from ISO-8601-formatted strings. Supports calendar, week, and ordinal formats.
http://boredzo.org/iso8601dateformatter/
Other
600 stars 140 forks source link

Refactor and Modernize ISO8601DateFormatter #21

Open blakewatters opened 11 years ago

blakewatters commented 11 years ago

Hi Peter -

Thanks so much for your most excellent contribution of ISO8601DateFormatter to the Cocoa Open Source community. It definitely has to be one of the most widely used libraries floating around.

Several years ago I integrated the library into RestKit/RestKit and have been maintaining a forked version of the library ever since. We have made a number of incremental improvements to the package. We are currently in the process of atomizing some parts of RestKit into smaller more modular libraries and one of the sticking points at the moment is the dependence on the forked copy of the date formatter.

This has put me in the position of either a) shipping a standalone competing implementation of the date formatter or b) trying to integrate our changes back into the mainline so that there is one authoritative code base out there. I'd prefer to go the latter route and wanted to reach out and gauge your enthusiasm for larger changes to the library.

I'd like to do the following:

Let me know if this is of interest to you and you'd be willing to merge such changes. I am also happy to help you with on-going maintenance of the library.

boredzo commented 11 years ago

Most other refactoring is blocked (AFAIC) on having much more test coverage in the modern tests.

boredzo commented 11 years ago

As I look at how I'll eventually refactor the parser, I'm starting to think that some sort of parsing operation object might be a good idea. It won't help with concurrency, but breaking the Single Giant Method into multiple methods will help with readability and redundancy.

boredzo commented 11 years ago

Setup of the parser might look something like this:

@synchronized(self) {
    ISO8601Parser *parser = [[ISO8601Parser alloc] initWithCalendar:… /*and whatever else it'll need*/];
    //Possibly more setup here
}
NSDateComponents *components = [parser parseString:string timeZone:&timeZone range:&range fractionOfSecond:&fractionOfSecond];

If that's enough (this would need to be VERY thoroughly tested), maybe this will help with concurrency after all.

At any rate, all such rewrites remain on hold until the test coverage of ISO8601DateFormatter.m gets sufficiently close to 100% and all old tests are ported and deleted—see #23. I at least want the coverage indicator on Coveralls to turn green.

blakewatters commented 11 years ago

Cool I will jump back in on this shortly. I have an ARC'ified and patched version of the date formatter that was in RestKit that is now spun out into an external project (see https://github.com/blakewatters/ISO8601DateFormatterValueTransformer/tree/master/Code). I'll need to review the history of my changes and get a pull request over so I can drop the fork.

I have some test cases and regular expression work that can also be brought upstream. I'll try and carve out some time this weekend to get these bits brought over.

boredzo commented 8 years ago

1.0 is going to be the “modernize all the things” release—more specifically, it's going to be exactly equivalent to 0.9, but less compatible.

66 is another subtask of this.

boredzo commented 8 years ago

Also includes #69 (and I'm going to start using a label for all these subtasks).