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

Re: Date problem


  • Subject: Re: Date problem
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 31 May 2015 10:10:55 +0200


Le 31/05/2015 à 10:00, Brian Christmas <email@hidden> a écrit :

G’day folks

I’ve struck an unusual problem.

The script...

property averageYear : "2015"
set theList to ""
set cd to (current date)
repeat with x from 1 to 12
set cd to (current date) # This, if uncommented, makes correct list
set theIntegerTallyMonth to x
set month of cd to theIntegerTallyMonth
set theNameInsert to ((my averageYear) & " " & (month of cd as integer) & " (" & (month of cd as text) & ") Averaged" as text)
set theList to theList & theNameInsert & return
end repeat
theList



Edit it this way :
property averageYear : "2015"
set theList to ""
set cd to (current date)
repeat with x from 1 to 12
set cd to (current date) # This, if uncommented, makes correct list
set day of cd to 1 # ADDED
set theIntegerTallyMonth to x
set month of cd to theIntegerTallyMonth
set theNameInsert to ((my averageYear) & " " & (month of cd as integer) & " (" & (month of cd as text) & ") Averaged" as text)
set theList to theList & theNameInsert & return
end repeat
theList

and all will work well.

In your original code, as we are on may 31th
when you set the month to 2, the script return an unwanted month because there is no day 31 in February, April, June, September and November.
The edited version set the day of the date to 1 so everything works well.
I would use:

property averageYear : "2015"
set theList to ""
set cd to (current date)
set day of cd to 1
repeat with x from 1 to 12
set theIntegerTallyMonth to x
set month of cd to theIntegerTallyMonth
set theNameInsert to ((my averageYear) & " " & (month of cd as integer) & " (" & (month of cd as text) & ") Averaged" as text)
set theList to theList & theNameInsert & return
end repeat
theList


Yvan KOENIG (VALLAURIS, France) dimanche 31 mai 2015 10:10:44



 _______________________________________________
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: Date problem
      • From: Yvan KOENIG <email@hidden>
References: 
 >Date problem (From: Brian Christmas <email@hidden>)

  • Prev by Date: Date problem
  • Next by Date: Re: Date problem
  • Previous by thread: Date problem
  • Next by thread: Re: Date problem
  • Index(es):
    • Date
    • Thread