• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Date pickers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date pickers


  • Subject: Re: Date pickers
  • From: red_menace <email@hidden>
  • Date: Mon, 08 Feb 2010 21:17:27 -0700


On Feb 8, 2010, at 7:53 PM, Deivy Petrescu wrote:

When I run a test here is what I get:

<output>
run
[Switching to process 5965]
Running∑
2010-02-08 19:42:40.425 OpenApp_Test[5965:a0f] 2010-01-01 00:00:00 -0500
</output>

where "2010-01-01 00:00:00 -0500" is the date that I want to capture.



Since before ASOC, I've used a handler (based on observations made by the fine folk 
at macscripter.net) to convert an ISO time string to an AppleScript date, since those are 
used in various places such as Spotlight metadata (and now, Cocoa).  Although there 
isn't an "official" conversion in there for whatever reason, the «class isot» object has 
been in use for a while:


on run -- example
set x to "2010-01-01 00:00:00 -0500"
set theDate to convertISOToDate(x)
log the result
display dialog x & return & theDate -- as text
end run


to convertISOToDate(ISOText)
(*
convert an ISO date/time string to a date using the hexdump shell script
parameters - ISOText [text]: ISO date/time
returns [mixed]: the ISO string as class date (or original text if error)
*)
try
-- get a hexdump of the input date
do shell script "echo " & quoted form of (ISOText as text) & "| xxd -u -p"
-- add class header and convert
return (run script "get «data isot" & (text 1 thru -3 of the result) & "»") as date
on error errorMessage -- oops
log errorMessage
return ISOText
end try
end convertISOToDate


Dave

 _______________________________________________
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

  • Follow-Ups:
    • Re: Date pickers
      • From: Robert DuToit <email@hidden>
  • Prev by Date: Re: Date pickers
  • Next by Date: Re: Date pickers
  • Previous by thread: Re: Date pickers
  • Next by thread: Re: Date pickers
  • Index(es):
    • Date
    • Thread