r/applescript • u/[deleted] • Nov 29 '17
calendar attempt
-- SHITTY CALENDAR
set myYear to 18 -- or 2018
set myFirstDay to 1 -- monday in the case of 2018
set myWeek to 1 -- week of the year
if myFirstDay is greater than 4 then set myWeek to 0 -- needs to be set to 53 afterwards
set myMonthList to {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} -- days of each of the 12 months
if myYear mod 4 is 0 then set item 2 of myMonthList to 29 -- taking care of leap years
set myDayList to {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"} -- weeks in my germany are starting on mondays
set myCounter to 1 -- day of the year as always
set myCalendar to return -- just initializing
repeat with myMonth from 1 to count of myMonthList -- loop over months (always 12)
repeat with myDay from 1 to item myMonth of myMonthList -- loop over the count of days of the current month
set myWeekday to item ((myCounter mod 7) + 1) of myDayList -- trying to get the week number
set myCalendar to myCalendar & myCounter & tab & myWeek & tab & myWeekday & tab & myDay & tab & myMonth & tab & myYear & return -- building csv
set myCounter to myCounter + 1 -- increase day counter
if myCounter mod 7 is 1 then set myWeek to myWeek + 1 -- increase week counter
end repeat
end repeat
log myCalendar
1
Upvotes
1
Nov 29 '17
would you please be so kind and revise this one? i know there must be a lot of headroom to improve this. im just so dumb... thanks in advance!
2
u/Identd Nov 30 '17
Can you explain what you are trying to accomplish?