• 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: Changing current date format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing current date format


  • Subject: Re: Changing current date format
  • From: Christopher Stone <email@hidden>
  • Date: Sun, 19 Jan 2014 13:51:36 -0600

Hey JF,

I see you've made a choice, which I assume is for brevity and clarity of the notation.  (Correct me if I'm wrong.)

property abbrMonth : {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}

Not sure why we're messing around with this old stuff, since it's been possible to coerce month to text for some time - but it is a tried and true old technique used to work around one of Applescript's former shortcomings.

-------------------------------------------------------------------------------------------
# Not directly relevant but worth noting:
set isoDate to (current date) as «class isot» as string
-------------------------------------------------------------------------------------------
# Again not directly relevant but worth noting:
set d to current date
set dStr to date string of d
set sDtStr to short date string of d
-------------------------------------------------------------------------------------------
# Relevant - clunky to make it a bit more obvious to JF how it works.
on dtStr(_date, _sep)
tell _date
set _month to text 1 thru 3 of (its month as text)
set _year to year
set _day to text 3 thru -1 of ((day / 100) as text)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, _sep}
set _output to {_year, _month, _day} as text
set AppleScript's text item delimiters to oldTIDS
return _output
end tell
end dtStr

dtStr(current date, "-")
dtStr(current date, "/")
dtStr(current date, "")
dtStr(current date, " ")
-------------------------------------------------------------------------------------------
# Relevant
on invDate(_date, sep)
tell (_date) to text 3 thru -1 of (((day) / 100 & sep & (text 1 thru 3 of (its month as text)) & sep & year) as text)
"Invoice Dated: " & result
end invDate

invDate(current date, " ")

-------------------------------------------------------------------------------------------

One of the nice things about handlers is that you can have a pure mess of spaghetti code in one with a much simpler invocation in the body of your code.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Changing current date format
      • From: Emmanuel LEVY <email@hidden>
    • Re: Changing current date format
      • From: Shane Stanley <email@hidden>
References: 
 >Changing current date format (From: JF <email@hidden>)
 >Re: Changing current date format (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Re(2): Changing current date format
  • Next by Date: Re: Changing current date format
  • Previous by thread: Re: Changing current date format
  • Next by thread: Re: Changing current date format
  • Index(es):
    • Date
    • Thread