There is some ISO spec for date formatting that Apple’s docs mention IIRC.
Let me sniff around. http://www.w3.org/TR/NOTE-datetime Also, from Apple’s docs: “ The format string uses the format patterns from the Unicode Technical Standard #35” Don’t go there. It will hurt you. I’ve added a great reference link later on. From what I remember, it’s pretty important to pay attention to the ZZZZ character for certain types of time/date formatting and it isn’t easy to discover unless you dig pretty deep into the docs. In any case, I tossed Alex Hall a bunch of samples. What I had considered this morning was to come up with a few formatting approaches and just fail through the ones that return bogus values until you get a positive response. Didn’t have time to dig into it though. FYI, here are a few of the formatting strings that I’ve used that worked well for me. // Notice the use of 3 or 4 Zs in the formatter. It matters with respect to hours from GMT. @"yyyy-MM-ddHH:mm:ssZZZ” @"yyyy-MM-dd’T'HH:mm:ssZZZZ” For Alex Hall’s date string, it looks like he’s got to add the date offset from GMT and a few space characters into the formatter. That’s what the ZZZZ stands for. Should be pretty easy, once you see what each of the letters in the formatter represent. Here’s a pretty good (really really good) reference: http://waracle.net/iphone-nsdateformatter-date-formatting-table/ Cheers, Alex Zavatone On Nov 23, 2015, at 4:32 PM, Sandor Szatmari <admin.szatmari....@gmail.com> wrote: > Alex, > > What spec are you referring to? Link? I was playing around with > NSDataDetector for pulling dates out of strings in XML dumps of excel files > for an internal tool I was writing. NSDataDetectors seemed powerful, but > failed when the dates weren't totally well formed (Tested on 10.8.5, SDK > 10.8); the dates were still totally recognizable by humans, just missing some > whitespace here or there. It did handle differently formatted dates very > well though. I ended up using regular expressions to 'parse' the dates as > there was just one format I was dealing with and the issue was just the > missing whitespace. Maybe I didn't know how to configure it to be more > flexible or tolerant of the format deviations? > > Sandor > > On Nov 23, 2015, at 9:33 AM, Alex Zavatone <z...@mac.com> wrote: > >> Have you looked into The spec for date formatting? >> >> It is seriously helpful. It's some ISO document. >> >> Specify the format at which the date is coming in and it should convert. >> >> I will send you my crappy routines for this for iOS. >> >> Sent from my iPhone >> >>> On Nov 23, 2015, at 9:06 AM, Alex Hall <mehg...@icloud.com> wrote: >>> >>> >>>> On Nov 23, 2015, at 8:00 AM, Sandor Szatmari >>>> <admin.szatmari....@gmail.com> wrote: >>>> >>>> Alex, >>>> >>>> Have you tried looking at NSDataDetector. >>>> http://nshipster.com/nsdatadetector/ <http://nshipster.com/nsdatadetector/> >>> Thanks for the suggestion. I don't think that would apply here, though; I >>> have some JSON data that includes a date as a string. I need to convert >>> that to an NSDate object so I can then display it however the user wants, >>> or compare it to now, and such. However, that's a really useful page (I >>> love NSHipster) and I'll save it for another project I'm thinking about >>> where data detectors will be useful. >>>> >>>> Sandor >>>> >>>>> On Nov 22, 2015, at 16:12, Alex Hall <mehg...@icloud.com >>>>> <mailto:mehg...@icloud.com>> wrote: >>>>> >>>>> Hey list, >>>>> I’m using NSDateFormatter.dateFromString() to make a date from the date >>>>> string in a tweet. However, it seems to be returning nil, and I’m not >>>>> sure why. Is there something else I have to do, like tell the formatter >>>>> what order to expect components to be in? The string is something like: >>>>> >>>>> "Sun Nov 22 21:00:39 +0000 2015” >>>>> >>>>> Thanks for any suggestions anyone has. >>>>> _______________________________________________ >>>>> >>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com >>>>> <mailto:Cocoa-dev@lists.apple.com>) >>>>> >>>>> Please do not post admin requests or moderator comments to the list. >>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>>>> <http://lists.apple.com/> >>>>> >>>>> Help/Unsubscribe/Update your Subscription: >>>>> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com >>>>> >>>>> <https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com> >>>>> >>>>> This email sent to admin.szatmari....@gmail.com >>>>> <mailto:admin.szatmari....@gmail.com> >>> _______________________________________________ >>> >>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>> >>> Please do not post admin requests or moderator comments to the list. >>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>> >>> Help/Unsubscribe/Update your Subscription: >>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com >>> >>> This email sent to z...@mac.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com