• 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: kai <email@hidden>
  • Date: Wed, 20 Aug 2003 23:30:57 +0100

on Wed, 20 Aug 2003 14:42:38 -0500, Rich Carroll <email@hidden> wrote:

> Is there a simple way to coerce "August 20, 2003" to 08/20/03?
> I can figure out a complicated series of steps to do it "manually," I'm just
> hoping someone knows a better way.

A vanilla solution would require several steps, Rich. You'll probably get a
few suggestions - but here's one way:

-------------------------------------------------------
(Any wrapped lines abutting the left edge of the window
should be reconnected to the end of the previous line)
-------------------------------------------------------

--=====================

on shortDate(dateStr)
set {month:m, day:d, year:y} to date dateStr
set t to text item delimiters
set text item delimiters to (m as string)'s text 1 thru 3
set m to (count ("JanFebMarAprMayJunJulAugSepOctNovDec"'s text item 1))
div 3 + 1
set text item delimiters to t
("0" & m)'s text -2 thru -1 & "/" & ("0" & d)'s text -2 thru -1 & "/" &
(y as string)'s text -2 thru -1
end shortDate

--=====================

shortDate("August 20, 2003")
--> "08/20/03"

---
kai
_______________________________________________
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.

  • Prev by Date: Re: Coerce time
  • Next by Date: Re: Silly question?
  • Previous by thread: Re: Coerce time
  • Next by thread: Re: Coerce time
  • Index(es):
    • Date
    • Thread