Week number
David Kwinter
dk42 at mac.com
Sat Apr 13 16:47:00 EDT 2002
This is my last whack at it.. there's definitely got to be a better way.
But these seems to work.
Just specify your month, day & year in the first few lines...
on mouseup
put the seconds into nowSecs
put "12" into theMonth
put "31" into theDay
put "2002" into theYear
put "no" into leapThisYear
if "." is not in theYear/4 then
put "yes" into leapThisYear
if "." is in theYear/100 then
put "no" into leapThisYear
if "." is not in theYear/2000 then
put "yes" into leapThisYear
end if
end if
end if
if theMonth>01 then add 31 to dayCount
if theMonth>02 then add 28 to dayCount
if leapThisYear="yes" then add 1 to dayCount
if theMonth>03 then add 31 to dayCount
if theMonth>04 then add 30 to dayCount
if theMonth>05 then add 31 to dayCount
if theMonth>06 then add 30 to dayCount
if theMonth>07 then add 31 to dayCount
if theMonth>08 then add 31 to dayCount
if theMonth>09 then add 30 to dayCount
if theMonth>10 then add 31 to dayCount
if theMonth>11 then add 30 to dayCount
set itemDelimiter to "/"
add theDay to dayCount
put dayCount*24*60*60 into furtherSecsThisYear
put 0 into totalSecs
put 1969 into sYr
repeat
add 1 to sYr
if sYr=theYear then exit repeat
put "no" into leapYear
if "." is not in sYr/4 then
put "yes" into leapYear
if "." is in sYr/100 then
put "no" into leapYear
if "." is not in sYr/2000 then
put "yes" into leapYear
end if
end if
end if
if leapYear="no" then put 365 into daysThisYear
else put 366 into daysThisYear
add daysThisYear*60*60*24 to totalSecs
end repeat
put (totalSecs+furtherSecsThisYear)-totalSecs into netSecsThisYr
put netSecsThisYr/60/60/24/7 into netWeek
set itemDelimiter to "."
put item 1 of netWeek into thisWeek
answer thisWeek
end mouseup
More information about the use-livecode
mailing list