Here's a fun little snippet of code to let you plan unusual birthday
parties. Just insert a list of dates and get a list of parties, like
celebrating the 2222nd week of birth ;-)
| start end parties birthday birth number party |
start := (Date today subtractDays: 14) asSeconds.
end := (Date today addDays: 365*5) asSeconds.
parties := SortedCollection new.
#('1/3/1995' '7/30/1999') do: [:each |
birthday := Date fromString: each.
birth := birthday asSeconds.
1 to: 9 do: [:digit |
{false. true} do: [:repeatDigit |
number := digit.
12 timesRepeat: [
#(1 60 3600 86400 604800) with:
#('seconds' 'minutes' 'hours' 'days' 'weeks') do:
[:unit :units |
party := birth + (number * unit).
(party between: start and: end) ifTrue: [
parties add: (Date fromSeconds: party) ->
(number asString, ' ', units, ' since ', birthday asString)]].
number := number * 10.
repeatDigit ifTrue: [number := number + digit]]]]].
Transcript clear.
parties do: [:each | Transcript show: each asString; cr].
- Bert -
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners