• 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: monthNumber (was: Create a folder with today's date...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: monthNumber (was: Create a folder with today's date...)


  • Subject: Re: monthNumber (was: Create a folder with today's date...)
  • From: paulskinner <email@hidden>
  • Date: Tue, 12 Feb 2002 09:45:10 -0500

On Monday, February 11, 2002, at 10:45 PM, Michelle Steiner wrote:

Also, please try my solution; I'm curious as to how it stacks up to the
others.

Thanks,

--Michelle

I changed your version to as below to give it a fair chance( can't be doing 100000 calls to current date). It's 10x slower than French vanilla. Offset is such a lazy-bones!

on MonthIndex(dateObject)
set allTheMonths to "JanFebMarAprMayJunJulAugSepOctNovDec"
set monthInteger to ((offset of (text 1 through 3 of (dateObject as text)) in allTheMonths) + 2) div 3
return monthInteger
end MonthIndex

Here's a slight variation that blends the call methods of French Vanilla and the 'IFy' method. :^)
FV had originally operated on the current date, The IFy method wanted constants. This will eat dates, constants or strings (of valid month names) and spit out month indices.

on MonthIndex(dateObject)
try
copy dateObject to basedate
set month of basedate to January
return (1 + (dateObject - basedate) div 2.5E+6)
on error
try
set dateObject to (date (dateObject as text))
copy dateObject to basedate
set month of basedate to January
return (1 + (dateObject - basedate) div 2.5E+6)
on error errorText
return "Error in MonthIndex: " & errorText
end try
end try
end MonthIndex

It's as fast as French Vanilla OMM. (10.1/1.8.1) as long as you pass it dates, coercion of the other types of input does slow it down a bit, but it's still quick.
--
Paul Skinner
_______________________________________________
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: -1708: errAEEventNotHandled
  • Next by Date: Scripting OSX Mail App
  • Previous by thread: Re: monthNumber (was: Create a folder with today's date...)
  • Next by thread: Re: monthNumber (was: Create a folder with today's date...)
  • Index(es):
    • Date
    • Thread