• 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: Coerce time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce time


  • Subject: Re: Coerce time
  • From: Graff <email@hidden>
  • Date: Sun, 30 Nov 2003 20:35:12 -0500

Whups, there is a little error in this code. I wrote "less than 9" when I meant "less than 10". Here's the corrected form:
---------
set myDate to date "August 20, 2003"
set myShortDate to ""

set theMonth to the (month of myDate) as integer
set theDay to the (day of myDate) as integer
set theYear to (text 3 thru 4 of ((year of myDate) as text))

if theMonth is less than 10 then
set myShortDate to myShortDate & "0"
end if
set myShortDate to myShortDate & theMonth & "/"

if theDay is less than 10 then
set myShortDate to myShortDate & "0"
end if
set myShortDate to myShortDate & theDay & "/"

set myShortDate to myShortDate & theYear
---------

- Ken

On Nov 30, 2003, at 8:25 PM, Graff wrote:

If you specifically want it in the format mm/dd/yy then you need to parse it out yourself:
---------
set myDate to date "August 20, 2003"
set myShortDate to ""

set theMonth to the (month of myDate) as integer
set theDay to the (day of myDate) as integer
set theYear to (text 3 thru 4 of ((year of myDate) as text))

if theMonth is less than 9 then
set myShortDate to myShortDate & "0"
end if
set myShortDate to myShortDate & theMonth & "/"

if theDay is less than 9 then
set myShortDate to myShortDate & "0"
end if
set myShortDate to myShortDate & theDay & "/"

set myShortDate to myShortDate & theYear
---------
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Coerce time (From: Graff <email@hidden>)

  • Prev by Date: Re: Hiding Application after running script
  • Next by Date: Re: Hiding Application after running script
  • Previous by thread: Re: Coerce time
  • Next by thread: Re: OS X and RegEx Commands
  • Index(es):
    • Date
    • Thread