• 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: Conversion of ISO Date String to AppleScript Date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conversion of ISO Date String to AppleScript Date


  • Subject: Re: Conversion of ISO Date String to AppleScript Date
  • From: Ed Stockly <email@hidden>
  • Date: Sat, 04 Mar 2017 21:41:06 -0800

> On Mar 4, 2017, at 9:02 PM, Ed Stockly <email@hidden> wrote:
>
> Any other dates I should worry about?)

Yes. There are other dates to worry about.

To try to answer my question I ran this script, and it failed miserably. For some reason the runDate variable was inheriting the value of the myDate variable inside the handler.
What’s up with that? I rewrote it, and that returned a list of 70 dates over the next 10 years, each the 31st day of a month.

My faith in AppleScript dates is truly shaken.

——— This script returns an empty list
set badDates to {}
set ISOdateString to "2017-04-04 11:15:15"
set runDate to date "Friday, December 30, 2016 at 12:00:00 AM"
set goodDate to my AppleScriptISODate(ISOdateString, runDate)
repeat with x from 1 to 365 * 3

	set runDate to runDate + 1 * days
	set appleScriptDate to my AppleScriptISODate(ISOdateString, runDate)
	if appleScriptDate is not goodDate then set the end of badDates to appleScriptDate
end repeat
return badDates
on AppleScriptISODate(ISOdateString, mydate)
	set {theYear, theMonth, theDay, theHour, theMin, theSec} to words of ISOdateString

	set {year of mydate, month of mydate, day of mydate, hours of mydate, minutes of mydate, seconds of mydate} to {theYear as integer, theMonth as integer, theDay as integer, theHour as integer, theMin as integer, theSec as integer}
	return mydate
end AppleScriptISODate

——————————— this script returns a list of 70 items


set badDates to {}
set ISOdateString to "2017-04-04 11:15:15"
set runDate to date "Friday, December 30, 2016 at 12:00:00 AM"
copy runDate to myDate
set goodDate to my AppleScriptISODate(ISOdateString, myDate)

repeat with x from 1 to 365 * 10
	set runDate to runDate + 1 * days
	copy runDate to myDate
	set appleScriptDate to my AppleScriptISODate(ISOdateString, myDate)
	if appleScriptDate is not goodDate then set the end of badDates to runDate
end repeat
return badDates
on AppleScriptISODate(ISOdateString, myDate)
	set {theYear, theMonth, theDay, theHour, theMin, theSec} to words of ISOdateString

	set {year of myDate, month of myDate, day of myDate, hours of myDate, minutes of myDate, seconds of myDate} to {theYear as integer, theMonth as integer, theDay as integer, theHour as integer, theMin as integer, theSec as integer}
	return myDate
end AppleScriptISODate



 _______________________________________________
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: Conversion of ISO Date String to AppleScript Date
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Conversion of ISO Date String to AppleScript Date (From: Ed Stockly <email@hidden>)
 >Re: Conversion of ISO Date String to AppleScript Date (From: Ed Stockly <email@hidden>)
 >Re: Conversion of ISO Date String to AppleScript Date (From: Ed Stockly <email@hidden>)

  • Prev by Date: Re: Conversion of ISO Date String to AppleScript Date
  • Next by Date: how to create a reference a variable at runtime
  • Previous by thread: Re: Conversion of ISO Date String to AppleScript Date
  • Next by thread: Re: Conversion of ISO Date String to AppleScript Date
  • Index(es):
    • Date
    • Thread