• 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: Need help with finding first of the month
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with finding first of the month


  • Subject: Re: Need help with finding first of the month
  • From: Nigel Garvey <email@hidden>
  • Date: Fri, 2 Jul 2004 01:02:00 +0100

"Young, Rich A." wrote on Thu, 1 Jul 2004 15:00:52 -0500 :

>I need to add a piece to an existing script that will find how many days it
>is until the first day of the next month from any given date taking into
>account things like leap year. Can anyone point me in the right direction

It depends what you mean by "days ... until the first of next month. If
you mean the number of complete 24-hour periods then:

on daysToFirstOfNextMonth(theDate)
tell 33 - (theDate's day) to return it - ((theDate + it * days - 1)'s
day)
end daysToFirstOfNextMonth

daysToFirstOfNextMonth(date "Saturday, 31 July 2004 23:59:59")
--> 0

If you mean the number of times the date changes:

on daysToFirstOfNextMonth(theDate)
tell 32 - (theDate's day) to return it - ((theDate + it * days)'s
day) + 1
end daysToFirstOfNextMonth

daysToFirstOfNextMonth(date "Saturday, 31 July 2004 23:59:59")
--> 1

NG
_______________________________________________
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:
    • Re: Need help with finding first of the month
      • From: "John W. Baxter" <email@hidden>
  • Prev by Date: Re: Don't waste disk space, use URL redirection services to distribute your scripts...
  • Next by Date: Re: Automator in OS 10.4 (Tiger)
  • Previous by thread: Re: Need help with finding first of the month
  • Next by thread: Re: Need help with finding first of the month
  • Index(es):
    • Date
    • Thread