|
|
#1 |
|
Major Leaguer
Join Date: Oct 2002
Posts: 467
|
weeks of pregnancy
a very long time ago I found here a script that makes a new calendar in ical with whole day events from monday to friday and call it week number, it crates 52 such events in this new calendar.
I am trying to adjust it to give me count of my wife's pregnancy weeks. mind you, I am shooting arrows in the dark as I have no idea what means what here. the important things for me are that the first event (week) will start on july 31 2012 and end 7 days later and then the second will start, there will be 42 weeks in this calendar I thought it was working nicely but as the next week is, from some reason back to 1 after 22 and I can't find the reason... please your help. here is the script after my playing with it... set numberOfWeeks to 42 set daysText to "TueWedThuFriSatSunMon" set aDate to (current date) set day of aDate to 31 set month of aDate to July set year of aDate to 2012 set aDay to weekday of aDate set weekNo to 1 --Day of week as num. starting with 0 set aDayText to (characters 1 thru 3 of (aDay as text)) as text set dayOff to ((offset of aDayText in daysText) - 1) / 3 as integer if dayOff is less than 5 then set StartDate to aDate - dayOff * days else set StartDate to aDate + (7 - dayOff) * days end if tell application "iCal" set newCal to make new calendar at end of calendars with properties {title:"Pregnancy Week No.'"} set myCal to (count of every calendar) end tell repeat with myCount from 1 to numberOfWeeks if (month of StartDate is December) and (day of StartDate is greater than 28) then set weekNo to 1 if (month of StartDate is January) and (day of StartDate is less than 5) then set weekNo to 1 set weekText to "Week No. " & weekNo tell application "iCal" tell calendar myCal make new event at end of events with properties {start date:StartDate, end date:StartDate + (6 * days), allday event:true, summary:weekText} end tell end tell set weekNo to weekNo + 1 set StartDate to StartDate + 7 * days end repeat
__________________
there is nothing better than a... oh well, that aint that good... |
|
|
|
|
|
#2 |
|
Hall of Famer
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 4,945
|
Wouldn't it be easier to do something like this:
set StartDate to date "Tuesday, July 31, 2012 12:00:00 AM" repeat with theWeek from 1 to 42 set aTuesday to StartDate + theWeek * weeks addToCal(aTuesday, theWeek) end repeat to addToCal(aDay, aNum) -- do your cal stuff here using the Tuesday date and the week number that have been passed. end addToCal
__________________
17" MBP, OS X 10.8.3; 27" iMac, OS X 10.8.3 Last edited by NovaScotian; 12-29-2012 at 06:50 PM. |
|
|
|
|
|
#3 |
|
Major Leaguer
Join Date: Oct 2002
Posts: 467
|
As i said, i know nothing about any of this, so i can't tell if it is better. but it does look simpler.
what should i copy paste? thanx
__________________
there is nothing better than a... oh well, that aint that good... |
|
|
|
|
|
#4 |
|
Hall of Famer
Join Date: Apr 2003
Posts: 2,658
|
Its a feature you can make a repeating event, no fancy magic, you can make daily weekly every two weeks, etc. You can even make multiple ones all tracking different things on different schedules.
You can also send reminders, multiple for each event. Alerts, Emails, etc. |
|
|
|
|
|
#5 |
|
Major Leaguer
Join Date: Oct 2002
Posts: 467
|
you all seem so nice but miss my main problem I am a complete newbeeeee
I have almost no understanding of what you are taking about, you will have to be a little more specific. Thanx
__________________
there is nothing better than a... oh well, that aint that good... |
|
|
|
|
|
#6 |
|
Hall of Famer
Join Date: Apr 2003
Posts: 2,658
|
Do not think this meets your needs but post it none the less, leave the scripting to my colleagues...
1) Go the Calendar and click your cursor on the day you want something to start. 2) Type a Description of that event 3) Now double click on the event you created and choose Edit 4) Leave or Not: All Day Button as appropriate (I usually leave it checked) 5) Below the From and To: date range, it Says REPEAT: None 6) Change The Repeat None pop up to: Every what ever you want, day, week, month, Custom, etc 7) Below that are options for Alerts, e.g. Pop Up 8) Once you create one alert you can create more alerts e.g. Email, etc. Last edited by anthlover; 12-30-2012 at 12:44 AM. |
|
|
|
|
|
#7 |
|
Hall of Famer
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 4,945
|
Definitely the best way to go -- use Calendar without any scripting at all. What's missing then is the week number, which could be done by adding a script to the event that sets the summary of the event, but I confess I've never done that, not sure how to go about it.
__________________
17" MBP, OS X 10.8.3; 27" iMac, OS X 10.8.3 |
|
|
|
|
|
#8 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,039
|
Oh, and there are some very good iPhone apps related to pregnancy. My favourites are the Contraction Timers -- press start and stop, get table of frequency and duration to show the midwife.
"You should be having another one ...... now."
|
|
|
|
|
|
#9 |
|
Hall of Famer
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 4,945
|
I just discovered that sandboxing in Mountain Lion makes it impossible to run a script from an event. Ah well....
__________________
17" MBP, OS X 10.8.3; 27" iMac, OS X 10.8.3 |
|
|
|
|
|
#10 |
|
Hall of Famer
Join Date: Apr 2003
Posts: 2,658
|
The use case I was suggesting was more for scheduling a recurring even/meeting reminder for taking meds or medication injections on a complicated schedule, etc.
I realize the OP was looking for a week number count. I can imagine why but not sure what will be done with the info. The OB/GYN usually keeps track of most of important cal events for the parents. Also not too hard to count by Months the weeks that have gone by from Aprox date of conception. Below are some tools outside of Ical that keep track of the weeks of pregnancy, trimester, etc. The first couple are web based so they work on anything, iphone too. Here are web based Pregnancy Calculator http://pregnancy.about.com/cs/pregna...blpregcalc.htm and http://calcnexus.com/pregnancy-calculator.php Iphone pregnancy apps http://ipod.about.com/od/bestiphonea...Ipod-Touch.htm Last edited by anthlover; 12-30-2012 at 12:55 PM. |
|
|
|
|
|
#11 |
|
Major Leaguer
Join Date: Oct 2002
Posts: 467
|
thanx all but you aren't answering my Qs
i want to fix the script so it will work. thanx for all the nice workarounds, though.
__________________
there is nothing better than a... oh well, that aint that good... |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|