Re: Date pickers
Re: Date pickers
- Subject: Re: Date pickers
- From: Deivy Petrescu <email@hidden>
- Date: Tue, 09 Feb 2010 15:38:24 -0500
On 09/02/2010, at 12:21 , Robert DuToit wrote:
>
> On Feb 9, 2010, at 9:17 AM, Deivy Petrescu wrote:
>
>>
>> On 09/02/2010, at 08:54 , Robert DuToit wrote:
>>
>>> Pretty cool.
>>>
>>> So a quick AS date to ASOC date would be:
>>>
>>> set theNSdate to current application's class "NSDate"'s |date|()
>>>
>>> set myFormatter to current application's class "NSDateFormatter"'s alloc()'s init()
>>> myFormatter's setDateFormat_("yyyy-MM-dd H:m:s")
>>> set theDateString to (myFormatter's stringFromDate_(theNSdate))
>>>
>>> do shell script "echo " & quoted form of (theDateString as text) & "| xxd -u -p"
>>> set theDate to (run script "get «data isot" & (text 1 thru -3 of the result) & "»") as date
>>> log (theDate as string)
>>>
>>> However I suppose this is not international proof. But still nice.
>>>
>>> Rob _______________________________________________
>>
>>
>> Rob,
>> I think it is locale dependent.
>> When you write "as date" I think it returns the value according to your specific settings.
>>
>> Thanks to you guys, I had a nice lesson.
>>
>> I am not going to use this now, but as a matter of curiosity I tried to set the DatePicker to a certain date.
>> I could not do it. May be it should be formatted or something, but all calls seem to return an error.
>>
>> Ahh! Rob, when you used "stringFromDate" you used "stringFromDate_" how did you know to add the underscore?
>> I did not see anything about it.
>
> You replace the colons in OBJc methods with an underscore in ASOC methods.
>
> so
>
> NSString *formattedDateString = [dateFormatter stringFromDate:someDate];
>
> becomes
>
> set formattedDateString to dateFormatter's stringFromDate_(someDate)
>
>
>>
>> Sorry being a pest, but I am beginning to expand my views of programming to include a decent UI.
>
> I'm new to all this myself so no problem.
>
>>
>> Thanks very much!
>
> Sure.
>
> Rob
>
Again, I want to thank you all for your help.
It is good to bang the head against the wall to learn, but, the headache my be a big pain... :)
So, your help minimized my headache.
As Shane said, it is different than AS. Living and learning.
The biggest difficulty is how to travel between AS and Cocoa.
so I read a cocoa book and I understand what goes on, but how to make it compatible with AS.
That is when you guys came and lend me a big hand.
Also, thanks to
<http://macscripter.net/viewtopic.php?pid=117489#p117489> from Craig Williams I was able to do a better translation.
Very well explained and it helped me understand how to set what I need.
So for future reference or to avoid newcomers to bang their heads, here is how one sets a date value of a DatePicker cell:
set zdate to current application's class "NSDate"'s |date|() -- zdate gets cocoa today's date
what_date's setDateValue_(zdate) -- what_date is a reference to my DatePicker cell
It works!
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden