Re: dateFromString won't accept this string:
Re: dateFromString won't accept this string:
- Subject: Re: dateFromString won't accept this string:
- From: Alex Hall <email@hidden>
- Date: Mon, 23 Nov 2015 00:12:42 -0500
> On Nov 22, 2015, at 6:04 PM, Alex Hall <email@hidden> wrote:
>
>
>> On Nov 22, 2015, at 5:06 PM, Jerry Krinock <email@hidden> wrote:
>>
>>
>>> On 2015 Nov 22, at 13:12, Alex Hall <email@hidden> wrote:
>>>
>>> Is there something else I have to do, like tell the formatter what order to expect components to be in?
>>
>> Yes, and more. You must set the dateFormat property of your date formatter exactly.
>>
>> Documentation of property ‘dateFormat’ refers you to click on the “Date Formatting Guide”. From there, you click on “Date Formatters”. Once there, scroll down to "Use Format Strings to Specify Custom Formats” and what to your wondering eyes does appear but a list of links to Unicode Consortium standards. Click on the one for the OS version you are targetting. Once there, read the fine print carefully. After 20 minutes or so you should have it working :)
>
> Thanks! I thought, for some reason, that NSDateFormatters could figure out the date from any string with the necessary information—I guess I was thinking of AppleScript.
>
> One follow-up, as I’m looking at all this: is there a reason to use setDateFormat over templates? The header for NSDateFormatter keeps talking about template strings, but online, all I see is setDateFormat(“some formatted string”). I haven’t dug deeply into this yet, so feel free to ignore this question if it’s quite obvious. I thought I’d ask while I was responding, before I go back to the docs. Thanks.
Update: it seems to work. I ended up going with something like:
//"Sun Nov 22 21:00:39 +0000 2015"
self.tweetDateToStringDateFormatter.dateFormat = "EEE MMM dd HH:mm:ss ZZZ yyyy"
and I get a date that appears correct. I'd still be curious to know about templates, but this works so I won't spend time on it right now. Off to figure more about table cells. I think this means a bit more with bindings… *shudder*
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> 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:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden