Adding week numbers to month view

M

motiondude

Version: 2004
Operating System: Mac OS X 10.5 (Leopard)
Processor: Power PC
Email Client: pop

Hi, I'm having some trouble adding week numbers to my month view calander. I've tried a scipt that was originally mend for 2008. When I execute the script I have to fill in the year so I type in: 2009. Then I get an error stating: Invalid date and time. How do I fix this? Or, is there a better script out there? Or what do I have to alter in the script?

I have to mention that I'm in Europe so our week starts on monday and we're using ISO-weeks. Our dating system is dd-mm-yyyy. Thanks in advance!
 
W

William Smith [MVP]

Hi, I'm having some trouble adding week numbers to my month view
calander. I've tried a scipt that was originally mend for 2008. When
I execute the script I have to fill in the year so I type in: 2009.
Then I get an error stating: Invalid date and time. How do I fix
this? Or, is there a better script out there? Or what do I have to
alter in the script?

I have to mention that I'm in Europe so our week starts on monday and
we're using ISO-weeks. Our dating system is dd-mm-yyyy. Thanks in
advance!

I'm the writer of the script and I believe I have seen this issue before.

The script was "compiled" while it was on a Mac with Entourage 2008,
however, it should still work for Entourage 2004. Simply re-saving the
script on your system should make it work.

You will need to open the Script Editor application found in
/Applications/AppleScript. Select File --> Open and select the script.
Go ahead and open it. Then all you need to do is simply choose File -->
Save As... and save it with a new name or to a new location.

If this doesn't work then let me know.

As for changing start days from Sunday to Monday, I believe you can do
it by altering this section of the script slightly while you have it open:

if day1 is Sunday then
set theSunday to 0
else if day1 is Monday then
set theSunday to -1
else if day1 is Tuesday then
set theSunday to -2
else if day1 is Wednesday then
set theSunday to -3
else if day1 is Thursday then
set theSunday to -4
else if day1 is Friday then
set theSunday to -5
else if day1 is Saturday then
set theSunday to -6
end if

Change the first line "if day1 is Sunday then" to "if day1 is Monday then".

Change the next line "if day1 is Monday then" to "if day1 is Tuesday
then", etc.

You'll change the last "Saturday" to "Sunday".

Don't worry about anything else that says "firstSunday" or "theSunday".
Leave them as they are. They are just arbitrary names.

Hope this helps!

--

bill

Entourage Help Page <http://entourage.mvps.org/>
Entourage Help Blog <http://blog.entourage.mvps.org/>
YouTalk <http://nine.pairlist.net/mailman/listinfo/youtalk>
Twitter: follow <http://twitter.com/meck>
 
M

motiondude

Hi William, Thanks for your response. I already thought if was something like that. However, I don't get it to work. I changed the days as you described but also wanted to make the notation shorter: Wk 01 instead of Week 01 and I want to get rid of the day numbering. I don't need it and I find it a bit distracting. I've tested in both 2004 and 2008 but in neither of them it's working. 2004 gives me the invalid date warning and in 2008 it does nothing at all.

(*

--------------------------------------------
Add Week Numbers 1.0
©2008 William Smith
[email protected]

This script may be freely modified for personal or commercial
purposes but may not be republished without prior consent.

If you find this script useful or have ideas for improving it, please let me know.
--------------------------------------------

This script adds a new all-day calendar event on every Sunday for the specified year.
Each event is set with a "Free" status and is named for the number of the week
and the ordinal date for the current year.

Installation: Place this script in your user home folder in this location
~/Documents/Microsoft User Data/Entourage Script Menu Items.

Use: Select "Add Week Numbers" from the Script menu in Entourage and enter a year
from 1905 to 2039. All-day Free status events will be added to each Sunday of the year
similar to the following information:

Wk 28

* )

-----------------------------------------------------------
-- Ask for a year - must between 1905 and 2039
-----------------------------------------------------------

tell application "Microsoft Entourage"

set theYear to ""

repeat until theYear ≥ 1905 and theYear ≤ 2039
set theYear to display dialog "This script will add week numbers to your default Entourage Calendar for the year below." default answer year of (current date) with icon 1 with title "Add week numbers for this year..."

set theYear to text returned of theYear

if theYear ≤ 1905 or theYear ≥ 2039 then
display dialog "Enter a year from 1905 to 2039." with icon 2 with title "Alert!"
end if
end repeat

end tell

-----------------------------------------------------------
-- What's the first day of the year?
-- Now, what's the first Sunday of the year?
-- This script will calculate week numbers
-- based on the first Sunday of the year.
-----------------------------------------------------------

set day1 to weekday of date ("January 1" & ", " & theYear)

if day1 is Monday then
set theSunday to 0
else if day1 is Tuesday then
set theSunday to -1
else if day1 is Wednesday then
set theSunday to -2
else if day1 is Thursday then
set theSunday to -3
else if day1 is Friday then
set theSunday to -4
else if day1 is Saturday then
set theSunday to -5
else if day1 is Sunday then
set theSunday to -6
end if

set newYearsDay to (date ("January 1" & ", " & theYear))
set firstSunday to newYearsDay + (86400 * theSunday)

-----------------------------------------------------------
-- Go populate the default calendar
-- with week numbers.
-----------------------------------------------------------

tell application "Microsoft Entourage"
make new event with properties {subject:"Wk 1", start time:firstSunday, all day event:true, recurring:false}

set oneWeek to 60 * 60 * 24 * 7 -- seconds x minutes x hours x days = one week
set weekNumber to 2
set dayNumber to theSunday + 8

repeat with i from 1 to 51
set nextSunday to (firstSunday) + (oneWeek * i)
make new event with properties {subject:"Wk " & weekNumber, start time:nextSunday, all day event:true, recurring:false}
set weekNumber to weekNumber + 1
end repeat

end tell

So William, what am I missing here? I hope you can help me out.
 
W

William Smith [MVP]

Hi William, Thanks for your response. I already thought if was
something like that. However, I don't get it to work. I changed the
days as you described but also wanted to make the notation shorter:
Wk 01 instead of Week 01 and I want to get rid of the day numbering.
I don't need it and I find it a bit distracting. I've tested in both
2004 and 2008 but in neither of them it's working. 2004 gives me the
invalid date warning and in 2008 it does nothing at all.

Sorry for taking so long to respond. If you'll zip your script into an
archive file and send it to me then I'll be glad to take a look at it.
Send it to:

mecklists att comcast dawt net

--

bill

Entourage Help Page <http://entourage.mvps.org/>
Entourage Help Blog <http://blog.entourage.mvps.org/>
YouTalk <http://nine.pairlist.net/mailman/listinfo/youtalk>
Twitter: follow <http://twitter.com/meck>
 
Top