text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
if length of numList < 2 then set timeMissing to true
|
Later.applescript
|
set timeDeferredTemp to figureOutTheTime(numList, timeMissing, false, true, minuteLeadingZero)
|
Later.applescript
|
set timeFromTodayUntilDesired to figuringTimeToDesiredDay(monthFound, (item 1 of numList))
|
Later.applescript
|
set totalTimeDeferred to timeFromTodayUntilDesired + timeDeferred
|
Later.applescript
|
return totalTimeDeferred
|
Later.applescript
|
end englishTime
|
Later.applescript
|
on isNumberIdentifier(possibleIdentifier, containerString)
|
Later.applescript
|
set numberIdentifier to true
|
Later.applescript
|
set identifierIsInContainer to false
|
Later.applescript
|
set positionOfLastIdentifier to 0
|
Later.applescript
|
set charList to every character of containerString
|
Later.applescript
|
repeat with i from 1 to (length of charList)
|
Later.applescript
|
if (item i of charList) = possibleIdentifier then
|
Later.applescript
|
set identifierIsInContainer to true
|
Later.applescript
|
set positionOfLastIdentifier to i
|
Later.applescript
|
if (positionOfLastIdentifier is 0) or (positionOfLastIdentifier is 1) then
|
Later.applescript
|
set numberIdentifier to false
|
Later.applescript
|
set characterBefore to character (positionOfLastIdentifier - 1) of containerString
|
Later.applescript
|
set numBefore to 0
|
Later.applescript
|
set numBefore to characterBefore as integer
|
Later.applescript
|
if (characterBefore is not " ") and (class of numBefore is not integer) then set numberIdentifier to false
|
Later.applescript
|
return numberIdentifier
|
Later.applescript
|
end isNumberIdentifier
|
Later.applescript
|
on howManyDays(numList, weeksMissing)
|
Later.applescript
|
set daysDeferred to item 2 of numList
|
Later.applescript
|
set daysDeferred to item 1 of numList
|
Later.applescript
|
return daysDeferred
|
Later.applescript
|
end howManyDays
|
Later.applescript
|
on figureOutTheTime(numList, timeMissing, daysMissing, weeksMissing, minuteLeadingZero)
|
Later.applescript
|
if not timeMissing then
|
Later.applescript
|
if minuteLeadingZero then
|
Later.applescript
|
set timeDeferredTemp to item -1 of numList
|
Later.applescript
|
set timeDeferredTemp to ((items -1 thru (1 + ((not daysMissing) as integer) + ¬
|
Later.applescript
|
((not weeksMissing) as integer)) of numList) as text) as integer
|
Later.applescript
|
set timeDeferredTemp to 0
|
Later.applescript
|
return timeDeferredTemp
|
Later.applescript
|
end figureOutTheTime
|
Later.applescript
|
to understandTheTime(timeDeferredTemp, inThe, timeMissing)
|
Later.applescript
|
if timeMissing then
|
Later.applescript
|
set timeDeferred to 0
|
Later.applescript
|
if timeDeferredTemp > 2400 then
|
Later.applescript
|
display alert "Please try again: the time you entered was not a valid time of day."
|
Later.applescript
|
set timeDeferred to -1
|
Later.applescript
|
else if timeDeferredTemp = 2400 then
|
Later.applescript
|
set timeDeferred to days
|
Later.applescript
|
else if timeDeferredTemp ≥ 100 then
|
Later.applescript
|
set minutesDeferred to (((characters -2 thru -1 of (timeDeferredTemp as text)) as text) as integer)
|
Later.applescript
|
set hoursDeferred to (((characters 1 thru -3 of (timeDeferredTemp as text)) as text) as integer)
|
Later.applescript
|
if inThe = "PM" then
|
Later.applescript
|
set timeDeferred to ((hoursDeferred + 12) * hours + minutesDeferred * minutes)
|
Later.applescript
|
else if hoursDeferred = 12 and inThe = "AM" then
|
Later.applescript
|
set timeDeferred to minutesDeferred * minutes
|
Later.applescript
|
set timeDeferred to (hoursDeferred * hours + minutesDeferred * minutes)
|
Later.applescript
|
else if timeDeferredTemp > 24 then
|
Later.applescript
|
else if timeDeferredTemp ≤ 24 then
|
Later.applescript
|
if timeDeferredTemp = 24 then
|
Later.applescript
|
else if (timeDeferredTemp = 12) and (inThe ≠ "AM") then
|
Later.applescript
|
set timeDeferred to 12 * hours
|
Later.applescript
|
else if (timeDeferredTemp ≥ 12) or (inThe ≠ "PM") then
|
Later.applescript
|
set timeDeferred to timeDeferredTemp * hours
|
Later.applescript
|
set timeDeferred to (timeDeferredTemp + 12) * hours
|
Later.applescript
|
return timeDeferred
|
Later.applescript
|
end understandTheTime
|
Later.applescript
|
to figuringTimeToDesiredDay(monthDesired, dayDesired)
|
Later.applescript
|
copy todaysDate to exactDesiredDate
|
Later.applescript
|
set (day of exactDesiredDate) to dayDesired
|
Later.applescript
|
set (month of exactDesiredDate) to monthDesired
|
Later.applescript
|
if exactDesiredDate < (current date) then
|
Later.applescript
|
set (year of exactDesiredDate) to ((year of todaysDate) + 1)
|
Later.applescript
|
return (exactDesiredDate - todaysDate)
|
Later.applescript
|
end figuringTimeToDesiredDay
|
Later.applescript
|
on daysFromTodayToWeekday(weekdayDesired)
|
Later.applescript
|
set currentWeekday to (weekday of (current date)) as integer
|
Later.applescript
|
if currentWeekday = weekdayDesired then
|
Later.applescript
|
else if currentWeekday < weekdayDesired then
|
Later.applescript
|
set daysDeferred to weekdayDesired - currentWeekday
|
Later.applescript
|
set daysDeferred to 7 + weekdayDesired - currentWeekday
|
Later.applescript
|
end daysFromTodayToWeekday
|
Later.applescript
|
on understandAbsoluteDate(theText)
|
Later.applescript
|
set the day of theDate to 1
|
Later.applescript
|
set the month of theDate to 2
|
Later.applescript
|
set theDate to (theDate - 1 * days)
|
Later.applescript
|
set theDate to short date string of theDate
|
Later.applescript
|
set text item delimiters to {".", "-", "/", "–", "—", "|", "\\"}
|
Later.applescript
|
set theDate to every text item of theDate
|
Later.applescript
|
set thePositions to {theDay:0, theMonth:0, theYear:0}
|
Later.applescript
|
repeat with i from 1 to (length of theDate)
|
Later.applescript
|
tell item i of theDate
|
Later.applescript
|
if it is in "01" then
|
Later.applescript
|
set (theMonth in thePositions) to i
|
Later.applescript
|
else if it is in "31" then
|
Later.applescript
|
set (theDay in thePositions) to i
|
Later.applescript
|
set (theYear in thePositions) to i
|
Later.applescript
|
set targetDate to (current date)
|
Later.applescript
|
set time of targetDate to 0
|
Later.applescript
|
if (length of theText is not 2) and (length of theText is not 3) then
|
Later.applescript
|
if length of theText is 3 then
|
Later.applescript
|
set the year of targetDate to solveTheYear((item (theYear of thePositions) of theText) as number)
|
Later.applescript
|
set thePositions to adjustPositionsForNoYear(thePositions)
|
Later.applescript
|
set the month of targetDate to (item (theMonth of thePositions) of theText) as number
|
Later.applescript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.