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

Re: Quickie Question


  • Subject: Re: Quickie Question
  • From: Sander Tekelenburg <email@hidden>
  • Date: Sat, 30 Mar 2002 18:36:11 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 02:17 -0800 UTC, on 30-03-2002, Chuck Ross wrote:

>> Now if only someone would come up with a vanilla way to obtain
>> the month as an integer, right Emmanuel? ;-)
>
> I saw something like this once. I can't be sure, but I think it was
> done by Matt Petrowski as a FileMaker Pro calc, but I could be wrong. I
> just remembered the basic technique and translated it to AppleScript.
> If by "vanilla" you mean we can use the standard scripting additions,
> then this should work.
>
> set theDate to current date
> set monthNum to ((((offset of ((characters 1 thru 3 of ((month of
> theDate) as string))
> as string) in "JanFebMarAprMayJunJulAugSepOctNovDec") - 1) / 3) +
> 1) as integer

Well, that depends on your definition of "work" ;) It will fail on non
english systems. The following works as in "works":

- From the <news:alt.comp.lang.applescript> FAQ at
<http://homepage.mac.com/dlivesay/aclafaq.html>:

+++++ begin quote +++++

3.3. How can I get the month of a date as a number?

AppleScript's date object gives you the month as a string only (January,
February etc.). You can either now check for the string value of the month
and get the appropriate number through a series of 12 "if...then" loops, or
you can use the so-called French Vanilla algorithm:

set theDate to the current date --or any other date
copy theDate to b
set the month of b to January
set monthNum to (1 + (theDate - b + 1314864) div 2629728)

The variable monthNum will return an integer representing the number of the
month (1 through 12).

+++++ end quote +++++

Note the term "french vanilla". It seems likely it refers to Emmanuel ;)


-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPKX3h+sywKfXgqKdEQLVZwCcCXlU6QCO4lIR/4Yq5mMOdHjA/3wAoJEB
uR2xwmTnkOugHJRg+WvHTU2Z
=YudJ
-----END PGP SIGNATURE-----
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
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.

  • Follow-Ups:
    • Popup buttons
      • From: Matthew Stuckwisch <email@hidden>
    • Re: Quickie Question
      • From: Matthew Stuckwisch <email@hidden>
References: 
 >Re: Quickie Question (From: Chuck Ross <email@hidden>)

  • Prev by Date: Re: Missing file info
  • Next by Date: Re: scripting apps in packages with OS 9.0.4?
  • Previous by thread: Re: Quickie Question
  • Next by thread: Re: Quickie Question
  • Index(es):
    • Date
    • Thread