Dates

Dan Ingalls Dan at SqueakLand.org
Fri Jan 28 22:05:39 UTC 2005


Hi, Brent -

>The ANSI compatible DateAndTime and Duration classes were introduced in 3.7.
>
>I am the developer and maintainer of that portion of the image.
>
>If you can reply to me next week, preferably with a DateTest unit test illustrating the desired behaviour I will eagerly look into it and motivate for any fixes to be imcluded in the 3.9 image.

While you are at it, I just ported my weather station app forward from 3.6 tp 3.8 and found that all display and scrolling was suddenly 4x slower.  I tracked this down to a couple of Date and Time operations that are slow in 3.8, such as addDays, and dayOfYear.  By restoring my former logic, I sped these up (dayOfYear by a factor of 50!), and everything went back to behaving normally.

Below is my code for dayOfYear in case you find it useful.  I can also send you a simple method for <Date>daylightSavingsInEffectAtStandardHour: which can be very useful.

	- Dan

--------------------------
dayOfYear

    | monthStart |
    true ifTrue:
            ["This code is 50x faster..."
            ^ self dayMonthYearDo:
                [:d :m :y |
                monthStart _ #(1 32 60 91 121 152 182 213 244 274 305 335) at: m.
                (m > 2 and: [Year isLeapYear: y])
                    ifTrue: [monthStart + d]
                    ifFalse: [monthStart + d - 1]]]
        ifFalse:
            ["Here is the ANSI code..."
            ^ jdn - (Year year: self year) start julianDayNumber + 1]
	



More information about the Squeak-dev mailing list