I cannot do is get Finder to return the number of days from the date

Hi guys

Firstly big thanks to jj, jonn8 et al for helping me out on other stuff.

Just had one quick question:

Trying to write a script to generate calendar data as text ie Jan has 31 days with the correct corresponding day, so I can output a text file for Qxp.

What I cannot do is get Finder to return the number of days from the month/date constant.

Is it possible?

Or should I try to extract from iCal? probably easier??

or should I give up and do it manually which with my skill level in AS would take the same amount of time!!


You can use the cal command. Here’s an example that should get you going:

set the_month to month of (current date) as integer
set the_year to year of (current date) as integer
set the_cal to (my get_cal(the_month, the_year)) --return my get_cal("", the_year) --leave month empty for full year
set the_days to word -1 of the_cal
return {the_month:the_month, the_year:the_year, the_days:the_days, the_cal:the_cal}

on get_cal(the_month, the_year)
	return (do shell script "cal " & the_month & " " & the_year)
end get_cal



How’s about subtracting 1 day from February 1. Then, get the day number. Something like this:

set feb_1 to (date “Sunday, February 1, 2004 12:00:00 AM”)
set jan_last_day to feb_1 - 1 * days
set day_number to day of jan_last_day

The Editor auto changes the short date string to long when checking syntax.


Thanks guys. Will try both of these when I get time.


Where can I get some info on shell scripts?

Been using Macs for years but the Unix side is still a bit new to me. I understand the basic concepts but not sure what is available and what can be done. I guess I could write my own?? Err maybe one day!!