Re: Days and hours
Re: Days and hours
- Subject: Re: Days and hours
- From: kai <email@hidden>
- Date: Mon, 24 Oct 2005 00:53:27 +0100
On 20 Oct 2005, at 13:46, Nigel Garvey wrote:
Of course, we've both made the unconscious assumption that the name
of every month in the local language will consist of just one word....
Yeah, I hadn't considered that, Nigel - even though I'd come across
examples of multiple-word month names previously. (The Irish names
for September and October, for example, being "Meán Fómhair" and "D.
Fómhair" respectively.)
-------------
On 22 Oct 2005, at 01:29, Nigel Garvey wrote:
[snip: sans-variable code]
The above code (by me), while it is to be avoided in its own right,
might
not work properly if your word for "January" or "February" is the
same as
your word for "Thursday". Fortunately, in western languages, any
coincidence is more likely to affect "March" and "Tuesday", which
is no
problem here. :-)
The following variation confines the weekday of compared dates to
Monday - and attempts to preserve month names of more than one word...
-------------
on listToText from l around d
set text item delimiters to d
tell l to beginning & ({""} & rest)
end listToText
on localizedMonths()
set l to {}
tell "1 1 1" to tell (my date it) - days to repeat 12 times
set day to 32
tell it + days * (9 - (its weekday)) to set l's end to space
& date string & space
end repeat
set tid to text item delimiters
set l to listToText from l around return
repeat with n in "0123456789"
set text item delimiters to n
set l to listToText from l's text items around ""
end repeat
set text item delimiters to space
repeat with i in (get text items of text 2 thru -2 of l's
paragraph 1)
set text item delimiters to space & i & space
if (count l's text items) > 12 then set l to listToText from
l's text items around space
end repeat
repeat with r in {return & space, space & return}
set text item delimiters to r
set l to listToText from l's text items around return
end repeat
set text item delimiters to tid
paragraphs of l's text 2 thru -2
end localizedMonths
choose from list localizedMonths()
-------------
on totalHours for m from h
tell (current date)
set its month to m
set day to 28
tell {it + 4 * days, its weekday as integer, ((h's item ¬
1) + (h's item 2) + (h's item 3) + (h's item 4) + ¬
(h's item 5) + (h's item 6) + (h's item 7)) * 4}
repeat with d from item 2 to (item 2) + ((beginning - ¬
(beginning's day) * days)'s day) - 29
set last item to end + (h's item (d mod 7 + 1))
end repeat
its end
end tell
end tell
end totalHours
totalHours for requiredMonth() from {0, 2.5, 2.5, 2, 0, 2, 0}
I can imagine Ronnie Barker reciting this at high speed from
memory. :-)
- As only Ronnie Barker could! :-)
I still chuckle about some of his other forms of wordplay, too. This
has got to be one of my all-time favourites:
http://pegnsean.net/~occupant/candle01.htm
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden