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

Re: Date Formatting


  • Subject: Re: Date Formatting
  • From: John Delacour <email@hidden>
  • Date: Fri, 7 Mar 2003 16:30:40 +0000
  • Mac-eudora-version: 6.0a9

At 1:45 pm +0000 7/3/03, <email@hidden> wrote:

It also handily and flexibly addresses the leading zeros
problem, and the US vs. World notation problem. Is there a reason that its
been considered unsuitable?

As has been said, all that can be done with a short line of perl or UNIX code, but if you must use Applescript then you can at least halve the length of your script and make it more readable.


global d
global m
global y
getDate()
makeDate(d, 2, m, 2, y, 2, "/", "ymd")
on getDate()
set cd to current date
set {n, d, m, y} to {0, cd's day, cd's month, cd's year}
set ls to {January, February, March, April, May, June, July, August}
set ls to ls & {September, October, November, December}
repeat with i from 1 to 12
if item i of ls is m then set m to i
end repeat
end getDate
on makeDate(d, ld, m, lm, y, ly, chr, ord)
if (count of ("" & d)) < ld then set d to "0" & d
if (count of ("" & m)) < lm then set m to "0" & m
if (count of ("" & y)) > ly then set y to text 3 through -1 of ("" & y)
if ord is "dmy" then return d & chr & m & chr & y
if ord is "mdy" then return m & chr & m & chr & y
if ord is "ymd" then return y & chr & m & chr & d
end makeDate

JD
_______________________________________________
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: 
 >Date Formatting (From: <email@hidden>)

  • Prev by Date: Re: Fallacious Thinking (Re: Date Formatting)
  • Next by Date: Re: path to selection/ASCII character 173
  • Previous by thread: PDF Services script won't process one page only
  • Next by thread: Short course
  • Index(es):
    • Date
    • Thread