<?xml version="1.0"?>

<st-source>
<time-stamp>From Squeak3.7beta on 19 May 2004 at 5:48:55 pm</time-stamp>


<name-space>
<name>Squeak</name>
<environment>Smalltalk</environment>
<private>false</private>
<imports>
private Smalltalk.*
</imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</name-space>

<class>
<name>ChronologyConstants</name>
<environment>Squeak</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>seconds offset jdn nanos</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>


<shared-variable>
<name>SecondsInMinute</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>SecondsInDay</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>SqueakEpoch</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>NanosInSecond</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>NanosInMillisecond</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>DayNames</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>MonthNames</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>SecondsInHour</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>


<shared-variable>
<name>DaysInMonth</name>
<environment>Squeak</environment>
<private>false</private>
<constant>false</constant>
<category>global variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>

<class>
<name>DateAndTime</name>
<environment>Squeak</environment>
<super>Core.Magnitude</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>seconds offset jdn nanos</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>


<shared-variable>
<name>LocalTimeZone</name>
<environment>Squeak.DateAndTime</environment>
<private>false</private>
<constant>false</constant>
<category>class variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>

<class>
<name>DateAndTimeEpochTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>aDateAndTime aDuration aTimeZone localTimeZoneToRestore</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>DateAndTimeLeapTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>aDateAndTime aDuration aTimeZone localTimeZoneToRestore</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>DateAndTimeTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>DateTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>date aDate aTime</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>Duration</name>
<environment>Squeak</environment>
<super>Core.Magnitude</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nanos seconds</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>DurationTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>aDuration</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>MonthTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>month</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>ScheduleTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>firstEvent aSchedule</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>Stopwatch</name>
<environment>Squeak</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>timespans state</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>StopwatchTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>aStopwatch aDelay</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>Time</name>
<environment>Squeak</environment>
<super>Core.Magnitude</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>seconds nanos</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>TimeStamp</name>
<environment>Squeak</environment>
<super>Squeak.DateAndTime</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>TimeStampTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>timestamp aTimeStamp</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>TimeTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>time aTime</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>TimeZone</name>
<environment>Squeak</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>offset abbreviation name</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>Timespan</name>
<environment>Squeak</environment>
<super>Core.Magnitude</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>start duration</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>Date</name>
<environment>Squeak</environment>
<super>Squeak.Timespan</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>Month</name>
<environment>Squeak</environment>
<super>Squeak.Timespan</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>Schedule</name>
<environment>Squeak</environment>
<super>Squeak.Timespan</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>schedule</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>TimespanDoSpanAYearTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>aTimespan aDuration aDate</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>TimespanDoTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>aTimespan aDuration aDate</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>TimespanTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>timespan aTimespan anOverlappingTimespan anIncludedTimespan aDisjointTimespan aDay aWeek dec31 jan01 jan08</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>Week</name>
<environment>Squeak</environment>
<super>Squeak.Timespan</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>


<shared-variable>
<name>StartDay</name>
<environment>Squeak.Week</environment>
<private>false</private>
<constant>false</constant>
<category>class variables</category>
<initializer>nil</initializer>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</shared-variable>

<class>
<name>WeekTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>week</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>Year</name>
<environment>Squeak</environment>
<super>Squeak.Timespan</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak</category>
<attributes>
<package>Squeak-Chronology</package>
</attributes>
</class>

<class>
<name>YearMonthWeekTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>restoredStartDay</inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>

<class>
<name>YearTest</name>
<environment>Squeak</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Squeak-Tests</category>
<attributes>
<package>Squeak-Chronology-Tests</package>
</attributes>
</class>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">addDays: dayCount 

	^ (self asDateAndTime + (dayCount days)) asDate</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>printing</category>
<body package="Squeak">storeOn: aStream

	aStream print: self printString; nextPutAll: ' asDate'</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>printing</category>
<body package="Squeak">printOn: aStream format: formatArray 
	"Print a description of the receiver on aStream using the format 
	denoted the argument, formatArray: 
	
		#(item item item sep monthfmt yearfmt twoDigits) 
	
		items: 1=day 2=month 3=year will appear in the order given, 
	
		separated by sep which is eaither an ascii code or character. 
	
		monthFmt: 1=09 2=Sep 3=September 
	
		yearFmt: 1=1996 2=96 
	
		digits: (missing or)1=9 2=09. 
	
	See the examples in printOn: and mmddyy"
	| gregorian twoDigits element monthFormat |
	gregorian := self dayMonthYearDo: [ :d :m :y | Array with: d with: m with: y ].
	twoDigits := formatArray size &gt; 6 and: [(formatArray at: 7) &gt; 1].
	1 to: 3 do: 
		[ :i | 
			element := formatArray at: i.
			element = 1
				ifTrue: [twoDigits
						ifTrue: [aStream
								nextPutAll: (gregorian first asString
										padded: #left
										to: 2
										with: $0)]
						ifFalse: [gregorian first printOn: aStream]].
			element = 2
				ifTrue: [monthFormat := formatArray at: 5.
					monthFormat = 1
						ifTrue: [twoDigits
								ifTrue: [aStream
										nextPutAll: (gregorian middle asString
												padded: #left
												to: 2
												with: $0)]
								ifFalse: [gregorian middle printOn: aStream]].
					monthFormat = 2
						ifTrue: [aStream
								nextPutAll: ((Month nameOfMonth: gregorian middle)
										copyFrom: 1
										to: 3)].
					monthFormat = 3
						ifTrue: [aStream
								nextPutAll: (Month nameOfMonth: gregorian middle)]].
			element = 3
				ifTrue: [(formatArray at: 6)
							= 1
						ifTrue: [gregorian last printOn: aStream]
						ifFalse: [aStream
								nextPutAll: ((gregorian last \\ 100) asString
										padded: #left
										to: 2
										with: $0)]].
			i &lt; 3
				ifTrue: [(formatArray at: 4)
							~= 0
						ifTrue: [aStream nextPut: (formatArray at: 4) asCharacter]]]
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">subtractDate: aDate 
	"Answer the number of days between self and aDate"

	^ (self start - aDate asDateAndTime) days</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">daylightSavingsInEffect
	"Return true if DST is observed at or after 2am on this day"

	self deprecated: 'Deprecated'.

	self dayMonthYearDo: 
		[ :day :month :year |
		(month &lt; 4 or: [month &gt; 10]) ifTrue: [^ false].  "False November through March"
		(month &gt; 4 and: [month &lt; 10]) ifTrue: [^ true].  "True May through September"
		month = 4
		ifTrue:	["It's April -- true on first Sunday or later"
				day &gt;= 7 ifTrue: [^ true].  "Must be after"
				^ day &gt; (self weekdayIndex \\ 7)]
		ifFalse: ["It's October -- false on last Sunday or later"
				day &lt;= 24 ifTrue: [^ true].  "Must be before"
				^ day &lt;= (24 + (self weekdayIndex \\ 7))]]</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>squeak protocol</category>
<body package="Squeak">dayMonthYearDo: aBlock 
	"Supply integers for day, month and year to aBlock and return the result"

	^ start dayMonthYearDo: aBlock</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">leap
	"Answer whether the receiver's year is a leap year."

	^ start isLeapYear ifTrue: [1] ifFalse: [0].</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">julianDayNumber: anInteger
	"Set the number of days elapsed since midnight GMT on January 1st, 4713 B.C."

	self deprecated: 'Obsolete'.

</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">week

	^ self 
		deprecated: 'Use #asWeek';
		asWeek</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">asJulianDayNumber

	^ self 
		deprecated: 'Use #julianDayNumber';
		julianDayNumber</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">mmddyy
	"Please use mmddyyyy instead, so dates in 2000 will be unambiguous"

	^ self 
		deprecated: 'Use #mmddyyyy';
		printFormat: #(2 1 3 $/ 1 2)
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>squeak protocol</category>
<body package="Squeak">month
	^ self asMonth</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">firstDayOfMonthIndex: monthIndex 

	^ self
		deprecated: 'Obsolete'
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">day: dayInteger year: yearInteger

	^ self
		deprecated: 'Obsolete'
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>printing</category>
<body package="Squeak">printFormat: formatArray 
	"Answer a String describing the receiver using the argument formatArray."

	| aStream |
	aStream := WriteStream on: (String new: 16).
	self printOn: aStream format: formatArray.
	^ aStream contents</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>printing</category>
<body package="Squeak">yyyymmdd
	"Format the date in ISO 8601 standard like '2002-10-22'."

	^ self printFormat: #(3 2 1 $- 1 1 2)</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">weekdayIndex
	"Sunday=1, ... , Saturday=7"

	^ self dayOfWeek</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">weekday
	"Answer the name of the day of the week on which the receiver falls."

	^ self dayOfWeekName</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">daylightSavingsInEffectAtStandardHour: hour
	"Return true if DST is observed at this very hour (standard time)"
	"Note: this *should* be the kernel method, and daylightSavingsInEffect
		should simply be self daylightSavingsInEffectAtHour: 3"

	self deprecated: 'Deprecated'.

	self daylightSavingsInEffect
		ifTrue: [^ (self addDays: -1) daylightSavingsInEffect or: [hour &gt;= 2]]
		ifFalse: [^ (self addDays: -1) daylightSavingsInEffect and: [hour &lt; 1]]</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDate

	^ self</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">previous: dayName 
	"Answer the previous date whose weekday name is dayName."

	| days |
	days := 7 + self weekdayIndex - (self class dayOfWeek: dayName) \\ 7.
	days = 0 ifTrue: [ days := 7 ].
	^ self subtractDays: days
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>converting</category>
<body package="Squeak">asTimeStamp
	"Answer the receiver as a TimeStamp at midnight."

	^TimeStamp date: self time: (Time fromSeconds: 0)</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">asGregorian
	"Return an array of integers #(dd mm yyyy)"

	^ self
		deprecated: 'Use #dayMonthYearDo:';
		dayMonthYearDo: [ :d :m :y | Array with: d with: m with: y ] 
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">asSeconds
	"Answer the seconds since the Squeak epoch: 1 January 1901"

	^ start asSeconds</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>printing</category>
<body package="Squeak">printOn: aStream

	self printOn: aStream format: #(1 2 3 $  3 1 )</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>deprecated</category>
<body package="Squeak">uniqueDateStringBetween: aStart and: anEnd
	"Return a String, with just enough information to distinguish it from other dates in the range."

	"later, be more sophisticated"
	self deprecated: 'Deprecated'.

	aStart year + 1 &gt;= anEnd year ifFalse: [^ self printFormat: #(1 2 3 $  3 1)].	"full"
	aStart week next &gt;= anEnd week ifFalse: [^ self printFormat: #(2 1 9 $  3 1)]. "May 6"
	^ self weekday
</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>printing</category>
<body package="Squeak">mmddyyyy
	"Answer the receiver rendered in standard U.S.A format mm/dd/yyyy.
	Note that the name here is slightly misleading -- the month and day numbers don't show leading zeros, 
	so that for example February 1 1996 is 2/1/96"


	^ self printFormat: #(2 1 3 $/ 1 1)</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>smalltalk-80</category>
<body package="Squeak">subtractDays: dayCount 

	^ (self asDateAndTime - (dayCount days)) asDate</body>
</methods>
<methods>
<class-id>Squeak.Date</class-id>
<category>squeak protocol</category>
<body package="Squeak">monthIndex
	^ super month</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">seconds

	^ self second</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">hour

	^ self hour24
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">printHMSOn: aStream
	"Print just hh:mm:ss"
	aStream
		nextPutAll: (self hour asString padded: #left to: 2 with: $0);
		nextPut: $:;
		nextPutAll: (self minute asString padded: #left to: 2 with: $0);
		nextPut: $:;
		nextPutAll: (self second asString padded: #left to: 2 with: $0).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">dayMonthYearDo: aBlock
	"Evaluation the block with three arguments: day month, year."

	| l n i j dd mm yyyy |
	l := jdn + 68569.
	n := 4 * l // 146097.
	l := l - (146097 * n + 3 // 4).
	i := 4000 * (l + 1) // 1461001.
	l := l - (1461 * i // 4) + 31.
	j := 80 * l // 2447.
	dd := l - (2447 * j // 80).
	l := j // 11.
	mm := j + 2 - (12 * l).
	yyyy := 100 * (n - 49) + i + l.

	^ aBlock
		value: dd
		value: mm
		value: yyyy.</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDateAndTime

	^ self
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">timeZoneAbbreviation

	^ self class localTimeZone abbreviation
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDuration

	"Answer the duration since midnight"

	^ Duration seconds: seconds nanoSeconds: nanos
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">isLeapYear


	^ Year isLeapYear: self year.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">printYMDOn: aStream withLeadingSpace: printLeadingSpaceToo
	"Print just the year, month, and day on aStream.

	If printLeadingSpaceToo is true, then print as:
		' YYYY-MM-DD' (if the year is positive) or '-YYYY-MM-DD' (if the year is negative)
	otherwise print as:
		'YYYY-MM-DD' or '-YYYY-MM-DD' "

	| year month day |
	self dayMonthYearDo: [ :d :m :y | year := y. month := m. day := d ].
	year negative
		ifTrue: [ aStream nextPut: $- ]
		ifFalse: [ printLeadingSpaceToo ifTrue: [ aStream space ]].
	aStream
		nextPutAll: (year abs asString padded: #left to: 4 with: $0);
		nextPut: $-;
		nextPutAll: (month asString padded: #left to: 2 with: $0);
		nextPut: $-;
		nextPutAll: (day asString padded: #left to: 2 with: $0)
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">= comparand
	"comparand conforms to protocol DateAndTime,
	or can be converted into something that conforms."
	| comparandAsDateAndTime |
	self == comparand
		ifTrue: [^ true].
	[comparandAsDateAndTime := comparand asDateAndTime]
		on: MessageNotUnderstood
		do: [^ false].
	^ self offset = comparandAsDateAndTime offset
		ifTrue: [self ticks = comparandAsDateAndTime ticks]
		ifFalse: [self asUTC ticks = comparandAsDateAndTime asUTC ticks]
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">printYMDOn: aStream
	"Print just YYYY-MM-DD part.
	If the year is negative, prints out '-YYYY-MM-DD'."

	^self printYMDOn: aStream withLeadingSpace: false.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">offset

	^ offset
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asWeek

	^ Week starting: self 
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInYear

	"Answer the number of days in the year represented by the receiver."

	^ self asYear daysInYear
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInMonth
	"Answer the number of days in the month represented by the receiver."


	^ self asMonth daysInMonth
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfWeek

	"Sunday=1, ... , Saturday=7"

	^ (jdn + 1 rem: 7) + 1</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">utcOffset: anOffset

	"Answer a &lt;DateAndTime&gt; equivalent to the receiver but offset from UTC by anOffset"

	| equiv |
	equiv := self + (anOffset asDuration - self offset).
	^ equiv ticks: (equiv ticks) offset: anOffset asDuration; yourself
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">to: anEnd
	"Answer a Timespan. anEnd conforms to protocol DateAndTime or protocol Timespan"

	^ Timespan starting: self ending: (anEnd asDateAndTime).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">to: anEnd by: aDuration do: aBlock
	"Answer a Timespan. anEnd conforms to protocol DateAndTime or protocol Timespan"

	^ (self to: anEnd by: aDuration) scheduleDo: aBlock
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTimeStamp

	^ self as: TimeStamp</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">hours

	^ self hour</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">- operand
	"operand conforms to protocol DateAndTime or protocol Duration"

	^ (operand respondsTo: #asDateAndTime)
		ifTrue: 
			[ | lticks rticks |
			lticks := self asLocal ticks.
	
		rticks := operand asDateAndTime asLocal ticks.
			Duration
 				seconds: (SecondsInDay *(lticks first - rticks first)) + 
							(lticks second - rticks second)
 				nanoSeconds: (lticks third - rticks third) ]
	
	ifFalse:
		
 	[ self + (operand negated) ].
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">day

	^ self dayOfYear</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">nanoSecond


	^ nanos
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">&lt; comparand
	"comparand conforms to protocol DateAndTime,
	or can be converted into something that conforms."
	| lticks rticks comparandAsDateAndTime |
	comparandAsDateAndTime := comparand asDateAndTime.
	offset = comparandAsDateAndTime offset
		ifTrue: [lticks := self ticks.
			rticks := comparandAsDateAndTime ticks]
		ifFalse: [lticks := self asUTC ticks.
			rticks := comparandAsDateAndTime asUTC ticks].
	^ lticks first &lt; rticks first
		or: [lticks first &gt; rticks first
				ifTrue: [false]
				ifFalse: [lticks second &lt; rticks second
						or: [lticks second &gt; rticks second
								ifTrue: [false]
								ifFalse: [lticks third &lt; rticks third]]]]
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">firstDayOfMonth

	^ self asMonth start day</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream withLeadingSpace: printLeadingSpaceToo
	"Print as per ISO 8601 sections 5.3.3 and 5.4.1.
	If printLeadingSpaceToo is false, prints either:
		'YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for positive years) or '-YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for negative years)
	If printLeadingSpaceToo is true, prints either:
		' YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for positive years) or '-YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for negative years)
	"

	self printYMDOn: aStream withLeadingSpace: printLeadingSpaceToo.
	aStream nextPut: $T.
	self printHMSOn: aStream.
	self nanoSecond ~= 0 ifTrue:
		[ | z ps |
		ps := self nanoSecond printString padded: #left to: 9 with: $0.
		z := ps findLast: [ :c | c asciiValue &gt; $0 asciiValue ].
		ps from: 1 to: z do: [ :c | aStream nextPut: c ] ].
	aStream
		nextPut: (offset positive ifTrue: [$+] ifFalse: [$-]);
		nextPutAll: (offset hours abs asString padded: #left to: 2 with: $0);
		nextPut: $:;
		nextPutAll: (offset minutes abs asString padded: #left to: 2 with: $0).
	offset seconds = 0 ifFalse:
		[ aStream
			nextPut: $:;
			nextPutAll: (offset seconds abs truncated asString) ].
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">monthAbbreviation


	^ self monthName copyFrom: 1 to: 3
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asYear

	^ Year starting: self
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asMonth

	^ Month starting: self
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">monthName


	^ Month nameOfMonth: self month
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream
	"Print as per ISO 8601 sections 5.3.3 and 5.4.1.
	Prints either:
		'YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for positive years) or '-YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for negative years)"

	^self printOn: aStream withLeadingSpace: false
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">asSeconds
	"Return the number of seconds since the Squeak epoch"

	^ (self - (self class epoch)) asSeconds
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">julianDayNumber


	^ jdn
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">meridianAbbreviation

	^ self asTime meridianAbbreviation</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysLeftInYear
	"Answer the number of days in the year after the date of the receiver."

	^ self daysInYear - self dayOfYear
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">offset: anOffset

	"Answer a &lt;DateAndTime&gt; equivalent to the receiver but with its local time 
	being offset from UTC by offset."

	^ self class basicNew 
		ticks: self ticks offset: anOffset asDuration;
		yourself
		</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">asLocal
	

	^ (self offset = self class localOffset)

		ifTrue: [self]
		ifFalse: [self utcOffset: self class localOffset]
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">monthIndex


	^ self month
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfWeekName

	^ Week nameOfDay: self dayOfWeek
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfYear


	^ jdn - (Year year: self year) start julianDayNumber + 1
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>smalltalk-80</category>
<body package="Squeak">minutes

	^ self minute</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfMonth
	"Answer which day of the month is represented by the receiver."

	^ self
		dayMonthYearDo: [ :d :m :y | d ]</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>private</category>
<body package="Squeak">ticks: ticks offset: utcOffset
	"ticks is {julianDayNumber. secondCount. nanoSeconds}"
	| normalize |

	normalize := [ :i :base | | tick div quo rem |
		tick := ticks at: i.
		div := tick digitDiv: base neg: tick negative.
		quo := div first normalize.
		rem := div second normalize.
		rem &lt; 0 ifTrue: [ quo := quo - 1. rem := base + rem ].
		ticks at: (i-1) put: ((ticks at: i-1) + quo).
		ticks at: i put: rem ].

	normalize value: 3 value: NanosInSecond.
	normalize value: 2 value: SecondsInDay.

	jdn	:= ticks first.
	seconds	:= ticks second.
	nanos := ticks third.
	offset := utcOffset.


</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">year
	^ self
		dayMonthYearDo: [ :d :m :y | y ]</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">month

	^ self 
		dayMonthYearDo: [ :d :m :y | m ].</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">noon
	"Answer a DateAndTime starting at noon"

	^ self dayMonthYearDo: 
		[ :d :m :y | self class year: y month: m day: d hour: 12 minute: 0 second: 0 ]</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">hour24


	^ (Duration seconds: seconds) hours
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">to: anEnd by: aDuration
	"Answer a Timespan. anEnd conforms to protocol DateAndTime or protocol Timespan"

	^ (Schedule starting: self ending: (anEnd asDateAndTime))
		schedule: (Array with: aDuration asDuration);
		yourself.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">duration

	^ Duration zero
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">+ operand
	"operand conforms to protocol Duration"

	| ticks |
 	ticks := self ticks + (operand asDuration ticks) .

	^ self class basicNew
		ticks: ticks
		offset: self offset; 
		yourself.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">minute


	^ (Duration seconds: seconds) minutes
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTime


	^ Time seconds: seconds nanoSeconds: nanos</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">hash

	^ self asUTC ticks hash
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asNanoSeconds
	"Answer the number of nanoseconds since midnight"

	^ self asDuration asNanoSeconds
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">timeZoneName

	^ self class localTimeZone name
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfWeekAbbreviation

	^ self dayOfWeekName copyFrom: 1 to: 3</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDate


	^ Date starting: self
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">second


	^ (Duration seconds: seconds) seconds
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">middleOf: aDuration
	"Return a Timespan where the receiver is the middle of the Duration"

	| duration |
	duration := aDuration asDuration.

	^ Timespan starting: (self - (duration / 2)) duration: duration.
		</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>squeak protocol</category>
<body package="Squeak">midnight
	"Answer a DateAndTime starting at midnight local time"

	^ self
		dayMonthYearDo: [ :d :m :y | self class year: y month: m day: d ]</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">asUTC


	^ self utcOffset: 0</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>private</category>
<body package="Squeak">ticks
	"Private - answer an array with our instance variables. Assumed to be UTC "

	^ Array with: jdn with: seconds with: nanos
.</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime</class-id>
<category>ansi protocol</category>
<body package="Squeak">hour12
	"Answer an &lt;integer&gt; between 1 and 12, inclusive, representing the hour 
	of the day in the 12-hour clock of the local time of the receiver."
	^ self hour24 - 1 \\ 12 + 1</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUtcOffset
     self assert: (aDateAndTime utcOffset: '0:12:00:00') =  '1901-01-01T12:00:00+12:00'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNow
	self deny: aDateAndTime =  (DateAndTime now).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinute
	self assert: aDateAndTime minute =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfWeek
	self assert: aDateAndTime dayOfWeek  = 3.
	self assert: aDateAndTime dayOfWeekAbbreviation = 'Tue'.
	self assert: aDateAndTime dayOfWeekName = 'Tuesday'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTime
	self assert: aDateAndTime asTime =  Time midnight.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayMonthYearDo
	|iterations|
	iterations := 0.
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  iterations := iterations + 1])  = 1.
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  eachYear])  = 1901.
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  eachMonth]) = 1.
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  eachDay]) = 1.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLessThan
	self assert: aDateAndTime  &lt; (aDateAndTime + '1:00:00:00').
	self assert: aDateAndTime + -1 &lt; aDateAndTime.
	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSecond
	self assert: aDateAndTime second =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysLeftInYear
	self assert: aDateAndTime daysLeftInYear  = 364.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDate
	self assert: aDateAndTime asDate =   'January 1, 1901' asDate.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDay
	self assert: aDateAndTime day =   DateAndTime new day
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testJulianDayNumber
	self assert: aDateAndTime =  (DateAndTime julianDayNumber: 2415386).
	self assert: aDateAndTime julianDayNumber = 2415386.</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMidnight
	self assert: aDateAndTime midnight =  aDateAndTime
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfMonth
	self assert: aDateAndTime dayOfMonth  = 1.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsMonth
	self assert: aDateAndTime asMonth = (Month month: 'January' year: 1901). 
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsSeconds
	self assert: aDateAndTime asSeconds =  0 asDuration asSeconds
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDateAndTime
	self assert: aDateAndTime asDateAndTime =  aDateAndTime
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testToday
	self deny: aDateAndTime =  (DateAndTime today).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDateTime
	self assert: aDateAndTime =  (DateAndTime date: '01-01-1901' asDate time: '00:00:00' asTime)
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNoon
	self assert: aDateAndTime noon =  '1901-01-01T12:00:00+00:00'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testToBy
	self assert: (aDateAndTime to: aDateAndTime + 10 days by: 5 days) = 
				(DateAndTime new to: DateAndTime new + 10 days by: 5 days ) 
	"MessageNotUnderstood: UndefinedObject&gt;&gt;starting:ending:  where UndefinedObject is Timespan "</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNanoSecond
	self assert: aDateAndTime nanoSecond =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYear
	self assert: aDateAndTime year = 1901.

	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinutes
	self assert: aDateAndTime minutes = 0
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHour12
	self assert: aDateAndTime hour12  = DateAndTime new hour12.
	self assert: aDateAndTime hour12  = 12
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMiddleOf
	self assert: (aDateAndTime middleOf: '2:00:00:00' asDuration) = 
	 (Timespan starting: '12-31-1900' asDate duration: 2 days).
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfYear
	self assert: aDateAndTime dayOfYear  = 1.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testToByDo
	"self assert: (aDateAndTime to: aDateAndTime + 10 days by: 5 days do: []) =  "
	"MessageNotUnderstood: UndefinedObject&gt;&gt;starting:ending:  where UndefinedObject is Timespan "</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTo
	self assert: (aDateAndTime to: aDateAndTime) = (DateAndTime new to: DateAndTime new) 
	"MessageNotUnderstood: UndefinedObject&gt;&gt;starting:ending:  where UndefinedObject is Timespan "</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsUTC
	self assert: aDateAndTime asUTC =  aDateAndTime
          </body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHash
	self assert: aDateAndTime hash =    DateAndTime new hash.
	self assert: aDateAndTime hash =    199296261
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTicks
	self assert: aDateAndTime ticks =  (DateAndTime julianDayNumber: 2415386) ticks.
	self assert: aDateAndTime ticks = #(2415386 0 0)</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMeridianAbbreviation
	self assert: aDateAndTime meridianAbbreviation = 'AM'.

	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsWeek
	self assert: aDateAndTime asWeek = (Week starting: '12-31-1900' asDate). 

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testOffset
	self assert: aDateAndTime offset =  '0:00:00:00' asDuration.
     self assert: (aDateAndTime offset: '0:12:00:00') =  '1901-01-01T00:00:00+12:00'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearDay
	self assert: aDateAndTime =  (DateAndTime year: 1901 day: 1).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFromSeconds
	self assert: aDateAndTime =  (DateAndTime fromSeconds: 0).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearMonthDayHourMinuteSecond
	self assert: aDateAndTime =  (DateAndTime year: 1901 month: 1 day: 1 hour: 0 minute: 0 second: 0).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFirstDayOfMonth
	self assert: aDateAndTime firstDayOfMonth =   1
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNew
	self assert: aDateAndTime =  (DateAndTime new).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsLocal
	self assert: aDateAndTime asLocal =  aDateAndTime.
	self assert: aDateAndTime asLocal = (aDateAndTime utcOffset: aDateAndTime class localOffset)
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTicksOffset
	self assert: aDateAndTime =  (aDateAndTime ticks:  #(2415386 0 0) offset: DateAndTime localOffset).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinus
	self assert: aDateAndTime - aDateAndTime =  '0:00:00:00' asDuration.
	self assert: aDateAndTime - '0:00:00:00' asDuration = aDateAndTime.
	self assert: aDateAndTime - aDuration =  (DateAndTime year: 1900 month: 12 day: 30 hour: 21 minute: 56 second: 55 nanoSecond: 999999995 offset: 0 hours ).
	" I believe this Failure is a bug in the nanosecond part of (DateAndTime &gt;&gt; year:month:day:hour:minute:second:nanoSecond:offset:)" </body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>running</category>
<body package="Squeak-Tests">tearDown
     DateAndTime localTimeZone: localTimeZoneToRestore.
     "wish I could remove the time zones I added earlier, tut there is no method for that"
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: '1901-01-01T00:00:00+00:00'.
	rw := ReadWriteStream on: ''.
	aDateAndTime printOn: rw.
	self assert: rw contents = cs contents.
	cs  := ReadStream on: 'a TimeZone(ETZ)'.
	rw := ReadWriteStream on: ''.
	aTimeZone printOn:  rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHour
	self assert: aDateAndTime hour =    aDateAndTime hour24.
	self assert: aDateAndTime hour =    0.
	self assert: aDateAndTime hour =    aDateAndTime hours
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsYear
	self assert: aDateAndTime asYear =   (Year starting: '01-01-1901' asDate). 
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYesterday
	self deny: aDateAndTime =  (DateAndTime yesterday).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFromString
	self assert: aDateAndTime =  (DateAndTime fromString: ' 1901-01-01T00:00:00+00:00').
	self assert: aDateAndTime =  (DateAndTime fromString: ' 1901-01-01T00:00:00').
	self assert: aDateAndTime =  (DateAndTime fromString: ' 1901-01-01T00:00').
	self assert: aDateAndTime =  (DateAndTime fromString: ' 1901-01-01T00:00:00+00:00').
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInMonth
	self assert: aDateAndTime daysInMonth  = 31.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDuration
	self assert: aDateAndTime asDuration =  0 asDuration
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIsLeapYear
	self deny: aDateAndTime isLeapYear
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTimeStamp
	self assert: aDateAndTime asTimeStamp =  TimeStamp new.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTommorrow
	self assert: (DateAndTime today + 24 hours) =  (DateAndTime tomorrow).
	self deny: aDateAndTime =  (DateAndTime tomorrow).
     "MessageNotUnderstood: Date class&gt;&gt;starting:"</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSeconds
	self assert: aDateAndTime seconds =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMonth
	self assert: aDateAndTime month  = 1.
	self assert: aDateAndTime monthAbbreviation = 'Jan'.
	self assert: aDateAndTime monthName = 'January'.
	self assert: aDateAndTime monthIndex = 1.</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearDayHourMinuteSecond
	self assert: aDateAndTime =  (DateAndTime year: 1901 day: 1 hour: 0 minute: 0 second: 0).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testtimeZone
	self assert: aDateAndTime timeZoneName	= 'Universal Time'.
	self assert: aDateAndTime timeZoneAbbreviation	=  'UTC'

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testEpoch
	self assert: aDateAndTime =  '1901-01-01T00:00:00+00:00'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
     localTimeZoneToRestore := DateAndTime localTimeZone.
	aDateAndTime :=  DateAndTime localTimeZone: TimeZone default; epoch.
	aTimeZone := TimeZone offset: (Duration minutes: 135) name: 'Epoch Test Time Zone' abbreviation: 'ETZ'.
	aDuration := Duration days: 1 hours: 2 minutes: 3 seconds: 4 nanoSeconds: 5 </body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInYear
	self assert: aDateAndTime daysInYear  = 365.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPlus
	self assert: aDateAndTime + '0:00:00:00' = aDateAndTime.
	self assert: aDateAndTime + 0 = aDateAndTime.
	self assert: aDateAndTime + aDuration = (DateAndTime year: 1901 month: 1 day: 2 hour: 2 minute: 3 second: 4 nanoSecond: 5 offset: 0 hours )
	" I believe this is a bug in the nanosecond part of (DateAndTime &gt;&gt; year:month:day:hour:minute:second:nanoSecond:offset:)"
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearMonthDayHourMinuteSecondNanosSecondOffset
	self assert: aDateAndTime =  (DateAndTime year: 1901 month: 1 day: 1 hour: 0 minute: 0 second: 0 nanoSecond: 0 offset:0 hours ).
	self assert: ((DateAndTime year: 1 month: 1 day: 1 hour: 0 minute: 0 second: 0 nanoSecond: 0 offset: 0 hours ) +
				(Duration days: 1 hours: 2 minutes: 3 seconds: 4  nanoSeconds: 5) ) =  	
				(DateAndTime year: 1 month: 1 day: 2 hour: 2 minute: 3 second: 4 nanoSecond: 5 offset: 0 hours ) 
	" I believe this is a bug in the nanosecond part of (DateAndTime &gt;&gt; year:month:day:hour:minute:second:nanoSecond:offset:)"" I believe this is a bug in the nanosecond part of (DateAndTime &gt;&gt; year:month:day:hour:minute:second:nanoSecond:offset:)"   
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsNanoSeconds
	self assert: aDateAndTime asNanoSeconds =  0 asDuration asNanoSeconds
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testCurrent
	self deny: aDateAndTime =  (DateAndTime current).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearMonthDay
	self assert: aDateAndTime =  (DateAndTime year: 1901 month: 1 day: 1).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeEpochTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDuration
	self assert: aDateAndTime duration  = 0 asDuration.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUtcOffset
     self assert: (aDateAndTime utcOffset: '0:02:00:00') =  '2004-02-29T13:33:00+02:00'.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinute
	self assert: aDateAndTime minute =  33

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTime
	self assert: aDateAndTime asTime = (Time hour: 13 minute: 33 second: 0)
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayMonthYearDo
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  eachYear])  = 2004.
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  eachMonth]) = 2.
	self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear |  eachDay]) = 29.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfWeek
	self assert: aDateAndTime dayOfWeek  = 1.
	self assert: aDateAndTime dayOfWeekAbbreviation = 'Sun'.
	self assert: aDateAndTime dayOfWeekName = 'Sunday'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLessThan
	self assert: aDateAndTime  &lt; (aDateAndTime + '1:00:00:00').
	self assert: aDateAndTime + -1 &lt; aDateAndTime.
	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSecond
	self assert: aDateAndTime second =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysLeftInYear
	self assert: aDateAndTime daysLeftInYear  = 306.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDay
	self assert: aDateAndTime day =   60. 
	self deny: aDateAndTime day =   29 </body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDate
	self assert: aDateAndTime asDate =   'February 29, 2004' asDate.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMidnight
	self assert: aDateAndTime midnight =  '2004-02-29T00:00:00+00:00'.
	self deny: aDateAndTime midnight =  '2004-02-29T00:00:00+02:00'
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfMonth
	self assert: aDateAndTime dayOfMonth  = 29.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsMonth
	self assert: aDateAndTime asMonth = (Month month: 'February' year: 2004).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsSeconds
	self assert: aDuration asSeconds =  48780.
	self assert: aDateAndTime asSeconds =  3255507180
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHour12
	self assert: aDateAndTime hour12  =   1.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNoon
	self assert: aDateAndTime noon =  '2004-02-29T12:00:00+00:00'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYear
	self assert: aDateAndTime year = 2004.

	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfYear
	self assert: aDateAndTime dayOfYear  = 60.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNanoSecond
	self assert: aDateAndTime nanoSecond =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinutes
	self assert: aDateAndTime minutes = 33
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMiddleOf
	self assert: (aDateAndTime middleOf: aDuration)  = 
	 (Timespan starting: (DateAndTime year: 2004 month: 2 day: 29 hour: 6 minute: 46 second: 30 offset: 2 hours)
	duration: (Duration days: 0 hours: 13 minutes: 33 seconds: 0 nanoSeconds: 0 ))
	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsUTC
	self assert: aDateAndTime asUTC =  aDateAndTime

          </body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHash
	self assert: aDateAndTime hash =     29855404
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTicks
	self assert: aDateAndTime ticks =  ((DateAndTime julianDayNumber: 2453065) + 48780 seconds) ticks.
	self assert: aDateAndTime ticks =  #(2453065 48780 0)</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testOffset
	self assert: aDateAndTime offset =  '0:02:00:00' asDuration.
     self assert: (aDateAndTime offset: '0:12:00:00') =  '2004-02-29T13:33:00+12:00'.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsWeek
	self assert: aDateAndTime asWeek =    (Week starting: '02-29-2004' asDate).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearMonthDayHourMinuteSecond
	self assert: aDateAndTime =  ((DateAndTime year: 2004 month: 2 day: 29 hour: 13 minute: 33 second: 0) offset: 2 hours).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMeridianAbbreviation
	self assert: aDateAndTime meridianAbbreviation = 'PM'.

	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFirstDayOfMonth
	self deny: aDateAndTime firstDayOfMonth =  1.
	self assert: aDateAndTime firstDayOfMonth = 32
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsLocal
	self assert: aDateAndTime asLocal =  aDateAndTime.
	self assert: aDateAndTime asLocal = (aDateAndTime utcOffset: aDateAndTime class localOffset)

	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTicksOffset
	self assert: aDateAndTime =  (aDateAndTime ticks:  #(2453065 48780 0) offset: DateAndTime localOffset).

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>running</category>
<body package="Squeak-Tests">tearDown
     DateAndTime localTimeZone: localTimeZoneToRestore.
     "wish I could remove the time zones I added earlier, tut there is no method for that"
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHour
	self assert: aDateAndTime hour =    aDateAndTime hour24.
	self assert: aDateAndTime hour =    13.
	self assert: aDateAndTime hour =    aDateAndTime hours
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: '2004-02-29T13:33:00+02:00'.
	rw := ReadWriteStream on: ''.
	aDateAndTime printOn: rw.
	self assert: rw contents = cs contents.
	cs  := ReadStream on: 'a TimeZone(UTC)'.
	rw := ReadWriteStream on: ''.
	aTimeZone printOn:  rw.
	self assert: rw contents = cs contents	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsYear
	self assert: aDateAndTime asYear =   (Year starting: '02-29-2004' asDate).  
	self deny: aDateAndTime asYear =   (Year starting: '01-01-2004' asDate)  
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInMonth
	self assert: aDateAndTime daysInMonth  = 29.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFromString
	self assert: aDateAndTime =  (DateAndTime fromString: ' 2004-02-29T13:33:00+02:00').

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDuration
	self assert: aDateAndTime asDuration =  aDuration
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIsLeapYear
	self assert: aDateAndTime isLeapYear
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTimeStamp
	self assert: aDateAndTime asTimeStamp =  ((TimeStamp readFrom: '2-29-2004 1:33 pm' readStream) offset: 2 hours).

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMonth
	self assert: aDateAndTime month  = 2.
	self assert: aDateAndTime monthAbbreviation = 'Feb'.
	self assert: aDateAndTime monthName = 'February'.
	self assert: aDateAndTime monthIndex = 2.</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSeconds
	self assert: aDateAndTime seconds =  0

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearDayHourMinuteSecond
	self assert: aDateAndTime =  ((DateAndTime year: 2004 day: 60 hour: 13 minute: 33 second: 0) offset: 2 hours).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testtimeZone
	self assert: aDateAndTime timeZoneName	= 'Universal Time'.
	self assert: aDateAndTime timeZoneAbbreviation	=  'UTC'

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
	localTimeZoneToRestore := DateAndTime localTimeZone.
	DateAndTime localTimeZone: TimeZone default.
	aDateAndTime := (DateAndTime year: 2004 month: 2 day: 29 hour: 13 minute: 33 second: 0 offset: 2 hours).
	aTimeZone := TimeZone default.
	aDuration := Duration days: 0 hours: 13 minutes: 33 seconds: 0 nanoSeconds: 0
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInYear
	self assert: aDateAndTime daysInYear  = 366.

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeLeapTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsNanoSeconds
	self assert: aDateAndTime asNanoSeconds =  aDuration asNanoSeconds.
	self assert: aDateAndTime asNanoSeconds = 48780000000000
	
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ DateAndTime

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| private | 
	private := #( #printOn: ).

	^ super selectorsToBeIgnored, private
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testMonotonicity

	| t1 t2 t3 t4 |
	t1 := DateAndTime now.
	t2 := DateAndTime now.
	(Delay forMilliseconds: 1000) wait.
	t3 := DateAndTime now.
	t4 := DateAndTime now.

	self
		assert: (	t1 &lt;= t2);
		assert: (	t2 &lt; t3);
		assert: (	t3 &lt;= t4).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInstanceCreation

	| t |
	t := DateAndTime 
			year: 1 month: 1 day: 2 
			hour: 2 minute: 3 second: 4 nanoSecond: 5 
			offset: 6 hours.
	self 
		assert: (t julianDayNumber = 1721427);
		assert: (t offset = 6 hours);
		assert: (t hour = 2);
		assert: (t minute = 3);
		assert: (t second = 4);
		assert: (t nanoSecond = 5).
		
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testSmalltalk80Accessors

	| t |
	t := DateAndTime 
			year: 1 month: 1 day: 2 
			hour: 2 minute: 3 second: 4 nanoSecond: 5 
			offset: 6 hours.
	self 
		assert: (t hours = t hours);
		assert: (t minutes = t minute);
		assert: (t seconds = t second).
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testArithmeticAcrossDateBoundary

	| t1 t2 |
	t1 := '2004-01-07T11:55:00+00:00' asDateAndTime. 
	t2 := t1 - ( (42900+1) seconds).  

	self 
		assert: t2 = ('2004-01-06T23:59:59+00:00' asDateAndTime)
		
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInquiries

	self	
		assert: date dayOfMonth = 2;
		assert: date dayOfYear = 153;
		assert: date daysInMonth = 30;
		assert: date daysInYear = 365;
		assert: date daysLeftInYear = (365 - 153);
		assert: date firstDayOfMonth = 152.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testEqual
	self assert: aDate = (Date readFrom: (ReadStream on: 'January 23, 2004')).</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDuration
	self assert: aDate duration = 24 hours</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOnFormat
	| cs rw |
	cs := ReadStream on: '04*Jan*23'.
	rw := ReadWriteStream on: ''.
	aDate printOn: rw format: #(3 2 1 $* 2 2).
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Private</category>
<body package="Squeak-Tests">dateClass

	^ Date</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayMonthYearDo
	self assert: (aDate dayMonthYearDo: [:day :month :year | day asString , month asString, year asString]) = '2312004'
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYyyymmdd
	self assert: aDate yyyymmdd =  '2004-01-23'</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLessThan
	self assert: aDate &lt; (Date readFrom: (ReadStream on: '01-24-2004')).</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDate
	self assert: (aDate asDate) = aDate
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testComparing
	| d1 d2 d3 |
	d1 := self dateClass newDay: 2 month: #June year: 1973.
	d2 := self dateClass newDay: 97 year: 2003. 		"7 April 2003"
	d3 := self dateClass newDay: 250 year: 1865. 		"7 September 1865"

	self
		assert: date = d1;
		assert: date = date copy;
		assert: date hash = d1 hash.
	self 
		assert: date &lt; d2;
		deny: date &lt; d3.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testJulianDayNumber
	self assert: aDate = (Date julianDayNumber: ((4713+2004)*365 +1323) ).  </body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLeapNot
	self assert: (aDate addDays: 365) leap = 0
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsSeconds
	self assert: (aDate asSeconds) =   3252268800.
	self assert: (aDate asSeconds) =  ((103*365*24*60*60) + (22+25"leap days"*24*60*60)) .
	self assert: aDate  =  (Date fromSeconds: 3252268800).</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStoreOn
	| cs rw |
	cs := ReadStream on: '''23 January 2004'' asDate'.
	rw := ReadWriteStream on: ''.
	aDate storeOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testConverting

	self 
		assert: date asDate = date;
		assert: '2 June 1973' asDate = date;
		assert: date asSeconds = 2285280000.

	date dayMonthYearDo: [ :d :m :y | self assert: d = 2; assert: m = 6; assert: y = 1973 ].</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTomorrow
	"Not a great test: could falsely fail if midnight come in between the two executions and doesnt catch many errors"
	self assert: Date tomorrow  &gt; Date today 
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintFormat
	self assert: (aDate printFormat: #(1 2 3 $? 2 2)) =  '23?Jan?04'</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSubtractDate
	self assert: (aDate subtractDate:(aDate addDays: 30)) = -30.	
	self assert: (aDate subtractDate:(aDate subtractDays: 00)) = 0.	
	self assert: (aDate subtractDate:(aDate subtractDays: 30)) = 30.

</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testAccessing

	self	
		assert: date day = 153;
		assert: date julianDayNumber = 2441836;
		assert: date leap = 0;
		assert: date monthIndex = 6;
		assert: date monthName = #June;
		assert: date weekday = #Saturday;
		assert: date weekdayIndex = 7;
		assert: date year = 1973.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNameOfMonth
	self assert: (Date nameOfMonth: 5) = 'May'.	
	self assert: (Date nameOfMonth: 8) = 'August' </body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testFromDays
	| epoch d0 d1 d2 |
	epoch := self dateClass newDay: 1 year: 1901.
	d0 := self dateClass fromDays: 0. 			"1 January 1901"
	self assert: d0 = epoch.

	d1 := self dateClass fromDays:  26450. 	"2 June 1973"
	self assert: d1 = date.

	d2 := self dateClass fromDays: -100000.	"18 March 1627"
	self assert: d2 julianDayNumber = 2315386.

	self assert: aDate  =  (Date fromDays:  37642).
	self assert: aDate  =  (Date fromDays: 103*365 + 22 + 25 "leap days") .
	</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testNew
	| epoch |
	epoch := self dateClass newDay: 1 year: 1901.
	self assert: (self dateClass new = epoch).</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAddDays
	self assert: (aDate addDays: 00) yyyymmdd =  '2004-01-23'.	
	self assert: (aDate addDays: 30) yyyymmdd =  '2004-02-22'.
	self assert: (aDate addDays: 60) yyyymmdd =  '2004-03-23'.
	self assert: (aDate addDays: 90) yyyymmdd =  '2004-04-22'.
	self assert: (aDate addDays:120) yyyymmdd =  '2004-05-22'</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStarting
	self assert: aDate = (Date starting: (DateAndTime fromString: '2004-01-23T12:12')).  </body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPreviousThursday
	self assert: (aDate previous: 'Thursday') yyyymmdd = '2004-01-22'

</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testFromSeconds
	| d |
	d := self dateClass fromSeconds: 2285280000. 
	self
		assert: d = date.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	 | deprecated private special |
	deprecated := #(
		#fromJulianDayNumber:
		#uniqueDateStringBetween:and:
		#daylightSavingsInEffectAtStandardHour:
		#daylightSavingsInEffect
		#asGregorian
		#asJulianDayNumber
		#day:year:
		#firstDayOfMonthIndex:
		#mmddyy
		#absoluteDaysToYear:
		#yearAndDaysFromDays:into:
		#week
		#month ).

	private := #( #julianDayNumber: ).

	special := #( #&lt; #= #new #next #previous #printOn: #printOn:format: #storeOn: #fromString: ).

	^ super selectorsToBeIgnored, deprecated, private, special</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testWeekday
	self assert: aDate weekday = 'Friday'.	
	self assert: aDate weekdayIndex = 6. 
	self assert: (Date dayOfWeek: aDate weekday ) =6.
	self assert: (Date nameOfDay: 6 ) = 'Friday'	</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testArithmetic
	| d |
	d := date addDays: 32.		"4 July 1973"

	self 
		assert: d year = 1973;
		assert: d monthIndex = 7;
		assert: d dayOfMonth = 4.
	self 
		assert: (d subtractDate: date) = 32;
		assert: (date subtractDate: d) = -32.
	self	 
		assert: (d subtractDays: 32) = date.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: '23 January 2004'.
	rw := ReadWriteStream on: ''.
	aDate printOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYesterday
	"Not a great test:  doesnt catch many errors"
	self assert: Date yesterday  &lt; Date today 
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLeap
	self assert: aDate leap = 1.	

</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPreviousNext
	| n p pt ps |
	n := date next.
	p := date previous.

	self
		assert: n year = 1973;
		assert: n dayOfYear = 154;
		assert: p year = 1973;
		assert: p dayOfYear = 152.

	pt := date previous: #Thursday.		"31 May 1973"
	self	
		assert: pt year = 1973;
		assert: pt dayOfYear = 151.

	ps := date previous: #Saturday.		" 26 May 1973"
	self	
		assert: ps year = 1973;
		assert: ps dayOfYear = (153-7).
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testGeneralInquiries

	| shuffled indices names now | 

	shuffled := #(#January #February #March #April #May #June #July 
					#August #September #October #November #December) shuffled.
	indices := shuffled collect: [ :m | self dateClass indexOfMonth: m ].
	names := indices collect: [ :i | self dateClass nameOfMonth: i ].
	self assert: names = shuffled.

	shuffled := #(#Monday #Tuesday #Wednesday #Thursday #Friday #Saturday #Sunday) shuffled.
	indices := shuffled collect: [ :m | self dateClass dayOfWeek: m ].
	names := indices collect: [ :i | self dateClass nameOfDay: i ].
	self assert: names = shuffled.
	
	now  := self dateClass dateAndTimeNow.
	self 
		assert: now size = 2;
		assert: now first = self dateClass today.

	self assert: (self dateClass firstWeekdayOfMonth: #June year: 1973) = 6.

	self
		assert: (self dateClass leapYear: 1973) = 0;
		assert: (self dateClass leapYear: 1972) = 1;
		assert: (self dateClass daysInYear: 1973) = 365;
		assert: (self dateClass daysInYear: 1972) = 366;
		assert: (self dateClass daysInMonth: #February forYear: 1973) = 28;
		assert: (self dateClass daysInMonth: #February forYear: 1972) = 29.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMmddyyyy
	self assert: aDate mmddyyyy =  '1/23/2004'</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testStoring

	self	
		assert: date storeString = '''2 June 1973'' asDate';
		assert: date = ('2 June 1973' asDate).
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDateAndTimeNow
	"Not a great test: could falsely fail if midnight come in between the two executions and doesnt catch time errors"
	self assert: Date dateAndTimeNow first  = Date today 
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNewDayYear
	self assert: aDate = (Date newDay: 23 year: 2004)	
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIndexOfMonth
	self assert: (Date indexOfMonth: 'January')  = 1.	
	self assert: (Date indexOfMonth: 'December')  = 12.	</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testReadFrom
	| s1 s2 s3 s4 s5 | 
	s1 := '2 June 1973'.
	s2 := '2-JUN-73'.
	s3 := 'June 2, 1973'.
	s4 := '6/2/73'.
	s5 := '2JUN73'.

	self	
		assert: date = (self dateClass readFrom: s1 readStream);
		assert: date = (self dateClass readFrom: s2 readStream);
		assert: date = (self dateClass readFrom: s3 readStream);
		assert: date = (self dateClass readFrom: s4 readStream);
		assert: date = (self dateClass readFrom: s5 readStream).</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFirstWeekdayOfMonthYear
	self assert: (Date firstWeekdayOfMonth: 'January' year: 2004)  = 5.	
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPrinting

	self	
		assert: date mmddyyyy = '6/2/1973';
		assert: date yyyymmdd = '1973-06-02';
		assert: (date printFormat: #(3 1 2 $! 2 1 1)) = '1973!2!Jun'.
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNewDayMonthYear
	self assert: aDate = (Date newDay: 23 month: 1 year: 2004)	
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">setUp

	date := self dateClass newDay: 153 year: 1973.	"2 June 1973"

	aDate := Date readFrom: '01-23-2004' readStream.
	aTime := Time readFrom: '12:34:56 pm' readStream</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInYear
	self assert: (Date daysInYear: 2008)  = 366.	
	self assert: (Date daysInYear: 2000)  = 366.	
	self assert: (Date daysInYear: 2100)  = 365	
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInMonthForYear
	self assert: (Date daysInMonth: 'February' forYear: 2008)  = 29.	
	self assert: (Date daysInMonth: 'February' forYear: 2000)  = 29.	
	self assert: (Date daysInMonth: 'February' forYear: 2100)  = 28.	
	self assert: (Date daysInMonth: 'July' forYear: 2100)  = 31.	</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ self dateClass</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInitialization

	self should: [ self dateClass initialize. true ].
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSubtractDays
	self assert: (aDate subtractDays: 00) yyyymmdd =  '2004-01-23'.	
	self assert: (aDate subtractDays: 30) yyyymmdd =  '2003-12-24'.
	self assert: (aDate subtractDays: 60) yyyymmdd =  '2003-11-24'
</body>
</methods>
<methods>
<class-id>Squeak.DateTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPreviousFriday
	self assert: (aDate previous: 'Friday') yyyymmdd = '2004-01-16'

</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">truncateTo: aDuration
	"e.g. if the receiver is 5 minutes, 37 seconds, and aDuration is 2 minutes, answer 4 minutes."

	^ self class
		nanoSeconds: (self asNanoSeconds truncateTo: aDuration asNanoSeconds)

</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">negated

	^ self class seconds: seconds negated nanoSeconds: nanos negated
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">minutes

	"Answer the number of minutes the receiver represents."


	^ (seconds rem: SecondsInHour) quo: SecondsInMinute
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">seconds
	"Answer the number of seconds the receiver represents."

	^ (seconds rem: SecondsInMinute) + (nanos / NanosInSecond)</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">nanoSeconds


	^ nanos
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>private</category>
<body package="Squeak">storeOn: aStream

	aStream
		nextPut: $(;
		nextPutAll: self className;
		nextPutAll: ' seconds: ';
		print: seconds;
		nextPutAll: ' nanoSeconds: ';
		print: nanos;
		nextPut: $).
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>initialize-release</category>
<body package="Squeak">initialize
	self seconds: 0 nanoSeconds: 0.
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">asDuration

	^ self
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">= comparand 
	"Answer whether the argument is a &lt;Duration&gt; representing the same 
	period of time as the receiver."

	^ self == comparand
		ifTrue: [true]
		ifFalse: 
			[self species = comparand species 
				ifTrue: [self asNanoSeconds = comparand asNanoSeconds]
				ifFalse: [false] ]</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDelay

	^ Delay forDuration: self</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">+ operand

	"operand is a Duration" 	^ self class nanoSeconds: (self asNanoSeconds + operand asNanoSeconds)
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">hash 	^seconds bitXor: nanos
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">roundTo: aDuration
	"e.g. if the receiver is 5 minutes, 37 seconds, and aDuration is 2 minutes, answer 6 minutes."

	^ self class nanoSeconds: (self asNanoSeconds roundTo: aDuration asNanoSeconds)

</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">abs

	^ self class seconds: seconds abs nanoSeconds: nanos abs
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">positive


	^ seconds = 0 ifTrue: [ nanos positive ] ifFalse: [ seconds positive ]
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">asNanoSeconds

	^ (seconds * NanosInSecond) + nanos
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">- operand
	"operand is a Duration" 	^ self + operand negated
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">asMilliSeconds


	^ ((seconds * NanosInSecond) + nanos) // (10 raisedToInteger: 6)
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">hours
	"Answer the number of hours the receiver represents."


	^ (seconds rem: SecondsInDay) quo: SecondsInHour
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">&lt; comparand

	^ self asNanoSeconds &lt; comparand asNanoSeconds
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">negative


	^ self positive not
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">* operand
	"operand is a Number" 	^ self class nanoSeconds: ( (self asNanoSeconds * operand) asInteger).
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">asSeconds


	^ seconds
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">\\ operand

	"modulo. Remainder defined in terms of //. Answer a Duration with the 
	same sign as aDuration. operand is a Duration or a Number."

	^ operand isNumber
		ifTrue: [ self class nanoSeconds: (self asNanoSeconds \\ operand) ]
		ifFalse: [ self - (operand * (self // operand)) ]
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream
	"Format as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]" 	| d h m s n |
	d := self days abs.
	h := self hours abs.
	m := self minutes abs.
 	s := self seconds abs truncated.
	n := self nanoSeconds abs. 	self negative ifTrue: [ aStream nextPut: $- ].
	d printOn: aStream. aStream nextPut: $:.
	h &lt; 10 ifTrue: [ aStream nextPut: $0. ].
	h printOn: aStream. aStream nextPut: $:.
	m &lt; 10 ifTrue: [ aStream nextPut: $0. ].
	m printOn: aStream. aStream nextPut: $:.
	s &lt; 10 ifTrue: [ aStream nextPut: $0. ].
	s printOn: aStream.
	n = 0 ifFalse:
		[ | z ps |
		aStream nextPut: $..
		ps := n printString padded: #left to: 9 with: $0. 
		z := ps findLast: [ :c | c asciiValue &gt; $0 asciiValue ].
		ps from: 1 to: z do: [ :c | aStream nextPut: c ] ].
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>private</category>
<body package="Squeak">ticks
	"Answer an array {days. seconds. nanoSeconds}. Used by DateAndTime and Time"

	^ Array 
		with: self days
		with: (self hours * 3600) + (self minutes * 60 ) + (self seconds truncated)
		with: self nanoSeconds</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>squeak protocol</category>
<body package="Squeak">// operand

	"operand is a Duration or a Number"


	^ operand isNumber
		ifTrue: [ self class nanoSeconds: (self asNanoSeconds // operand) asInteger ]
		ifFalse: [ self asNanoSeconds // operand asDuration asNanoSeconds ]
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">days

	"Answer the number of days the receiver represents."

	^ seconds quo: SecondsInDay
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>ansi protocol</category>
<body package="Squeak">/ operand

	"operand is a Duration or a Number"


	^ operand isNumber
		ifTrue: [ self class nanoSeconds: (self asNanoSeconds / operand) asInteger ]
		ifFalse: [ self asNanoSeconds / operand asDuration asNanoSeconds ]
.
</body>
</methods>
<methods>
<class-id>Squeak.Duration</class-id>
<category>private</category>
<body package="Squeak">seconds: secondCount nanoSeconds: nanoCount 
	"Private - only used by Duration class"

	seconds := secondCount.
	nanos := nanoCount</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIntegerDivision
	self assert: aDuration // aDuration = 1. 
	self assert: aDuration // 2 =  (aDuration / 2). 
	"is there ever a case where this is not true, since precision is always to the nano second?"</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testNumberConvenienceMethods

	self
		assert: 1 week = (Duration days: 7);
		assert: -1 week = (Duration days: -7);
		assert: 1 day = (Duration days: 1);
		assert: -1 day = (Duration days: -1);
		assert: 1 hours = (Duration hours: 1);
		assert: -1 hour = (Duration hours: -1);
		assert: 1 minute = (Duration seconds: 60);
		assert: -1 minute = (Duration seconds: -60);
		assert: 1 second = (Duration seconds: 1);
		assert: -1 second = (Duration seconds: -1);
		assert: 1 milliSecond = (Duration milliSeconds: 1);
		assert: -1 milliSecond = (Duration milliSeconds: -1);
		assert: 1 nanoSecond = (Duration nanoSeconds: 1);
		assert: -1 nanoSecond = (Duration nanoSeconds: -1)
		</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDays
	self assert: aDuration   days = 1.
	self assert: (Duration   days: 1) days= 1.	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAbs
	self assert: aDuration abs = aDuration. 
	self assert: (Duration nanoSeconds: -5)  abs =  (Duration nanoSeconds: 5). 
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLessThan
	self assert: aDuration  &lt; (aDuration + 1 day ).
	self deny: aDuration &lt; aDuration.
	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testComparing

	| d1 d2 d3 |
	d1 := Duration seconds: 10 nanoSeconds: 1.
	d2 := Duration seconds: 10 nanoSeconds: 1.
	d3 := Duration seconds: 10 nanoSeconds: 2.
	
	self
		assert: (d1 = d1);
		assert: (d1 = d2);
		deny: (d1 = d3);
		assert: (d1 &lt; d3)
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNegative
	self deny: aDuration negative.
	self assert: aDuration negated negative
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsSeconds
	self assert: (Duration nanoSeconds: 1000000000)  asSeconds = 1.
	self assert: (Duration seconds: 1)  asSeconds = 1.	
	self assert: aDuration   asSeconds = 93784.</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStoreOn
     self assert: (aDuration storeOn: (WriteStream on:'')) asString ='1:02:03:04.000000005'. 
     "storeOn: returns a duration (self) not a stream"</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNegated
	self assert: aDuration + aDuration negated = (Duration seconds: 0). 
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinutes
	self assert: aDuration   minutes = 3.
	self assert: (Duration minutes: 3) minutes = 3.	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDivide
	self assert: aDuration / aDuration = 1. 
	self assert: aDuration / 2 = (Duration days: 0 hours: 13 minutes: 1 seconds: 32 nanoSeconds: 2). 
	self assert: aDuration / (1/2) = (Duration days: 2 hours: 4 minutes: 6 seconds: 8 nanoSeconds: 10).
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testZero
	self assert: (Duration zero) = (Duration seconds: 0).	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testTruncateTo

	self assert: ((5 minutes + 37 seconds) truncateTo: (2 minutes)) = (4 minutes).
	self assert:  (aDuration truncateTo: (Duration days: 1)) =
	               (Duration days: 1 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0).
	self assert:  (aDuration truncateTo: (Duration hours: 1)) =
	               (Duration days: 1 hours: 2 minutes: 0 seconds: 0 nanoSeconds: 0).	
	self assert:  (aDuration truncateTo: (Duration minutes: 1)) =
	               (Duration days: 1 hours: 2 minutes: 3 seconds: 0 nanoSeconds: 0).</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testRoundTo

	self assert: ((5 minutes + 37 seconds) roundTo: (2 minutes)) = (6 minutes).
	
	self assert:  (aDuration roundTo: (Duration days: 1)) =
	               (Duration days: 1 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0).
	self assert:  (aDuration roundTo: (Duration hours: 1)) =
	               (Duration days: 1 hours: 2 minutes: 0 seconds: 0 nanoSeconds: 0).	
	self assert:  (aDuration roundTo: (Duration minutes: 1)) =
	               (Duration days: 1 hours: 2 minutes: 3 seconds: 0 nanoSeconds: 0).</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHash
	self assert: aDuration hash =    	(Duration days: 1 hours: 2 minutes: 3 seconds: 4 nanoSeconds: 5) hash.
	self assert: aDuration hash =     93789
	"must be a more meaningful test?"</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMultiply
	self assert: aDuration * 2 = (Duration days: 2 hours: 4 minutes: 6 seconds: 8 nanoSeconds: 10). </body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTicks
	self assert: aDuration ticks =  #(1 7384 5)</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNew
	"self assert: Duration new =  (Duration seconds: 0)."
    "new is not valid as a creation method: MessageNotUnderstood: UndefinedObject&gt;&gt;quo:, where Duration seconds is nil"</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDelay
	self deny: aDuration asDelay =   aDuration.
	"want to come up with a more meaningful test"
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNanoSeconds
	self assert: aDuration nanoSeconds = 5.
	self assert: (Duration nanoSeconds: 5) nanoSeconds = 5.	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMilliSeconds
	self assert: (Duration milliSeconds: 5) nanoSeconds = 5000000.	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| private | 
	private := #( #printOn: ).

	^ super selectorsToBeIgnored, private
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPositive
	self assert: (Duration nanoSeconds: 0) positive.
	self assert: aDuration positive.
	self deny: aDuration negated positive
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinus
	self assert: aDuration - aDuration = (Duration seconds: 0).
	self assert: aDuration - (Duration days: -1 hours: -2 minutes: -3 seconds: -4 nanoSeconds: -5) = 
						    (Duration days: 2  hours: 4  minutes: 6  seconds: 8  nanoSeconds: 10). 
	self assert: aDuration - (Duration days: 0  hours: 1  minutes: 2  seconds: 3  nanoSeconds: 4) = 
						    (Duration days: 1  hours: 1  minutes: 1  seconds: 1  nanoSeconds: 1). 
	self assert: aDuration - (Duration days: 0  hours: 3   minutes: 0  seconds: 5  nanoSeconds: 0) = 
						    (Duration days: 0  hours: 23  minutes: 2  seconds: 59  nanoSeconds: 5). </body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testQuotient

	| d1 d2 q |
	d1 := 11.5 seconds.
	d2 := d1 // 3.
	self assert: d2 = (Duration seconds: 3 nanoSeconds: 833333333).

	q := d1 // (3 seconds).
	self assert: q = 3.

</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
    	|cs rw |
	cs := ReadStream on: '1:02:03:04.000000005'.
	rw := ReadWriteStream on: ''.
     aDuration printOn: rw.
     self assert: rw contents = cs contents.</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testModulo

	| d1 d2 d3 |
	d1 := 11.5 seconds.
	d2 := d1 \\ 3.
	self assert: d2 = (Duration nanoSeconds: 1).

	d3 := d1 \\ (3 seconds).
	self assert: d3 =  (Duration seconds: 2 nanoSeconds: 500000000).

	self assert: aDuration \\ aDuration = 
		(Duration days: 0 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0). 
	self assert: aDuration \\ 2 = 
		(Duration days: 0 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 1).
	

</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSecondsNanoSeconds 
	self assert: (Duration   seconds: 0 nanoSeconds: 5)  = (Duration  nanoSeconds: 5).	
	"not sure I should include in sunit since its Private "
	self assert: (aDuration seconds: 0 nanoSeconds: 1) = (Duration nanoSeconds: 1). 
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testWeeks
	self assert: (Duration  weeks: 1) days= 7.	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFromString
	self assert: aDuration = (Duration fromString: '1:02:03:04.000000005').
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDuration
	self assert: aDuration asDuration =  aDuration
	
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHours
	self assert: aDuration   hours = 2.
	self assert: (Duration   hours: 2) hours = 2.	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSeconds
	self assert: aDuration seconds =   (800000001/200000000).
	self assert: (Duration  nanoSeconds: 2) seconds = (2/1000000000).	
	self assert: (Duration  seconds: 2) seconds = 2.	
	self assert: (Duration  days: 1 hours: 2 minutes: 3 seconds:4) seconds = (4).
	self deny: (Duration  days: 1 hours: 2 minutes: 3 seconds:4) seconds = (1*24*60*60+(2*60*60)+(3*60)+4).	</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testReadFrom
	self assert: aDuration =  (Duration readFrom: (ReadStream on: '1:02:03:04.000000005'))
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
	aDuration := Duration days: 1 hours: 2 minutes: 3 seconds: 4 nanoSeconds: 5 </body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPlus
	self assert: (aDuration + 0 hours) = aDuration.
	self assert: (aDuration + aDuration) = (Duration days: 2 hours: 4 minutes: 6 seconds: 8 nanoSeconds: 10). </body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Duration


</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testMonthDurations

	| jan feb dec |
	jan := Duration month: #January.
	feb := Duration month: #February.
	dec := Duration month: #December.
	
	self 
		assert: jan = (Year current months first duration);
		assert: feb = (Year current months second duration);
		assert: dec = (Year current months last duration)

		
</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsNanoSeconds
	self assert: (Duration nanoSeconds: 1)  asNanoSeconds = 1.
	self assert: (Duration seconds: 1)  asNanoSeconds = 1000000000.	
	self assert: aDuration   asNanoSeconds = 93784000000005.</body>
</methods>
<methods>
<class-id>Squeak.DurationTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsMilliSeconds
	self assert: (Duration nanoSeconds: 1000000)  asMilliSeconds = 1.
	self assert: (Duration seconds: 1)  asMilliSeconds = 1000.	
	self assert: (Duration nanoSeconds: 1000000)  asMilliSeconds = 1.
	self assert: (Duration nanoSeconds: 1000000)  asMilliSeconds = 1.
	self assert: aDuration   asMilliSeconds = 93784000.</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>deprecated</category>
<body package="Squeak">eachWeekDo: aBlock

	self deprecated: 'Use #weeksDo:'.

	self weeksDo: aBlock
</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>squeak protocol</category>
<body package="Squeak">index

	^ self monthIndex
</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>squeak protocol</category>
<body package="Squeak">asMonth

	^ self
</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream


	aStream nextPutAll: self monthName, ' ', self year printString.</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>squeak protocol</category>
<body package="Squeak">name


	^ self monthName
</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>squeak protocol</category>
<body package="Squeak">previous


	^ self class starting: (self start - 1)
</body>
</methods>
<methods>
<class-id>Squeak.Month</class-id>
<category>squeak protocol</category>
<body package="Squeak">daysInMonth

	^ self duration days.</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testConverting

	self assert: month asDate = '1 July 1998' asDate</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| deprecated private special |
	deprecated := #().
	private := #( #printOn: ).
	special := #( #next ).

	^ super selectorsToBeIgnored, deprecated, private, special.</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testReadFrom

	| m |
	m := Month readFrom: 'July 1998' readStream.
	self 
		assert: m = month</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPrinting

	self 
		assert: month printString = 'July 1998'.
</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testEnumerating

	| weeks |
	weeks := OrderedCollection new.
	month eachWeekDo: [ :w | weeks add: w firstDate ].

	0 to: 4 do: [ :i | weeks remove: 
		(Week fromDate: ('29 June 1998' asDate addDays: i * 7)) firstDate ].

	self assert: weeks isEmpty
</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">setUp

	super setUp.
	month := Month month: 7 year: 1998.</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">tearDown

	super tearDown.
	month := nil.</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testDeprecated

	self 
		assert: month firstDate = '1 July 1998' asDate;
		assert: month lastDate = '31 July 1998' asDate.</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Month</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInstanceCreation

	| m1 m2 |
	m1 := Month fromDate: '4 July 1998' asDate.
	m2 := Month month: #July year: 1998.
	
	self
		assert: month = m1;
		assert: month = m2.

</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPreviousNext
	| n p |
	n := month next.
	p := month previous.

	self
		assert: n year = 1998;
		assert: n index = 8;
		assert: p year = 1998;
		assert: p index = 6.

</body>
</methods>
<methods>
<class-id>Squeak.MonthTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInquiries

	self 
		assert: month index = 7;
		assert: month name = #July;
		assert: month duration = (31 days).
</body>
</methods>
<methods>
<class-id>Squeak.Schedule</class-id>
<category>enumerating</category>
<body package="Squeak">between: aStart and: anEnd do: aBlock

	| element end i |
	end := self end min: anEnd.
	element := self start.
	
	i := 1.
	[ element &lt; aStart ] whileTrue:
	
	[ element := element + (schedule at: i).
		i := i + 1. (i &gt; schedule size) ifTrue: [i := 1]].
	i := 1.
	[ element &lt;= end ] whileTrue:
	
	[ aBlock value: element.
		element := element + (schedule at: i).
		i := i + 1.
		(i &gt; schedule size) ifTrue: [i := 1]]
.
</body>
</methods>
<methods>
<class-id>Squeak.Schedule</class-id>
<category>enumerating</category>
<body package="Squeak">dateAndTimes

	| dateAndTimes |
	dateAndTimes := OrderedCollection new.
	self scheduleDo: [ :e | dateAndTimes add: e ].
	^ dateAndTimes asArray.</body>
</methods>
<methods>
<class-id>Squeak.Schedule</class-id>
<category>enumerating</category>
<body package="Squeak">schedule: anArrayOfDurations

	schedule := anArrayOfDurations
</body>
</methods>
<methods>
<class-id>Squeak.Schedule</class-id>
<category>enumerating</category>
<body package="Squeak">schedule
	^ schedule
</body>
</methods>
<methods>
<class-id>Squeak.Schedule</class-id>
<category>squeak protocol</category>
<body package="Squeak">includes: aDateAndTime

	| dt |
	dt := aDateAndTime asDateAndTime.
	self scheduleDo: [ :e | e = dt ifTrue: [^true] ].
	^ false.
</body>
</methods>
<methods>
<class-id>Squeak.Schedule</class-id>
<category>enumerating</category>
<body package="Squeak">scheduleDo: aBlock

	self between: (self start) and: (self end) do: aBlock.
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIncludes
	self assert: (aSchedule includes: (DateAndTime year: 2003 month: 6 day: 15 hour: 20 minute: 30 second: 0 offset: 0 hours))
	
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testBetweenAndDoOverlappingSchedule
	| count |
	count := 0.
	aSchedule
		between: (DateAndTime
				year: 2002
				month: 12
				day: 1)
		and: (DateAndTime
				year: 2003
				month: 1
				day: 31)
		do: [:each | count := count + 1].
	self assert: count = 8</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| private | 
	private := #( #printOn: ).

	^ super selectorsToBeIgnored, private
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDateAndTimes
	| answer |
	self assert: aSchedule dateAndTimes size  = 104.
	self assert: aSchedule dateAndTimes first = firstEvent.
	answer := true.
	aSchedule dateAndTimes do: [:each | (each dayOfWeekName = 'Saturday'
		or: [each dayOfWeekName = 'Sunday']) ifFalse: [^false]].
	self assert: answer
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSchedule
	self assert: aSchedule schedule size = 2.
	self assert: aSchedule schedule first = 1 days.	
	self assert: aSchedule schedule second = 6 days.
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
 	 "Schedule is a type of Timespan representing repeated occurences of the same event. 
	The beginning of the schedule is the first occurrence of the event.
	A schedule maintains an array of Durations. Each durations specify the offset to the next scheduled each. 
	The duration of each occurence of the event is not specified. Nor are any other attributes such as name"
	
	"Create aSchedule with an event scheduled for 8:30pm every Saturday and Sunday for the year 2003. "
	"Create the first event occurring on the first Saturday at 8:30 pm: 1/4/03"
	firstEvent :=  DateAndTime year: 2003 month: 1 day: 4 hour: 20 minute: 30. 
	"Create a schedule for one year starting with the first event" 
	aSchedule := Schedule starting: firstEvent duration: 52 weeks.
	"Schedule the recurring events by scheduling the time in between each one.  One day for Sat-Sun. 6 days for Sun-Sat" 
	aSchedule schedule: (Array with: (Duration days: 1) with: (Duration days: 6)).
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testFromDateAndTime

	| oc1 oc2 |
	oc1 := OrderedCollection new.
	DateAndTime today to: DateAndTime tomorrow by: 10 hours do: [ :dt | oc1 add: dt ].

	oc2 := Array with: DateAndTime today
			with: (DateAndTime today + 10 hours)
				with: (DateAndTime today + 20 hours).

	self assert: (oc1 asArray = oc2)</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Schedule

</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testMonotonicity

	| t1 t2 t3 t4 |
	t1 := DateAndTime now.
	t2 := DateAndTime now.
	t3 := DateAndTime now.
	t4 := DateAndTime now.

	self 
		assert: (	t1 &lt;= t2);
		assert: (	t2 &lt;= t3);
		assert: (	t3 &lt;= t4).
</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testBetweenAndDoDisjointWithSchedule
	| count |
	count := 0.
	aSchedule
		between: (DateAndTime
				year: 2004
				month: 4
				day: 1)
		and: (DateAndTime
				year: 2004
				month: 4
				day: 30)
		do: [:each | count := count + 1].
	self assert: count = 0</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testExampleFromSwikiPage
	"It is often neccessary to schedule repeated events, like airline flight schedules, TV programmes, and file backups.
	 Schedule is a Timespan which maintains an array of Durations.
	 The durations specify the offset to the next scheduled DateAndTime. "
	"Consider a TV programme scheduled for 8:30pm every Saturday and Sunday for the current year. "
	"Find the first Saturday and set its time to 20h30"
	| sat shows |
	sat := Year current asMonth dates detect: [ :d | d dayOfWeekName = #Saturday ].
	sat := sat start + (Duration hours: 20.5).
	"Create a schedule" 
	shows := Schedule starting: sat ending: Year current end.
	shows schedule: (Array with: (Duration days: 1) with: (Duration days: 6)).
	"To inspect:"
	shows dateAndTimes.
	shows dateAndTimes collect: [ :dt | dt dayOfWeekName ].

</body>
</methods>
<methods>
<class-id>Squeak.ScheduleTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testBetweenAndDoIncludedInSchedule
	| count |
	count := 0.
	aSchedule
		between: (DateAndTime
				year: 2003
				month: 4
				day: 1)
		and: (DateAndTime
				year: 2003
				month: 4
				day: 30)
		do: [:each | count := count + 1].
	self assert: count = 8</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">activate

	self isSuspended ifTrue:
		[self timespans add: 
			(Timespan starting: DateAndTime now duration: Duration zero).
		self state: #active]
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">isActive

	^ self state = #active
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream

	super printOn: aStream.
	aStream
		nextPut: $(;
		nextPutAll: self state;
		nextPut: $:;
		print: self duration;
		nextPut: $).

</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">isSuspended

	^ self state = #suspended

</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">state: aSymbol

	state := aSymbol
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">end

	^ self timespans last next

</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">timespans

	^ timespans ifNil: [ timespans := OrderedCollection new ]
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">state

	^ state ifNil: [ state := #suspended ]
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">suspend

	| ts |
	self isActive ifTrue:
		[ ts := self timespans last.
		ts duration: (DateAndTime now - ts start).
		self state: #suspended]
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">start

	^ self timespans first start

</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">reset

	self suspend.
	timespans := nil.

</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">reActivate

	self 
		suspend;
		activate.
</body>
</methods>
<methods>
<class-id>Squeak.Stopwatch</class-id>
<category>squeak protocol</category>
<body package="Squeak">duration

	| ts last |
	self isSuspended 
		ifTrue:
			[ (ts := self timespans) isEmpty ifTrue: 
				[ ts := Array with: (Timespan starting: DateAndTime now duration: Duration zero ) ] ]
		ifFalse:
			[ last := self timespans last.
			ts := self timespans allButLast
				add: (last duration: (DateAndTime now - last start); yourself);
				yourself ].
		
	^ (ts collect: [ :t | t duration ]) sum
</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| private | 
	private := #( #printOn: #state: ).

	^ super selectorsToBeIgnored, private
</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testStartStop

	| sw t1 t2 t3 t4 |
	sw := Stopwatch new.
	t1 := DateAndTime now.
	(Delay forMilliseconds: 10) wait.
	sw activate; activate.
	(Delay forMilliseconds: 10) wait.
	t2 := DateAndTime now.
	
	self 
		deny: (sw isSuspended);
		assert: (sw isActive);
		assert: (sw timespans size = 1);
		assert: (t1 &lt; sw start);
		assert: (sw start &lt; t2).

	(Delay forMilliseconds: 10) wait.
	t3 := DateAndTime now.
	(Delay forMilliseconds: 10) wait.
	sw suspend; suspend.
	(Delay forMilliseconds: 10) wait.
	t4 := DateAndTime now.

	self 
		assert: (sw isSuspended);
		deny: (sw isActive);
		assert: (sw timespans size = 1);
		assert: (sw end between: t3 and: t4);
		assert: (t3 &lt; sw end);
		assert: (sw end &lt; t4).
</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMultipleTimings
	aStopwatch activate.
	aDelay wait.
	aStopwatch suspend.
	aStopwatch activate.
	aDelay wait.
	aStopwatch suspend.
	self assert: aStopwatch timespans size = 2. 
	self assert: aStopwatch timespans first asDateAndTime &lt; aStopwatch 
	timespans last asDateAndTime.
</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testReActivate

	| sw |
	sw := Stopwatch new.
	sw 
		activate;
		suspend;
		reActivate.
	
	self 
		assert: (sw isActive).
</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
	aStopwatch := Stopwatch new.
	aDelay := Delay forMilliseconds: 1.</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testChangingStatus
	aStopwatch activate.
	self assert: aStopwatch isActive.
	self assert: aStopwatch timespans size = 1.
	aStopwatch suspend.
	self assert: aStopwatch isSuspended.
	self assert: aStopwatch timespans size = 1.
	aStopwatch activate.
	aStopwatch reActivate.
	self assert: aStopwatch isActive.
	self assert: aStopwatch timespans size = 3.
	aStopwatch reset.
	self assert: aStopwatch isSuspended.
	self assert: aStopwatch timespans size = 0.</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testActive

	| sw |
	sw := Stopwatch new.
	sw activate.
	
	1 seconds asDelay wait.
	self 
		assert: (sw duration &gt;= 1 seconds).

	2 seconds asDelay wait.
	self 
		assert: (sw duration &gt;= 3 seconds).

	sw suspend.</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Stopwatch

</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testInitialStatus
	self assert: aStopwatch isSuspended.
	self deny: aStopwatch isActive.
	self assert: aStopwatch duration = 0 seconds</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testReset

	| sw |
	sw := Stopwatch new.
	sw activate.
	
	sw reset.
	self 
		assert: (sw isSuspended);
		assert: (sw timespans isEmpty)
</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: 'a Stopwatch(suspended:0:00:00:00)'.
	rw := ReadWriteStream on: ''.
	aStopwatch printOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testNew

	| sw |
	sw := Stopwatch new.
	
	self 
		assert: (sw isSuspended);
		assert: (sw state = #suspended);
		deny: (sw isActive);
		assert: (sw timespans isEmpty)

</body>
</methods>
<methods>
<class-id>Squeak.StopwatchTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSingleTiming
	| timeBefore |
	timeBefore := DateAndTime now.
	aStopwatch activate.
	aDelay wait.
	aStopwatch suspend.
	self assert: aStopwatch timespans size = 1. 
	self assert: aStopwatch timespans first asDateAndTime &gt; timeBefore. 
	self assert: aStopwatch timespans first asDateAndTime &lt; aStopwatch end.
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">seconds

	^ self second</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">storeOn: aStream

	aStream print: self printString; nextPutAll: ' asTime'</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">printMinutes
	"Return as string 'hh:mm pm'  "

	^String streamContents:
		[ :aStream | self print24: false showSeconds: false on: aStream ]
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">hour

	^ self hour24
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDateAndTime

	^ DateAndTime today + self</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDuration

	"Answer the duration since midnight"

	^ Duration seconds: seconds nanoSeconds: nanos
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asWeek

	^ self asDateAndTime asWeek</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">= aTime

	^ [ self ticks = aTime ticks ]
		on: MessageNotUnderstood do: [false]</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>private</category>
<body package="Squeak">ticks: anArray
	"ticks is an Array: { days. seconds. nanoSeconds }"

	seconds := anArray second.
	nanos := anArray third.</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">to: anEnd
	"Answer a Timespan. anEnd must respond to #asDateAndTime"

	^ self asDateAndTime to: anEnd</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTimeStamp

	^ self asDateAndTime asTimeStamp</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">hours

	^ self hour</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">nanoSecond


	^ nanos
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">&lt; aTime

	^ self asDuration &lt; aTime asDuration</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">print24: hr24 on: aStream 
	"Format is 'hh:mm:ss' or 'h:mm:ss am' "

	self print24: hr24 showSeconds: true on: aStream 
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">hhmm24
	"Return a string of the form 1123 (for 11:23 am), 2154 (for 9:54 pm), of exactly 4 digits"

	^(String streamContents: 
		[ :aStream | self print24: true showSeconds: false on: aStream ])
			copyWithout: $:</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asYear

	^ self asDateAndTime asYear</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asMonth

	^ self asDateAndTime asMonth</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">asSeconds
	"Answer the number of seconds since midnight of the receiver."

	^ seconds</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">printOn: aStream 

	self print24: false showSeconds: (self seconds ~= 0) on: aStream</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">subtractTime: timeAmount 
	"Answer a Time that is timeInterval before the receiver. timeInterval is  
	an instance of Date or Time."

	^ self class seconds: self asSeconds - timeAmount asSeconds</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">meridianAbbreviation

	^ self hour &lt; 12 ifTrue: ['AM'] ifFalse: ['PM'].
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">addTime: timeAmount
	"Answer a Time that is timeInterval after the receiver. timeInterval is an 
	instance of Date or Time."

	^ self class seconds: self asSeconds + timeAmount asSeconds</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">minutes

	^ self asDuration minutes</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">addSeconds: nSeconds 
	"Answer a Time that is nSeconds after the receiver."

	^ self class seconds: self asSeconds + nSeconds</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>deprecated</category>
<body package="Squeak">hours: anInteger

	self 
		deprecated: 'Deprecated';
		hours: anInteger minutes: 0 seconds: 0.
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">hour24


	^ self asDuration hours
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">duration

	^ Duration zero
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>deprecated</category>
<body package="Squeak">setSeconds: secondCount

	self 
		deprecated: 'Deprecated'.

	self ticks: (Array with: 0 with: secondCount with: 0)
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">minute

	^ self asDuration minutes</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTime

	^ self</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">hash

	^ self ticks hash
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asNanoSeconds
	"Answer the number of nanoseconds since midnight"

	^ self asDuration asNanoSeconds
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">second


	^ self asDuration seconds</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDate

	^ Date today</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>deprecated</category>
<body package="Squeak">hours: hourInteger minutes: minInteger seconds: secInteger

	self 
		deprecated: 'Deprecated';
		setSeconds: (hourInteger * SecondsInHour) + (minInteger * SecondsInMinute) + secInteger.		
</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>smalltalk-80</category>
<body package="Squeak">intervalString
	"Treat the time as a difference.  Give it in hours and minutes with two digits of accuracy."

	| d |
	d := self asDuration.
	^ String streamContents: [ :s |
		d hours &gt; 0 ifTrue: [s print: d hours; nextPutAll: ' hours'].
		d minutes &gt; 0 ifTrue: [s space; print: d minutes; nextPutAll: ' minutes'].
		d seconds &gt; 0 ifTrue: [s space; print: d seconds; nextPutAll: ' seconds'] ].

</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>private</category>
<body package="Squeak">ticks
	"Answer an Array: { seconds. nanoSeconds }"

	^ Array with: 0 with: seconds with: nanos.</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">print24
	"Return as 8-digit string 'hh:mm:ss', with leading zeros if needed"

	^String streamContents:
		[ :aStream | self print24: true on: aStream ]

</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>ansi protocol</category>
<body package="Squeak">hour12
	"Answer an &lt;integer&gt; between 1 and 12, inclusive, representing the hour 
	of the day in the 12-hour clock of the local time of the receiver."
	^ self hour24 - 1 \\ 12 + 1</body>
</methods>
<methods>
<class-id>Squeak.Time</class-id>
<category>printing</category>
<body package="Squeak">print24: hr24 showSeconds: showSeconds on: aStream 
	"Format is 'hh:mm:ss' or 'h:mm:ss am'  or, if showSeconds is false, 'hh:mm' or 'h:mm am'"

	| h m s |
	h := self hour. m := self minute. s := self second.
	hr24
	
	ifTrue: 
			[ h &lt; 10 ifTrue: [ aStream nextPutAll: '0' ].
	
		h printOn: aStream ]
	
	ifFalse:
			[ h &gt; 12
		
		ifTrue: [h - 12 printOn: aStream]
		
		ifFalse: 
			
		[h &lt; 1
		
				ifTrue: [ 12 printOn: aStream ]
						ifFalse: [ h printOn: aStream ]]].

	aStream nextPutAll: (m &lt; 10 ifTrue: [':0'] ifFalse: [':']).
	m printOn: aStream.

	showSeconds ifTrue:
	
	[ aStream nextPutAll: (s &lt; 10 ifTrue: [':0'] ifFalse: [':']).
		s asInteger printOn: aStream ].

	hr24 ifFalse:
	
	[ aStream nextPutAll: (h &lt; 12 ifTrue: [' am'] ifFalse: [' pm']) ].
</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">time
	"Answer the time of the receiver."

	^ self asTime</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">storeOn: aStream 

	aStream 
		print: self printString;
		nextPutAll: ' asTimeStamp'</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">plusDays: anInteger
	"Answer a TimeStamp which is anInteger days after the receiver."

	^ self + (anInteger days)</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTimeStamp
	"Answer the receiver as an instance of TimeStamp."

	^ self</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">date
	"Answer the date of the receiver."

	^ self asDate</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">dateAndTime
	"Answer a two element Array containing the receiver's date and time."

	^ Array with: self date with: self time</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>deprecated</category>
<body package="Squeak">time: aTime

	self deprecated: 'Deprecated'</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">minusSeconds: anInteger
	"Answer a TimeStamp which is anInteger number of seconds before the receiver."

	^ self - (anInteger seconds)</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>deprecated</category>
<body package="Squeak">date: aDate

	self deprecated: 'Deprecated'</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream 
	"Print receiver's date and time on aStream."

	aStream 
		nextPutAll: self date printString;
		space;
		nextPutAll: self time printString.</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">plusSeconds: anInteger
	"Answer a TimeStamp which is anInteger number of seconds after the receiver."

	^ self + (anInteger seconds)</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp</class-id>
<category>squeak protocol</category>
<body package="Squeak">minusDays: anInteger
	"Answer a TimeStamp which is anInteger days before the receiver."

	^ self - (anInteger days)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTimeStamp
	self assert: aTimeStamp = aTimeStamp asTimeStamp
</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| deprecated private special |

	deprecated := #( #&lt;= #&gt;= #&gt; ).
	private := #( #date: #time: #printOn: ).
	special := #( #&lt; #= ).

	^ super selectorsToBeIgnored, deprecated, private, special.</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPlusDays
	self assert: (aTimeStamp plusDays: 366) dateAndTime
			= (Array with: '01-02-2005' asDate with: '00:34:56' asTime)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testReadFromA1
	|ts|
	ts := TimeStamp current.
	self assert: (ts = (TimeStamp fromString: ts asString)).</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTime
	self assert: aTimeStamp time =  '00:34:56' asTime</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testComparing

	| ts1 ts2 ts3 c1 c2 le |
	ts1 := self timestampClass date: ('01-10-2000' asDate) time: ('11:55:00 am' asTime).
	ts2 := self timestampClass date: ('07-26-2003' asDate) time: ('22:09:45 am' asTime).
	ts3 := self timestampClass date: ('05-28-1972' asDate) time: ('04:31:14 pm' asTime).

	self
		assert: ts1 = timestamp;
		assert: ts1 hash = timestamp hash;
		assert: timestamp = timestamp copy;
		assert: ts1 &lt; ts2;
		deny: ts1 &lt; ts3.

	c1 := self timestampClass current.
	c2 := self timestampClass current.
	le := (c1 &lt;= c2).
	self assert: le.

</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">tearDown

	timestamp := nil.</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: '2 January 2004 12:34:56 am'.
	rw := ReadWriteStream on: ''.
	aTimeStamp printOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testArithmetic

	| ts |
	ts := timestamp minusDays: 123.  	"9 September 1999, 11:55 am"
	ts := ts minusSeconds: 1056.			"9 September 1999, 11:37:24 am"
	ts := ts plusDays: 123.				"10 January 2000, 11:37:24 am"
	ts := ts plusSeconds: 1056.			"10 January 2000, 11:55 am"
	self
		assert: ts  = timestamp.

	</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testSorting

	| c1 c2 |
	c1 := self timestampClass current.
	c2 := self timestampClass current.

	self
		assert: (self timestampClass current) &lt;= (self timestampClass current);
		assert: (c1 &lt;= c2).


</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testFromString
	"This should signal an exception in 3.6beta as Time&gt;&gt;fromString: does not exist."

	self should: [ timestamp = (self timestampClass fromString: '1-10-2000 11:55:00 am') ] 

</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testArithmeticAcrossDateBoundary

	| ts |
	ts := timestamp minusSeconds: ((11*3600) + (55*60) + 1).
	self
		assert: ts = ('1-9-2000 11:59:59 pm' asTimeStamp).

	</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinusSeconds
	self assert: (aTimeStamp minusSeconds: 34 * 60 + 56) dateAndTime
			= (Array with: '01-02-2004' asDate with: '00:00:00' asTime)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStoreOn
	| cs rw |
	cs := ReadStream on: '''2 January 2004 12:34:56 am'' asTimeStamp'.
	rw := ReadWriteStream on: ''.
	aTimeStamp storeOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDate
	self assert: aTimeStamp date = '01-02-2004' asDate</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testConverting

	| d t |
	d := '1-10-2000' asDate.
	t := '11:55:00 am' asTime.

	self
		assert: timestamp asSeconds = (d asSeconds + t asSeconds);
		assert: timestamp asDate = d;
		assert: timestamp asTime = t;
		assert: timestamp asTimeStamp == timestamp;
		assert: timestamp dateAndTime = (Array with: d with: t).
</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPlusSeconds
	self assert: (aTimeStamp plusSeconds: 60 * 60 ) dateAndTime
			= (Array with: '01-02-2004' asDate with: '01:34:56' asTime)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDateAndTime
	self assert: aTimeStamp dateAndTime
			= (Array with: '01-02-2004' asDate with: '00:34:56' asTime)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testAccessing

	| d t |
	d := '1-10-2000' asDate.
	t := '11:55:00 am' asTime.

	self
		assert: timestamp date = d;
		assert: timestamp time = t.
</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinusDays
	self assert: (aTimeStamp minusDays: 5) dateAndTime
			= (Array with: '12-28-2003' asDate with: '00:34:56' asTime)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPrinting

	self	
		assert: timestamp printString = '10 January 2000 11:55 am'.
</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">setUp

	timestamp := self timestampClass date: ('1-10-2000' asDate) time: ('11:55:00 am' asTime).

	aTimeStamp := TimeStamp readFrom: '1-02-2004 12:34:56 am' readStream</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinusSecondsOverMidnight
	self assert: (aTimeStamp minusSeconds: 34 * 60 + 57) dateAndTime
			= (Array with: '01-01-2004' asDate with: '23:59:59' asTime)
	"Bug The results are actual results are: #(1 January 2005 11:25:03 pm)"</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ self timestampClass</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInstanceCreation

	| warn |
	warn := Preferences showDeprecationWarnings.
	Preferences setPreference: #showDeprecationWarnings toValue: true.
	
	self 
		should: [ self timestampClass midnight asDuration = (0 hours) ];
		should: [ self timestampClass midnightOn: timestamp date ] 
			raise: Deprecation;
		should: [ self timestampClass noon asDuration = (12 hours) ];
		should: [ self timestampClass noonOn: timestamp date ] 
			raise: Deprecation.
			
	Preferences setPreference: #showDeprecationWarnings toValue: warn.
</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testFromSeconds

	self
		assert: (self timestampClass fromSeconds: 3124958100) = timestamp.</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPlusSecondsOverMidnight
	self assert: (aTimeStamp plusSeconds: 24 * 60 * 60 + 1) dateAndTime
			= (Array with: '01-03-2004' asDate with: '00:34:57' asTime)</body>
</methods>
<methods>
<class-id>Squeak.TimeStampTest</class-id>
<category>Private</category>
<body package="Squeak-Tests">timestampClass

	^ TimeStamp</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testEqual
	self assert: aTime = (Time readFrom: (ReadStream on: '12:34:56')).</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTimeStamp
	self assert: aTime = aTime asTimeStamp asTime</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinute
	self assert: aTime minute =  34.
	self assert: aTime minutes =  34
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTime
	self assert: (aTime asTime) = aTime

</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrint24On
	| cs rw |
	cs := ReadStream on: '12:34:56'.
	rw := ReadWriteStream on: ''.
	aTime print24: true on: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLessThan
	self assert: aTime &lt; (Time readFrom: (ReadStream on: '12:34:57')).</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSecond
	self assert: aTime second =  56.
	self assert: aTime seconds =  56
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDate
	self assert: (aTime asDate) = (Date current)
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testComparing
	| t1 t2 t3 |
	t1 := self timeClass fromSeconds: 14567.		"4:02:47 am"
	t2 := self timeClass fromSeconds: 5000.		"1:23:20 am"
	t3 := self timeClass fromSeconds: 80000.		"10:13:20 pm"

	self
		assert: time = t1;
		assert: time hash = t1 hash;
		assert: time = time copy.
	self
		deny: t1 &lt; t2;
		assert: t1 &lt; t3.</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHumanWordsForSecondsAgoWithDays

	self assert: (Time humanWordsForSecondsAgo: 18 * 60 * 60)
					= 'yesterday'.
	self assert: (Time humanWordsForSecondsAgo: 24 * 60 * 60)
					= 'yesterday'.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsSeconds
	self assert: (aTime asSeconds) = 45296
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDateAndTime
	self assert: (aTime asDateAndTime) = (DateAndTime current midnight + aTime)
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testSubtractTime
	self assert: (aTime subtractTime: aTime) = (Time readFrom: (ReadStream on: '00:00:00'))
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStoreOn
	| cs rw |
	cs := ReadStream on: '''12:34:56 pm'' asTime'.
	rw := ReadWriteStream on: ''.
	aTime storeOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testConverting

	self
		assert: time asSeconds = 14567.</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Private</category>
<body package="Squeak-Tests">timeClass

	^ Time</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrint24OnWithoutSeconds
	| cs rw |
	cs := ReadStream on: '12:34:56'.
	rw := ReadWriteStream on: ''.
	aTime print24: true showSeconds: true on: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testAccessing

	self
		assert: time hours = 4;
		assert: time minutes = 2;
		assert: time seconds = 47;
		assert: time asSeconds = 14567.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHumanWordsForSecondsAgo
	self assert: (Time humanWordsForSecondsAgo: 0.999999999)
			= 'a second ago'.
	self assert: (Time humanWordsForSecondsAgo: 44.99999999)
			= '44.99999999 seconds ago'.
	self assert: (Time humanWordsForSecondsAgo: 89.999999999)
			= 'a minute ago'.
	self assert: (Time humanWordsForSecondsAgo: 2699.999999999)
			= '44 minutes ago'.
	self assert: (Time humanWordsForSecondsAgo: 5399.999999999)
			= 'an hour ago'.
	self assert: (Time humanWordsForSecondsAgo: 64799.999999999)
			= '17 hours ago'.
	</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNanoSecond
	self assert: aTime nanoSecond = 0
	"Right now all times all seconds"
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintMinutes
	self assert: aTime printMinutes = '12:34 pm'</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHash
	self assert: aTime hash =  167741779.</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTicks
	self assert: aTime ticks = #(0 45296 0).
	self assert: aTime  = (Time new ticks: #(0 45296 0))</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMeridianAbbreviation
	self assert: aTime meridianAbbreviation =  'PM'.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsWeek
	self assert: aTime asWeek = (DateAndTime current midnight + aTime) asWeek
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testNew
	
	self assert: self timeClass new asSeconds = 0</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testSqueakInquiries
	| timewords totalseconds condensed corrected |
	self assert: 
		(self timeClass namesForTimes: #(2 10000023 10000026))
			= #('January, 1901' 'April, 1901, 4/26/1901, 5:47 pm' 'April, 1901, 4/26/1901, 5:47 pm').

	timewords := #(0.5 30 62 130 4000 10000 60000 90000) 
		collect: [ :ss | self timeClass humanWordsForSecondsAgo: ss ].
	self assert: 
		timewords = #('a second ago' '30 seconds ago' 'a minute ago' '2 minutes ago' 
			'an hour ago' '2 hours ago' '16 hours ago' 'yesterday').

	totalseconds :=  self timeClass totalSeconds.
	condensed := self timeClass condenseBunches: 
		(#(20 400 401  20000 20200 20300 40000 45000  200000 201000 202000) 
			collect: [:tt | totalseconds - tt]).
	corrected := condensed collect: [ :e | totalseconds - e ].
	self
		assert: (corrected includesAllOf: #(20 400 401 20000 40000 45000 200000)).
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testFromSeconds
	| t |
	t := self timeClass fromSeconds: 14567.
	self
		assert: t = time
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	 | deprecated private special primitives timing benchmarks |

	deprecated := #().
	private := #( #hours: #hours:minutes:seconds: #setSeconds: #print24:on: #print24:showSeconds:on: ).
	special := #( #&lt; #= #new #printOn: #storeOn: ).
	primitives := #( #primMillisecondClock #primSecondsClock ).
	timing := #( #millisecondClockValue #milliseconds:since: #millisecondsSince: ).
	benchmarks := #( #benchmarkMillisecondClock #benchmarkPrimitiveResponseDelay ). 

	^ super selectorsToBeIgnored, deprecated, private, special, primitives, timing, benchmarks.</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrint24OnWithPM
	| cs rw |
	cs := ReadStream on: '12:34:56 pm'.
	rw := ReadWriteStream on: ''.
	aTime print24: false on: rw.
	^ self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">tearDown
	DateAndTime localTimeZone: localTimeZoneToRestore.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAddTime
	self assert: (aTime addTime: aTime) = (Time readFrom: (ReadStream on: '01:09:52')).
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHour
	self assert: aTime hour =  12.
	self assert: aTime hour12 =  12.
	self assert: aTime hour24 =  12.
	self assert: aTime hours =  12.</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testArithmetic
	| t1 t2 t3 |
	t1 := time addSeconds: 70.		"4:03:57 am"
	self
		assert: t1 hours = 4;
		assert: t1 minutes = 3;
		assert: t1 seconds = 57.

	t2 := t1 addTime: (self timeClass fromSeconds: (60*60*5)).
	self
		assert: t2 hours = 9;
		assert: t2 minutes = 3;
		assert: t2 seconds = 57.

	t3 := t2 subtractTime: (self timeClass fromSeconds: (60*60*5) + 70).
	self
		assert: t3 = time.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHhmm24
	self assert: aTime hhmm24 = '1234'</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsYear
	self assert: aTime asYear = (DateAndTime current midnight + aTime) asYear
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: '12:34:56 pm'.
	rw := ReadWriteStream on: ''.
	aTime printOn: rw.
	self assert: rw contents = cs contents</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testGeneralInquiries
	| now d t dt |

	now  := self timeClass dateAndTimeNow.
	self 
		assert: now size = 2;
		assert: now last &lt;= self timeClass now.

	self should: [ self timeClass timeWords ] raise: MessageNotUnderstood.

	d := '2 June 1973' asDate.
	t := '4:02:47 am' asTime.
	dt := self timeClass dateAndTimeFromSeconds: (2285280000 + 14567).
	self
		assert: dt = (Array with: d with: t).
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAddSeconds
	self assert: (aTime addSeconds: 1) = (Time readFrom: (ReadStream on: '12:34:57')).
	self assert: (aTime addSeconds: 60) = (Time readFrom: (ReadStream on: '12:35:56')).	
	self assert: (aTime addSeconds: 3600) = (Time readFrom: (ReadStream on: '13:34:56')).
	self assert: (aTime addSeconds: 24*60*60) = (Time readFrom: (ReadStream on: '12:34:56')).</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testStoring

	self	
		assert: time storeString = '''4:02:47 am'' asTime';
		assert: time = ('4:02:47 am' asTime).
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrint24
	self assert: aTime print24 = '12:34:56'</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTimeStamp
	self assert: (aTime asTimeStamp) = (DateAndTime current midnight + aTime) asTimeStamp
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDuration
	self assert: (aTime asDuration) = (Duration days: 0 hours: 12 minutes: 34 seconds: 56)
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testReadFrom

	| string t |
	string := '4:02:47 am'.
	t := self timeClass readFrom: string readStream.

	self
		assert: time = t.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPrinting

	self	
		assert: time printString = '4:02:47 am';
		assert: time intervalString =  '4 hours 2 minutes 47 seconds';
		assert: time print24 = '04:02:47';
		assert: time printMinutes = '4:02 am';
		assert: time hhmm24 = '0402'.
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">setUp

	localTimeZoneToRestore := DateAndTime localTimeZone.
	DateAndTime localTimeZone: TimeZone default.
	time := self timeClass fromSeconds: 14567.		"4:02:47 am"
	aTime := Time readFrom: '12:34:56 pm' readStream
</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ self timeClass</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsNanoSeconds
	self assert: (aTime asNanoSeconds) = 45296000000000

</body>
</methods>
<methods>
<class-id>Squeak.TimeTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDuration
	self assert: aTime duration = 0 seconds</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>accessing</category>
<body package="Squeak">name: aString

	name := aString
</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>accessing</category>
<body package="Squeak">offset

	^ offset</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>accessing</category>
<body package="Squeak">abbreviation: aString

	abbreviation := aString
</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>accessing</category>
<body package="Squeak">name

	^ name
</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>accessing</category>
<body package="Squeak">abbreviation

	^ abbreviation
</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>private</category>
<body package="Squeak">printOn: aStream

	super printOn: aStream.
	aStream
		nextPut: $(;
		nextPutAll: self abbreviation;
		nextPut: $).</body>
</methods>
<methods>
<class-id>Squeak.TimeZone</class-id>
<category>accessing</category>
<body package="Squeak">offset: aDuration

	offset := aDuration</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDateAndTime

	^ start
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">months

	| months |
	months := OrderedCollection new: 12.
	self monthsDo: [ :m | months add: m ].
	^ months asArray.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDuration

	^ self duration</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">isLeapYear

	^ start isLeapYear
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asWeek

	^ start asWeek
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">= comparand

	^ (self start = comparand start) and: [self duration = comparand duration]
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">start: aDateAndTime
	"Store the start DateAndTime of this timespan"

	start := aDateAndTime asDateAndTime
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>private</category>
<body package="Squeak">do: aBlock with: aFirstElement

	self do: aBlock with: aFirstElement when: [ :t | true ].
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">previous


	^ self class starting: (start - duration) duration: duration
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInMonth


	^ start daysInMonth
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfWeek
	"Answer the day of the week represented by the receiver."

	^ start dayOfWeek</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>private</category>
<body package="Squeak">duration: aDuration
	"Set the Duration of this timespan"

	duration := aDuration
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">to: anEnd
	"Answer an Timespan. anEnd must be aDateAndTime or a Timespan"


	^ Timespan starting: (self start) ending: (anEnd asDateAndTime).
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInYear
	"Answer the number of days in the month represented by the receiver."

	^ start daysInYear
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTimeStamp

	^ start asTimeStamp</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">- operand
	"operand conforms to protocol DateAndTime or protocol Duration"

	^ (operand respondsTo: #asDateAndTime)

	 	ifTrue: [ self start - operand ]
	
	ifFalse: [ self + (operand negated) ].
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">day
	"Answer the day of the year represented by the receiver."
	^ self dayOfYear</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">monthsDo: aBlock

	self do: aBlock with: start asMonth.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">&lt; comparand

	^ self start &lt; comparand	
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>private</category>
<body package="Squeak">do: aBlock with: aFirstElement when: aConditionBlock

	| element end |
	element := aFirstElement.
	end := self end.
	[ element start &lt;= end ] whileTrue:
	
	[(aConditionBlock value: element)
			ifTrue: [ aBlock value: element ].
		element := element next. ]</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">includes: aDateAndTime


	^ (aDateAndTime isKindOf: Timespan)
			ifTrue: [ (self includes: aDateAndTime start)
						and: [ self includes: aDateAndTime end ] ]
			ifFalse: [ aDateAndTime asDateAndTime between: start and: self end ]
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">firstDayOfMonth

	^ start firstDayOfMonth</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">julianDayNumber


	^ start julianDayNumber
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">monthAbbreviation


	^ start monthAbbreviation
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asMonth


	^ start asMonth
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">monthName


	^ start monthName
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>deprecated</category>
<body package="Squeak">lastDate
 
	self deprecated: 'Use #end'.

	^ self end asDate</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">workDatesDo: aBlock
	"Exclude Saturday and Sunday"

	self do: aBlock with: start asDate when: [ :d | d dayOfWeek &lt; 6 ].
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">every: aDuration do: aBlock

	| element end |
	element := self start.
	end := self end.
	[ element &lt;= end ] whileTrue:
	
	[ aBlock value: element.
		element := element + aDuration. ]
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream


	super printOn: aStream.
	aStream 
		nextPut: $(;
		print: start;
		nextPut: $D;
		print: duration;
		nextPut: $).
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysLeftInYear
	^ start daysLeftInYear</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">yearsDo: aBlock

	self do: aBlock with: start asYear.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">monthIndex

	^ self month
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asYear


	^ start asYear</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfWeekName
	"Answer the day of the week represented by the receiver."

	^ start dayOfWeekName</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">intersection: aTimespan

	 "Return the Timespan both have in common, or nil"

	 | aBegin anEnd |
	 aBegin := self start max: aTimespan start.
	 anEnd := self end min: aTimespan end.
	 anEnd &lt; aBegin ifTrue: [^nil].

	 ^ self class starting: aBegin ending: anEnd.
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>deprecated</category>
<body package="Squeak">firstDate

	self deprecated: 'Use #start'.

	^ self start asDate</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfYear
	"Answer the day of the year represented by the receiver."

	^ start dayOfYear</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">dayOfMonth
	"Answer the day of the month represented by the receiver."

	^ start dayOfMonth</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">weeks


	| weeks |
	weeks := OrderedCollection new.
	self weeksDo: [ :m | weeks add: m ].
	^ weeks asArray.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">years


	| years |
	years := OrderedCollection new.
	self yearsDo: [ :m | years add: m ].
	^ years asArray.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">year


	^ start year
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">month

	^ start month
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">includesAllOf: aCollection 
	"Answer whether all the elements of aCollection are in the receiver."

	aCollection do: [:elem | (self includes: elem) ifFalse: [^ false]].
	^ true
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">duration
	"Answer the Duration of this timespan"

	^ duration
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">+ operand
	"operand conforms to protocol Duration"
	

	^ self class starting: (self start + operand) duration: self duration
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">weeksDo: aBlock

	self do: aBlock with: self asWeek.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">datesDo: aBlock


	self do: aBlock with: start asDate.
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asTime

	^ start asTime</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">union: aTimespan
	 "Return the Timespan spanned by both"

	| aBegin anEnd |

	aBegin := self start min: aTimespan start.
	anEnd := self end max: aTimespan end.
	^ Timespan starting: aBegin ending: (anEnd + DateAndTime clockPrecision).
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>ansi protocol</category>
<body package="Squeak">hash

	^ start hash + duration hash
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>smalltalk-80</category>
<body package="Squeak">next

	^ self class starting: (start + duration) duration: duration
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">asDate


	^ start asDate
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>enumerating</category>
<body package="Squeak">dates


	| dates |

	dates := OrderedCollection new.
	self datesDo: [ :m | dates add: m ].
	^ dates asArray.</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">includesAnyOf: aCollection 
	"Answer whether any element of aCollection is included in the receiver"

	aCollection do: [ :elem | (self includes: elem) ifTrue: [^ true]].
	^false
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">end


	^ self next start - DateAndTime clockPrecision 
</body>
</methods>
<methods>
<class-id>Squeak.Timespan</class-id>
<category>squeak protocol</category>
<body package="Squeak">start
	"Answer the start DateAndTime of this timespan"

	^ start
</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoSpanAYearTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
	aDate := DateAndTime
				year: 2004
				month: 12
				day: 25
				hour: 0
				minute: 0
				second: 0.
	aDuration := Duration
				days: 91
				hours: 0
				minutes: 0
				seconds: 0
				nanoSeconds: 0.
	aTimespan := Timespan starting: aDate duration: aDuration</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoSpanAYearTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testWeeksDo
	| weeks weekArray |
	weeks := aTimespan weeks.
	self assert: weeks size = ((aDuration days / 7.0) ceiling + 1).

	weekArray := OrderedCollection new.
	weekArray
		addLast: (Week starting: (DateAndTime year: 2004 month: 12 day: 26) duration: 7 days).

	2 to: 86 by: 7 do:
		[ :i | weekArray
				addLast: (Week starting: (DateAndTime year: 2005 day: i) duration: 7 days) ].

	weekArray := weekArray asArray.
	self assert: aTimespan weeks = weekArray
</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoSpanAYearTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMonthsDo

	| monthArray |

	monthArray := Array
				with: (Month starting: (DateAndTime year: 2004 day: 355) duration: 31 days)
				with: (Month starting: (DateAndTime year: 2005 day: 1) duration: 31 days)
				with: (Month starting: (DateAndTime year: 2005 day: 32) duration: 29 days)
				with: (Month starting: (DateAndTime year: 2005 day: 61) duration: 31 days).
				
	self assert: aTimespan months = monthArray</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoSpanAYearTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearsDo
	| yearArray |
	yearArray := Array
				with: (Year
						starting: (DateAndTime
								year: 2004
								month: 12
								day: 25)
						duration: 366 days).
	self assert: aTimespan years = yearArray
</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoSpanAYearTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNext

	self assert: aTimespan next
			= (Timespan
					starting: (DateAndTime
							year: 2005
							month: 3
							day: 26
							hour: 0
							minute: 0
							second: 0)
					duration: aDuration)</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMonthsDo
	| monthArray |
	monthArray := Array
				with: (Month
						starting: (DateAndTime year: 2003 day: 1)
						duration: 31 days)
				with: (Month
						starting: (DateAndTime year: 2003 day: 32)
						duration: 28 days)
				with: (Month
						starting: (DateAndTime year: 2003 day: 60)
						duration: 31 days)		
				with: (Month
						starting: (DateAndTime year: 2003 day: 91)
						duration: 30 days).
	self assert: aTimespan months = monthArray</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNext
	self assert: aTimespan next 
			= (Timespan
					starting: (DateAndTime
							year: 2003
							month: 4
							day: 8
							hour: 0
							minute: 0
							second: 0)
					duration: aDuration)</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearsDo
	| yearArray |
	yearArray := Array
				with: (Year
						starting: (DateAndTime year: 2003 day: 7)
						duration: 365 days).
	self assert: aTimespan years contents = yearArray contents</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDatesDo
	| dateArray |
	dateArray := OrderedCollection new.
	7
		to: 97
		do: [:each | dateArray
				addLast: (Date year: 2003 day: each)].
	dateArray := dateArray asArray.
	self assert: aTimespan dates = dateArray</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testWeeksDo
	| weekArray |
	weekArray := OrderedCollection new.
	7
		to: 98
		by: 7
		do: [:each | weekArray
				addLast: (Week
						starting: (DateAndTime year: 2003 day: each)
						duration: 7 days)].
	weekArray := weekArray asArray.
	self assert: aTimespan weeks = weekArray
</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDoWith
	| count |
	count := 0.
	aTimespan
		do: [:each | count := count + 1]
		with: (Timespan
				starting: aDate
				duration: 7 days).
	self assert: count = 13</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDoWithWhen
	| count |
	count := 0.
	aTimespan
		do: [:each | count := count + 1]
		with: (Timespan starting: aDate duration: 7 days)
		when: [:each | count &lt; 5].
	self assert: count = 5	
</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
	aDate := DateAndTime
				year: 2003
				month: 01
				day: 07
				hour: 0
				minute: 0
				second: 0.
	aDuration := Duration
				days: 91
				hours: 0
				minutes: 0
				seconds: 0
				nanoSeconds: 0.
	aTimespan := Timespan starting: aDate duration: aDuration</body>
</methods>
<methods>
<class-id>Squeak.TimespanDoTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testEveryDo
	|count  duration |
	count := 0.
	duration := 7 days.
	(aTimespan
			every: duration
			do: [:each | count := count + 1]).
	self assert: count = 13
			</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinusADateAndTime
	"It appears that subtracting a date from a Timespan gives you a duration = to the difference between the start of the timespan and the date "
	self assert: aTimespan - dec31 =  aDay.
	self assert: aDisjointTimespan - jan01 =  aWeek.


</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfWeek
	self assert: aTimespan  dayOfWeek  = 7.
	self assert: aTimespan  dayOfWeekName = 'Saturday'.
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIncludesAnyOf
	self deny: (aTimespan includesAnyOf: (Bag with: dec31)).
	self assert: (aTimespan includesAnyOf: (Bag with: jan01 with: jan08))
	"Error is due to bug in Timespan 
includesAnyOf: aCollection "
	"Answer whether any element of aCollection is included in the receiver"
	"aCollection do: [ :elem | (self includes: elem) ifTrue: [^ true]].
Shouldn't this return false if none are included?
"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTime
	self assert: aTimespan asTime =  jan01 asTime
	"MessageNotUnderstood: Time class&gt;&gt;seconds:nanoSeconds:"
 </body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testLessThan
	self assert: aTimespan  &lt; aDisjointTimespan.
	self deny: anIncludedTimespan &lt; aTimespan
	</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDoWithWhen
	| count |
	count := 0.
	aTimespan
		do: [:each | count := count + 1]
		with: (Timespan starting: jan01 duration: aDay)
		when: [:each | count &lt; 5].
	self assert: count = 5</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysLeftInYear
	self assert: aTimespan  daysLeftInYear  = 364.
	"MessageNotUnderstood: UndefinedObject&gt;&gt;starting:  UndefinedObject is Year class"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIntersectionWithOverlapping
	self assert: (aTimespan intersection: anOverlappingTimespan)  = 
	(Timespan starting: jan01 duration: (Duration days: 5 hours: 23 minutes: 59 seconds: 59 nanoSeconds: 999999999)).		

</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDay
	self assert: aTimespan day =   jan01 day
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDate
	self assert: aTimespan asDate =   jan01 asDate.
	"MessageNotUnderstood: Date class&gt;&gt;starting:"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testJulianDayNumber
	self assert: aTimespan julianDayNumber =  (jan01 julianDayNumber).
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfMonth
	self assert: aTimespan dayOfMonth  = 1.
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsMonth
	self assert: aTimespan asMonth =   jan01 asMonth.
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDoWith
	| count |
	count := 0.
	aTimespan
		do: [:each | count := count + 1]
		with: (Timespan starting: jan01 duration: aDay).
	self assert: count = 7</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDateAndTime
	self assert: aTimespan asDateAndTime =   jan01.
	"MessageNotUnderstood: Date class&gt;&gt;starting:"
	
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrevious
	self assert: aTimespan  = aDisjointTimespan previous.
	self assert: aTimespan next previous = aTimespan 
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIncludes
	self assert: (aTimespan includes: jan01).
	self deny: (aTimespan includes: jan08)
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYear
	self assert: aTimespan year = 2005.

	</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDayOfYear
	self assert: aTimespan  dayOfYear  = 1.
	"MessageNotUnderstood: UndefinedObject&gt;&gt;year:, Undefined object is Year class"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInclusion

	| t1 t2 t3 t4 |
	t1 := timespan start.
	t2 := timespan start + (timespan duration / 2).
	t3 := timespan end.
	t4 := timespan start + (timespan duration).

	self 
		assert: (timespan includes: t1);
		assert: (timespan includes: t2);
		assert: (timespan includes: t3)";
		deny: (timespan includes: t4).
	self
		assert: (timespan includes: (t1 to: t2));
		assert: (timespan includes: (t1 to: t4));
		deny: (timespan includes: (Timespan starting: t2 duration: (timespan duration * 2))).
	self 
		assert: (timespan includesAllOf: (Array with: t1 with: t2 with: t3) );
		deny: (timespan includesAllOf: (Array with: t1 with: t2 with: t3 with: t4) ).
	self 
		assert: (timespan includesAnyOf: (Array with: t1 with: t2 with: t3) );
		deny: (timespan includesAnyOf: (Array with: t4) ).
"</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testAccessing

	self 
		assert: (timespan start =
				 (DateAndTime year: 2003 month: 03 day: 22 hour: 12 minute: 0 second: 0));
		assert: timespan duration = (Duration hours: 100);
		assert: timespan month = 3;
		assert: timespan monthName = 'March';
		assert: timespan monthAbbreviation = 'Mar'
		

</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUnionWithSelf
	self assert: (aTimespan union: aTimespan) = aTimespan
	</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMinusADuration
	"It appears that subtracting a duration from a Timespan gives you a Timespan shifted by the duration"
	self assert: aTimespan - aDay =  anOverlappingTimespan.
	self assert: aDisjointTimespan - aWeek =  aTimespan.	


</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testWorkDatesDo
	| count |
	count := 0.
	aTimespan
		workDatesDo: [:each | count := count + 1].
	self assert: count = 5</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testHash
	self assert: aTimespan hash =     268333199
	"must be a more meaningful test?"</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testTo
	self assert: (anIncludedTimespan to: jan08) = aTimespan 
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNew
	self assert: Timespan new = (Timespan starting: '01-01-1901' asDate)</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStart
	self assert: aTimespan start =   jan01.
	aTimespan start: jan08.
	self assert: aTimespan start =   jan08.</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testNext
	self assert: aTimespan next = aDisjointTimespan
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsWeek
	self assert: aTimespan asWeek =   jan01 asWeek.
	"DateAndTime new asWeek
	 MessageNotUnderstood: Week class&gt;&gt;starting:"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUnionWithDisjoint

	self assert: (aTimespan union: aDisjointTimespan)  = 
		(Timespan starting: jan01 duration: (14 days)).	
			
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUnionWithIncluded

	self 
		assert: (aTimespan union: anIncludedTimespan) = aTimespan 	</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStartingEnding
	self assert: aTimespan  = (Timespan starting: jan01 ending: jan08)
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testEveryDo
	| count duration |
	count := 0.
	duration := 7 days.
	aTimespan
		every: duration
		do: [:each | count := count + 1].
	self assert: count = 1</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testFirstDayOfMonth
	self assert: aTimespan firstDayOfMonth =   1. 
	self assert: aDisjointTimespan firstDayOfMonth =   1
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUnionWithSeparate

	self 
		assert: (anOverlappingTimespan union: aDisjointTimespan) = 
			(Timespan 
				starting: anOverlappingTimespan start
				ending:  (aDisjointTimespan end + DateAndTime clockPrecision))
			
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIncludesAllOf
	self assert: (aTimespan includesAllOf: (Bag with: jan01)).
	self deny: (aTimespan includesAllOf: (Bag with: jan01 with: jan08))
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testUnion

	| union |
	union := timespan union: timespan.
	
	self 
		assert: (union start = timespan start);
		assert: (union duration = timespan duration)
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">tearDown
	DateAndTime localTimeZone: localTimeZoneToRestore.
	timespan := nil
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPrintOn
	| cs rw |
	cs := ReadStream on: 'a Timespan(2005-01-01T00:00:00+00:00D7:00:00:00)'.
	rw := ReadWriteStream on: ''.
	aTimespan  printOn: rw.
	self assert: rw contents = cs contents
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testArithmetic

	| ts1 ts2 d |
	ts1 := timespan + 2 days.
	ts2 := ts1 - 2 days.
	d := ts1 - (DateAndTime year: 2003 month: 03 day: 20).

	self 
		assert: (ts1 start = 
				 (DateAndTime year: 2003 month: 03 day: 24 hour: 12 minute: 0 second: 0));
		assert: (ts1 duration = timespan duration);
		assert: (ts2 start = timespan start);
		assert: (ts2 duration = timespan duration).

	self
		assert: d = (Duration days: 4 hours: 12 minutes: 0 seconds: 0)

</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testUnionWithOverlapping

	self 
		assert: (aTimespan union: anOverlappingTimespan)  = 
				(Timespan starting: dec31 duration: (8 days))</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsYear
	self assert: aTimespan asYear =   jan01 asYear.

</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInMonth
	self assert: aTimespan  daysInMonth  = 31.
	"MessageNotUnderstood: Month class&gt;&gt;starting:"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testEnd
	self assert: aTimespan end 	+ (Duration  nanoSeconds:1)  =  aDisjointTimespan
	"self assert: aTimespan end 	(DateAndTime year: 2005 month: 1 day: 7 hour: 23 minute: 59 second: 59 nanoSecond: 999999999 offset: 0 hours). "
	"This should work once DateAndTime &gt;&gt; year:month:day:hour:minute:second:nanoSecond:offset: is fixed"

</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIntersectionWithSelf
	self assert: (aTimespan intersection: aTimespan)  = 
	(Timespan starting: jan01 duration: (Duration days: 6 hours: 23 minutes: 59 seconds: 59 nanoSeconds: 999999999)).		
	self deny: (aTimespan intersection: anIncludedTimespan)	= aTimespan
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsDuration
	self assert: aTimespan asDuration =  aWeek.

	
	
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIntersectionWithDisjoint
	self assert: (aTimespan intersection: aDisjointTimespan) isNil.
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testAsTimeStamp
	self assert: aTimespan asTimeStamp =  ((TimeStamp readFrom: '1-01-2005 0:00 am' readStream) offset: 0 hours).
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIsLeapYear
	"self assert: anOverlappingTimespan isLeapYear."
	"not sure why this fails"
	self deny: aTimespan isLeapYear
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMonth
	self assert: aTimespan month  = 1.
	self assert: aTimespan monthName = 'January'.
	self assert: aTimespan monthIndex = 1.</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIntersectionWithIncluded
	self assert: (aTimespan intersection: anIncludedTimespan)  = 
	(Timespan starting: jan01 duration: (Duration days: 0 hours: 23 minutes: 59 seconds: 59 nanoSeconds: 999999999)).		
	self deny: (aTimespan intersection: anIncludedTimespan)	= anIncludedTimespan
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIntersectionWithSeparate
	self assert: (aTimespan intersection: aDisjointTimespan) isNil.
	self deny: (aTimespan intersection: anOverlappingTimespan) isNil.
	self assert: (aTimespan intersection: anIncludedTimespan)  = 
	(Timespan starting: jan01 duration: (Duration days: 0 hours: 23 minutes: 59 seconds: 59 nanoSeconds: 999999999)).		
	self deny: (aTimespan intersection: anIncludedTimespan)	= anIncludedTimespan
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">setUp

	localTimeZoneToRestore := DateAndTime localTimeZone.
	DateAndTime localTimeZone: TimeZone default.

	"100 hours starting noon 22 March 2003"
	timespan := Timespan starting:
					(DateAndTime year: 2003 month: 03 day: 22 hour: 12 minute: 0 second: 0)
						duration: (Duration hours: 100).

	dec31 := (DateAndTime year: 2004 month: 12 day: 31 hour: 0 minute: 0 second: 0).
	jan01 := (DateAndTime year: 2005 month: 1 day: 1 hour: 0 minute: 0 second: 0).
	jan08 := (DateAndTime year: 2005 month: 1 day: 8 hour: 0 minute: 0 second:0).
	aDay := Duration days: 1 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0.
	aWeek := Duration days: 7 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0.
	aTimespan := Timespan starting: jan01 duration: aWeek.
	anOverlappingTimespan := Timespan starting: dec31 duration: aWeek.
	anIncludedTimespan := Timespan starting: jan01 duration: aDay.
	aDisjointTimespan := Timespan starting: jan08 duration: aWeek.



</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInYear
	self assert: aTimespan  daysInYear  = 365.
	"MessageNotUnderstood: UndefinedObject&gt;&gt;starting:  UndefinedObject is Year class"
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testPlus
	self assert: aTimespan + aWeek = aDisjointTimespan.
	self assert: anOverlappingTimespan + aDay = aTimespan.
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Timespan
</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testCurrent
	self assert: (Timespan starting: DateAndTime current)
			&lt;= Timespan current.
	self assert:  Timespan current
			&lt;= (Timespan starting: DateAndTime current)</body>
</methods>
<methods>
<class-id>Squeak.TimespanTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDuration
	self assert: aTimespan duration  = aWeek.
	aTimespan duration: aDay.
	self assert: aTimespan duration =  aDay.

</body>
</methods>
<methods>
<class-id>Squeak.Week</class-id>
<category>deprecated</category>
<body package="Squeak">indexInMonth: aMonth
	"1=first week, 2=second week, etc."

	self deprecated: 'obsolete'.

	^ (Date dayOfWeek: aMonth dayOfWeekName) + self dayOfMonth - 2  // 7 + 1
</body>
</methods>
<methods>
<class-id>Squeak.Week</class-id>
<category>deprecated</category>
<body package="Squeak">index

	self deprecated: 'obsolete'.

	^ self indexInMonth: self asMonth
 
</body>
</methods>
<methods>
<class-id>Squeak.Week</class-id>
<category>squeak protocol</category>
<body package="Squeak">asWeek

	^ self
</body>
</methods>
<methods>
<class-id>Squeak.Week</class-id>
<category>deprecated</category>
<body package="Squeak">do: aBlock

	self deprecated: 'Use #datesDo:'.

	self datesDo: aBlock</body>
</methods>
<methods>
<class-id>Squeak.Week</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream

	aStream nextPutAll: 'a Week starting: '.
	self start printOn: aStream.
</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">tearDown

	super tearDown.
	week := nil.

</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Week</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">selectorsToBeIgnored

	| deprecated private special |

	deprecated := #( #startMonday #toggleStartMonday).
	private := #( #indexInMonth: #printOn: ).
	special := #( #next #do: ).

	^ super selectorsToBeIgnored, deprecated, private, special.</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testEnumerating

	| days |
	days := OrderedCollection new.
	0 to: 6 do: [ :i | days add: ('29 June 1998' asDate addDays: i) ].

	week do: [ :d | days remove: d ].
	
	self assert: days isEmpty.
</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testPreviousNext

	self
		assert: week next = (Week fromDate: '6 July 1998' asDate);
		assert: week previous = (Week fromDate: '22 June 1998' asDate).

</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Running</category>
<body package="Squeak-Tests">setUp
	"June 1998, 5th week"

	super setUp.

	Week startMonday ifFalse: [ Week toggleStartMonday ].
	week := Week fromDate: '4 July 1998' asDate.
</body>
</methods>
<methods>
<class-id>Squeak.WeekTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testInquiries

	self
		assert: week firstDate = '29 June 1998' asDate;
		assert: week lastDate = '5 July 1998' asDate;
		assert: week index = 5;
		assert: week duration = (7 days).
</body>
</methods>
<methods>
<class-id>Squeak.Year</class-id>
<category>squeak protocol</category>
<body package="Squeak">daysInMonth


	self shouldNotImplement 
</body>
</methods>
<methods>
<class-id>Squeak.Year</class-id>
<category>squeak protocol</category>
<body package="Squeak">asYear


	^ self
</body>
</methods>
<methods>
<class-id>Squeak.Year</class-id>
<category>squeak protocol</category>
<body package="Squeak">daysInYear

	^ self duration days.</body>
</methods>
<methods>
<class-id>Squeak.Year</class-id>
<category>squeak protocol</category>
<body package="Squeak">printOn: aStream

	aStream nextPutAll: 'a Year ('.
	self start year printOn: aStream.

	aStream nextPutAll: ')'.
</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIsLeapYear
	self assert: (Year isLeapYear: 2000).
	self deny: (Year isLeapYear: 2001).
	self assert: (Year isLeapYear: 2004).
	self deny: (Year isLeapYear: 2100).
	self deny: (Year isLeapYear: 2002).</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testWeekPrintOn

	|aWeek cs rw |

	aWeek := Week starting: DateAndTime new duration: 7 days. 
	cs := 'a Week starting: 1900-12-31T00:00:00+00:00'.
	rw := WriteStream on: ''.
	aWeek printOn: rw.
	self assert: rw contents = cs</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testIndexOfDay
	self assert: (Week indexOfDay: 'Friday') = 6.

</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testYearPrintOn
    	|aYear cs rw |
	aYear := 	Year starting: DateAndTime new duration: 365 days. 
	cs := ReadStream on: 'a Year (1901)'.
	rw := ReadWriteStream on: ''.
     aYear printOn: rw.
     self assert: rw contents = cs contents.</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInYear
	self assert: (Year daysInYear: 2000) = 366.
	self assert: (Year daysInYear: 2001) = 365.
	self assert: (Year daysInYear: 2004) = 366.
	self assert: (Year daysInYear: 2100) = 365.
	self assert: (Year daysInYear: 2003) = 365.</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>running</category>
<body package="Squeak-Tests">setUp
	restoredStartDay := Week startDay</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testMonthPrintOn
    	|aMonth cs rw |
	aMonth := 	Month starting: DateAndTime new duration: 31 days.  
	cs := ReadStream on: 'January 1901'.
	rw := ReadWriteStream on: ''.
     aMonth printOn: rw.
     self assert: rw contents = cs contents.</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>running</category>
<body package="Squeak-Tests">tearDown
	Week startDay: restoredStartDay</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testDaysInMonth
	self assert: (Month daysInMonth: 2 forYear: 2000) = 29.
	self assert: (Month daysInMonth: 2 forYear: 2001) = 28.
	self assert: (Month  daysInMonth: 2 forYear: 2004) = 29.
	self assert: (Month  daysInMonth: 2 forYear: 2100) = 28.
	
	self assert: (Month  daysInMonth: 'January' forYear: 2003) = 31.
	self assert: (Month  daysInMonth: 'February' forYear: 2003) = 28.
	self assert: (Month  daysInMonth: 'March' forYear: 2003) = 31.
	self assert: (Month  daysInMonth: 'April' forYear: 2003) = 30.
	self assert: (Month  daysInMonth: 'May' forYear: 2003) = 31.
	self assert: (Month  daysInMonth: 'June' forYear: 2003) = 30.
	self assert: (Month  daysInMonth: 'July' forYear: 2003) = 31.
	self assert: (Month  daysInMonth: 'August' forYear: 2003) = 31.
	self assert: (Month  daysInMonth: 'September' forYear: 2003) = 30.
	self assert: (Month  daysInMonth: 'October' forYear: 2003) = 31.
	self assert: (Month  daysInMonth: 'November' forYear: 2003) = 30.
	self assert: (Month  daysInMonth: 'December' forYear: 2003) = 31.</body>
</methods>
<methods>
<class-id>Squeak.YearMonthWeekTest</class-id>
<category>testing</category>
<body package="Squeak-Tests">testStartDay
	Week startDay: 'Wednesday'.
	self assert: Week startDay = 'Wednesday'.
	Week startDay: 'Thursday'.
	self assert: Week startDay = 'Thursday'.

</body>
</methods>
<methods>
<class-id>Squeak.YearTest</class-id>
<category>Tests</category>
<body package="Squeak-Tests">testCurrent

	| yyyy |

	yyyy := DateAndTime now year.
	
	self assert: Year current start = (DateAndTime year: yyyy month: 1 day: 1)</body>
</methods>
<methods>
<class-id>Squeak.YearTest</class-id>
<category>Coverage</category>
<body package="Squeak-Tests">classToBeTested

	^ Year</body>
</methods>
<methods>
<class-id>Squeak.ChronologyConstants class</class-id>
<category>as yet unclassified</category>
<body package="Squeak">initialize
	"ChronologyConstants initialize" 	SqueakEpoch := 2415386. 		"Julian day number of 1 Jan 1901" 
	SecondsInDay := 86400.
	SecondsInHour := 3600.
	SecondsInMinute := 60.
	NanosInSecond := 10 raisedTo: 9.
	NanosInMillisecond := 10 raisedTo: 6.
	DayNames := #(Sunday Monday Tuesday Wednesday Thursday Friday Saturday).
		
	MonthNames := #(January February March April May June July
 			August September October November December).
	DaysInMonth := #(31 28 31 30 31 30 31 31 30 31 30 31).
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: year day: dayOfYear

	^ self starting: (DateAndTime year: year day: dayOfYear)
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">julianDayNumber: aJulianDayNumber

	^ self starting: (DateAndTime julianDayNumber: aJulianDayNumber)</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: aDateAndTime

	^super starting: (aDateAndTime midnight) duration: (Duration days: 1)
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">dateAndTimeNow
	"Answer an Array whose with Date today and Time now."

	^ Time dateAndTimeNow</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">readFrom: aStream 
	"Read a Date from the stream in any of the forms:  
	
		&lt;day&gt; &lt;monthName&gt; &lt;year&gt;		(5 April 1982; 5-APR-82)  
	
		&lt;monthName&gt; &lt;day&gt; &lt;year&gt;		(April 5, 1982)  
	
		&lt;monthNumber&gt; &lt;day&gt; &lt;year&gt;		(4/5/82) 
			&lt;day&gt;&lt;monthName&gt;&lt;year&gt;			(5APR82)"
	| day month year |
	aStream peek isDigit
		ifTrue: [day := Integer readFrom: aStream].
	[aStream peek isAlphaNumeric]
		whileFalse: [aStream skip: 1].
	aStream peek isLetter
		ifTrue: ["number/name... or name..."
			month := WriteStream
						on: (String new: 10).
			[aStream peek isLetter]
				whileTrue: [month nextPut: aStream next].
			month := month contents.
			day isNil
				ifTrue: ["name/number..."
					[aStream peek isAlphaNumeric]
						whileFalse: [aStream skip: 1].
					day := Integer readFrom: aStream]]
		ifFalse: ["number/number..."
			month := Month nameOfMonth: day.
			day := Integer readFrom: aStream].
	[aStream peek isAlphaNumeric]
		whileFalse: [aStream skip: 1].
	year := Integer readFrom: aStream.
	year &lt; 10 ifTrue: [year := 2000 + year] 
		ifFalse: [ year &lt; 1900 ifTrue: [ year := 1900 + year]].

	^ self
		year: year
		month: month
		day: day</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>deprecated</category>
<body package="Squeak">yearAndDaysFromDays: days into: aTwoArgBlock

	self deprecated: 'Deprecated'</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">fromSeconds: seconds
	"Answer an instance of me which is 'seconds' seconds after January 1, 1901."

	^ self fromDays: ((Duration seconds: seconds) days)</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">nameOfDay: dayIndex 

	^ Week nameOfDay: dayIndex </body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInMonth: monthName forYear: yearInteger 

	^ Month daysInMonth: monthName forYear: yearInteger.
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">nameOfMonth: anIndex 

	^ Month nameOfMonth: anIndex.
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: year month: month day: day

	^ self starting: (DateAndTime year: year month: month day: day)
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">today

	^ self current</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">dayOfWeek: dayName 

	^ Week indexOfDay: dayName</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">newDay: dayCount year: yearInteger

	^ self year: yearInteger day: dayCount</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>deprecated</category>
<body package="Squeak">absoluteDaysToYear: gregorianYear

	self deprecated: 'Deprecated'</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInYear: yearInteger 

	^ Year daysInYear: yearInteger.</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">indexOfMonth: aMonthName 

	^ Month indexOfMonth: aMonthName.
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">fromDays: dayCount 
	"Days since 1 January 1901"

	^ self julianDayNumber: dayCount + SqueakEpoch</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">yesterday

	^ self today previous</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>deprecated</category>
<body package="Squeak">fromJulianDayNumber: aJulianDayNumber

	self 
		deprecated: 'Deprecated';
		julianDayNumber: aJulianDayNumber</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">fromString: aString
	"Answer an instance of created from a string with format dd.mm.yyyy."

	^ self readFrom: aString readStream.
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">firstWeekdayOfMonth: month year: year
	"Answer the weekday index of the first day in &lt;month&gt; in the &lt;year&gt;."

	^ (self newDay: 1 month: month year: year) weekdayIndex
</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">newDay: day month: month year: year 

	^ self year: year month: month day: day</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>squeak protocol</category>
<body package="Squeak">tomorrow

	^ self today next</body>
</methods>
<methods>
<class-id>Squeak.Date class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">leapYear: yearInteger 

	^ Year leapYear: yearInteger</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>ansi protocol</category>
<body package="Squeak">clockPrecision
	"One nanosecond precision"

	^ Duration nanoSeconds: 1
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: year day: dayOfYear
	"Return a DateAndTime"

	^ self
		year: year
		day: dayOfYear
		hour: 0
		minute: 0
		second: 0</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">localTimeZone: aTimeZone
	"Set the local time zone"

	"
	DateAndTime localTimeZone: (TimeZone offset:  0 hours name: 'Universal Time' abbreviation: 'UTC').
	DateAndTime localTimeZone: (TimeZone offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST').
	"

	LocalTimeZone := aTimeZone


</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>ansi protocol</category>
<body package="Squeak">year: year day: dayOfYear hour: hour minute: minute second: second

	^ self
		year: year
		day: dayOfYear
		hour: hour
		minute: minute
		second: second
		offset: self localOffset.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">julianDayNumber: aJulianDayNumber

	^ self basicNew
		ticks: aJulianDayNumber days ticks offset: self localOffset;
		yourself
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">new
	"Answer a DateAndTime representing the Squeak epoch: 1 January 1901"

	^ self epoch
	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: year month: month day: day hour: hour minute: minute

	"Return a DateAndTime" 	^ self
 		year: year
 		month: month
 		day: day
 		hour: hour
		minute: minute
		second: 0</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">localTimeZone
	"Answer the local time zone"

	^ LocalTimeZone ifNil: [ LocalTimeZone := TimeZone default ]

</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">noon

	^ self now noon</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">current


	^ self now
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">readFrom: aStream
	| bc year month day hour minute second nanos offset buffer ch |


	aStream peek = $- ifTrue: [ aStream next. bc := -1] ifFalse: [bc := 1].
	year := (aStream upTo: $-) asInteger * bc.
	month := (aStream upTo: $-) asInteger.
	day := (aStream upTo: $T) asInteger.
	hour := (aStream upTo: $:) asInteger.
 	buffer := '00:'. ch := nil.
	minute := WriteStream on: buffer.
	[ aStream atEnd | (ch = $:) | (ch = $+) | (ch = $-) ]
		whileFalse: [ ch := minute nextPut: aStream next. ].
	(ch isNil or: [ch isDigit]) ifTrue: [ ch := $: ].
	minute := ((ReadStream on: buffer) upTo: ch) asInteger.
	buffer := '00.'.
	second := WriteStream on: buffer.
	[ aStream atEnd | (ch = $.) | (ch = $+) | (ch = $-) ]
		whileFalse: [ ch := second nextPut: aStream next. ].
	(ch isNil or: [ch isDigit]) ifTrue: [ ch := $. ].
	second := ((ReadStream on: buffer) upTo: ch) asInteger.
	buffer := '00000000+'.
	nanos := WriteStream on: buffer.
	[ aStream atEnd | (ch = $+) | (ch = $-) ]
		whileFalse: [ ch := nanos nextPut: aStream next. ].
	(ch isNil or: [ch isDigit]) ifTrue: [ ch := $+ ].
	nanos := ((ReadStream on: buffer) upTo: ch) asInteger.
	aStream atEnd
		ifTrue: [ offset := self localOffset ]
	
	ifFalse:
		 	[offset := Duration fromString: (ch asString, '0:', aStream upToEnd).
	
		(offset = self localOffset) ifTrue: [ offset := self localOffset ]].
	^ self
		year: year
		month: month
		day: day
		hour: hour
		minute: minute

		second: second
		nanoSecond:  nanos

		offset: offset.


	"	'-1199-01-05T20:33:14.321-05:00' asDateAndTime
		' 2002-05-16T17:20:45.00000001+01:01' asDateAndTime
  		' 2002-05-16T17:20:45.00000001' asDateAndTime
 		' 2002-05-16T17:20' asDateAndTime
		' 2002-05-16T17:20:45' asDateAndTime
		' 2002-05-16T17:20:45+01:57' asDateAndTime
 		' 2002-05-16T17:20:45-02:34' asDateAndTime
 		' 2002-05-16T17:20:45+00:00' asDateAndTime
		' 1997-04-26T01:02:03+01:02:3' asDateAndTime 
 	"
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">fromSeconds: seconds
	"Answer a DateAndTime since the Squeak epoch: 1 January 1901"

	| since |
	since := Duration days: SqueakEpoch hours: 0 minutes: 0 seconds: seconds.
	^ self basicNew
		ticks: since ticks offset: self localOffset;
		yourself.
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>ansi protocol</category>
<body package="Squeak">now
	^ self basicNew 
		ticks: (Duration 
				days: SqueakEpoch 
				hours: 0 
				minutes: 0 
				seconds: self totalSeconds 
				nanoSeconds: 0) ticks
		offset: self localOffset;
		yourself
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: year month: month day: day hour: hour minute: minute second: second nanoSecond: nanoCount offset: offset
	"Return a DateAndTime"

	| monthIndex p q r s julianDayNumber since |

	monthIndex := month isInteger ifTrue: [month] ifFalse: [Month indexOfMonth: month].
	p := (monthIndex - 14) quo: 12.
	q := year + 4800 + p.
	r := monthIndex - 2 - (12 * p).
	s := (year + 4900 + p) quo: 100.

	julianDayNumber :=
 		( (1461 * q) quo: 4 ) +
			( (367 * r) quo: 12 ) -
 				( (3 * s) quo: 4 ) +
 					( day - 32075 ).

	since := Duration days: julianDayNumber hours: hour 
				minutes: minute seconds: second nanoSeconds: nanoCount.

	^ self basicNew
 		ticks: since ticks offset: offset;
		yourself.</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">date: aDate time: aTime

	^ self 
		year: aDate year 
		day: aDate dayOfYear 
		hour: aTime hour 
		minute: aTime minute 
		second: aTime second
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: year month: month day: day
	"Return a DateAndTime, midnight local time" 	^ self
 		year: year
 		month: month
 		day: day
 		hour: 0
		minute: 0</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">totalSeconds

	^ Time totalSeconds</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>ansi protocol</category>
<body package="Squeak">year: year month: month day: day hour: hour minute: minute second: second
	"Return a DateAndTime"

	^ self
		year: year
		month: month
		day: day
		hour: hour
		minute: minute
		second: second
		offset: self localOffset
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">today

	^ self midnight
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">localOffset
	"Answer the duration we are offset from UTC"

	^ self localTimeZone offset
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">millisecondClockValue

	^ Time millisecondClockValue</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>ansi protocol</category>
<body package="Squeak">year: year month: month day: day hour: hour minute: minute second: second offset: offset

	^ self
		year: year
		month: month
		day: day
		hour: hour
		minute: minute
		second: second
		nanoSecond: 0
		offset: offset
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">epoch
	"Answer a DateAndTime representing the Squeak epoch: 1 January 1901"

	^ self julianDayNumber: SqueakEpoch
	</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">midnight

	^ self now midnight
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">yesterday

	^ self today asDate previous asDateAndTime
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">fromString: aString


	^ self readFrom: (ReadStream on: aString)
</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>squeak protocol</category>
<body package="Squeak">tomorrow

	^ self today asDate next asDateAndTime</body>
</methods>
<methods>
<class-id>Squeak.DateAndTime class</class-id>
<category>ansi protocol</category>
<body package="Squeak">year: year day: dayOfYear hour: hour minute: minute second: second offset: offset 
	"Return a DataAndTime"

	| y d |
	y := self
		year: year
		month: 1
		day: 1
		hour: hour
		minute: minute
		second: second
		nanoSecond: 0
		offset: offset.

	d := Duration days: (dayOfYear - 1).

	^ y + d</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">weeks: aNumber

	^ self days: (aNumber * 7) hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">days: aNumber

	^ self days: aNumber hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">milliSeconds: milliCount


	^ self days: 0 hours: 0 minutes: 0 seconds: 0 nanoSeconds: 
			(milliCount * (10 raisedToInteger: 6))
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">month: aMonth
	"aMonth is an Integer or a String"
	
	^ (Month month: aMonth year: Year current year) duration
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">hours: aNumber


	^ self days: 0 hours: aNumber minutes: 0 seconds: 0 nanoSeconds: 0</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: nanos

 	^ self nanoSeconds: 
			( ( (days * SecondsInDay) 
				+ (hours * SecondsInHour)
					+ (minutes * SecondsInMinute) 
						+ seconds ) * NanosInSecond )
							+ nanos.
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">nanoSeconds: nanos

	^ self new
		seconds: (nanos quo: NanosInSecond) 
		nanoSeconds: (nanos rem: NanosInSecond) rounded;
		yourself.
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">readFrom: aStream
	"Formatted as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]
	To assiste DateAndTime&gt;&gt;#readFrom: SS may be unpadded or absent."

	| sign days hours minutes seconds nanos ws ch |
	sign := (aStream peekFor: $-) ifTrue: [-1] ifFalse: [1].

	days := (aStream upTo: $:) asInteger sign: sign.
	hours := (aStream upTo: $:) asInteger sign: sign.
	minutes := (aStream upTo: $:) asInteger sign: sign.

	aStream atEnd 
		ifTrue: [seconds := 0. nanos := 0]
		ifFalse: 
			[ ws := String new writeStream.
			[ch := aStream next. (ch isNil) | (ch = $.)]
				whileFalse: [ ws nextPut: ch ].
			seconds := ws contents asInteger sign: sign.
			ws reset.
			9 timesRepeat: 
				[ ch := aStream next. 
				ws nextPut: (ch ifNil: [$0] ifNotNil: [ch]) ].
			nanos := ws contents asInteger sign: sign].

	^ self days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: nanos.

	"	'0:00:00:00' asDuration
		'0:00:00:00.000000001' asDuration
		'0:00:00:00.999999999' asDuration
		'0:00:00:00.100000000' asDuration
		'0:00:00:00.10' asDuration
		'0:00:00:00.1' asDuration
		'0:00:00:01' asDuration
		'0:12:45:45' asDuration
		'1:00:00:00' asDuration
		'365:00:00:00' asDuration
		'-7:09:12:06.10' asDuration
		'+0:01:02' asDuration
		'+0:01:02:3' asDuration
 	"
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>ansi protocol</category>
<body package="Squeak">days: days hours: hours minutes: minutes seconds: seconds

	^ self days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: 0.</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>ansi protocol</category>
<body package="Squeak">zero

	^ (self basicNew) seconds: 0 nanoSeconds: 0; yourself.
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">fromString: aString


	^ self readFrom: (ReadStream on: aString)
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>ansi protocol</category>
<body package="Squeak">seconds: aNumber

	^ (self basicNew) seconds: aNumber nanoSeconds: 0; yourself.
</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">minutes: aNumber

	^ self days: 0 hours: 0 minutes: aNumber seconds: 0 nanoSeconds: 0</body>
</methods>
<methods>
<class-id>Squeak.Duration class</class-id>
<category>squeak protocol</category>
<body package="Squeak">seconds: seconds nanoSeconds: nanos

	^ self days: 0 hours: 0 minutes: 0 seconds: seconds nanoSeconds: nanos
</body>
</methods>
<methods>
<class-id>Squeak.Month class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: aDateAndTime duration: aDuration 
	"Override - a each month has a defined duration"
	| start adjusted days |
	start := aDateAndTime asDateAndTime.
	adjusted := DateAndTime
				year: start year
				month: start month
				day: 1.
	days := self daysInMonth: adjusted month forYear: adjusted year.
	^ super
		starting: adjusted
		duration: (Duration days: days)</body>
</methods>
<methods>
<class-id>Squeak.Month class</class-id>
<category>squeak protocol</category>
<body package="Squeak">readFrom: aStream

	| m y c |
	m := (ReadWriteStream with: '') reset.
	[(c := aStream next) isSeparator] whileFalse: [m nextPut: c].
	[(c := aStream next) isSeparator] whileTrue.
	y := (ReadWriteStream with: '') reset.
	y nextPut: c.
	[aStream atEnd] whileFalse: [y nextPut: aStream next].

	^ self 
		month: m contents
		year: y contents

"Month readFrom: 'July 1998' readStream"
</body>
</methods>
<methods>
<class-id>Squeak.Month class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInMonth: indexOrName forYear: yearInteger 

	| index |
	index := indexOrName isInteger 
				ifTrue: [indexOrName]
				ifFalse: [self indexOfMonth: indexOrName].
	^ (DaysInMonth at: index)
			+ ((index = 2
					and: [Year isLeapYear: yearInteger])
						ifTrue: [1] ifFalse: [0])</body>
</methods>
<methods>
<class-id>Squeak.Month class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">nameOfMonth: anIndex

	^ MonthNames at: anIndex.</body>
</methods>
<methods>
<class-id>Squeak.Month class</class-id>
<category>squeak protocol</category>
<body package="Squeak">month: month year: year
	"Create a Month for the given &lt;year&gt; and &lt;month&gt;.
	&lt;month&gt; may be a number or a String with the
	name of the month. &lt;year&gt; should be with 4 digits."

	^ self starting: (DateAndTime year: year month: month day: 1)
</body>
</methods>
<methods>
<class-id>Squeak.Month class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">indexOfMonth: aMonthName


	1 to: 12 do: [ :i |  (aMonthName, '*' match: (MonthNames at: i)) ifTrue: [^i] ].
	self error: aMonthName , ' is not a recognized month name'.</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>benchmarks</category>
<body package="Squeak">benchmarkMillisecondClock		"Time benchmarkMillisecondClock"
	"Benchmark the time spent in a call to Time&gt;&gt;millisecondClockValue.
	On the VM level this tests the efficiency of calls to ioMSecs()."
	"PII/400 Windows 98: 0.725 microseconds per call"
	| temp1 temp2 temp3 delayTime nLoops time |
	delayTime := 5000. "Time to run benchmark is approx. 2*delayTime"

	"Don't run the benchmark if we have an active delay since
	we will measure the additional penalty in the primitive dispatch
	mechanism (see #benchmarkPrimitiveResponseDelay)."
	Delay anyActive ifTrue:[
		^self notify:'Some delay is currently active.
Running this benchmark will not give any useful result.'].

	"Flush the cache for this benchmark so we will have
	a clear cache hit for each send to #millisecondClockValue below"
	Object flushCache.
	temp1 := 0.
	temp2 := self. "e.g., temp1 == Time"
	temp3 := self millisecondClockValue + delayTime.

	"Now check how often we can run the following loop in the given time"
	[temp2 millisecondClockValue &lt; temp3]
		whileTrue:[temp1 := temp1 + 1].

	nLoops := temp1. "Remember the loops we have run during delayTime"

	"Setup the second loop"
	temp1 := 0.
	temp3 := nLoops.

	"Now measure how much time we spend without sending #millisecondClockValue"
	time := Time millisecondClockValue.
	[temp1 &lt; temp3]
		whileTrue:[temp1 := temp1 + 1].
	time := Time millisecondClockValue - time.

	"And compute the number of microseconds spent per call to #millisecondClockValue"
	^((delayTime - time * 1000.0 / nLoops) truncateTo: 0.001) printString,
		' microseconds per call to Time&gt;&gt;millisecondClockValue'</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">milliseconds: currentTime since: lastTime
	"Answer the elapsed time since last recorded in milliseconds.
	Compensate for rollover."

	| delta |
	delta := currentTime - lastTime.
	^ delta &lt; 0
		ifTrue: [SmallInteger maxVal + delta]
		ifFalse: [delta]
</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">hour: hour minute: minute second: second
	"Answer a Time"

	^ self hour: hour minute: minute second: second nanoSecond: 0</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">dateAndTimeFromSeconds: secondCount

	^ Array
		with: (Date fromSeconds: secondCount)
		with: (Time fromSeconds: secondCount \\ 86400)
</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">millisecondsSince: lastTime
	"Answer the elapsed time since last recorded in milliseconds.
	Compensate for rollover."

	^self milliseconds: self millisecondClockValue since: lastTime</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>benchmarks</category>
<body package="Squeak">benchmarkPrimitiveResponseDelay	"Time benchmarkPrimitiveResponseDelay"
	"Benchmark the overhead for primitive dispatches with an active Delay.
	On the VM level, this tests the efficiency of ioLowResMSecs."

	"PII/400 Windows98: 0.128 microseconds per prim"

	"ar 9/6/1999: This value is *extremely* important for stuff like sockets etc.
	I had a bad surprise when Michael pointed this particular problem out:
	Using the hardcoded clock() call for ioLowResMSecs on Win32 resulted in an overhead
	of 157.4 microseconds per primitive call - meaning you can't get no more than
	approx. 6000 primitives per second on my 400Mhz PII system with an active delay!
	BTW, it finally explains why Squeak seemed soooo slow when running PWS or 
	other socket stuff. The new version (not using clock() but some Windows function) 
	looks a lot better (see above; approx. 8,000,000 prims per sec with an active delay)."

	| nLoops bb index baseTime actualTime delayTime |
	delayTime := 5000. "Time to run this test is approx. 3*delayTime"

	Delay anyActive ifTrue:[
		^self notify:'Some delay is currently active.
Running this benchmark will not give any useful result.'].

	bb := Array new: 1. "The object we send the prim message to"

	"Compute the # of loops we'll run in a decent amount of time"
	[(Delay forMilliseconds: delayTime) wait] 
		forkAt: Processor userInterruptPriority.

	nLoops := 0.
	[Delay anyActive] whileTrue:[
		bb basicSize; basicSize; basicSize; basicSize; basicSize; 
			basicSize; basicSize; basicSize; basicSize; basicSize.
		nLoops := nLoops + 1.
	].

	"Flush the cache and make sure #basicSize is in there"
	Object flushCache.
	bb basicSize.

	"Now run the loop without any active delay
	for getting an idea about its actual speed."
	baseTime := self millisecondClockValue.
	index := nLoops.
	[index &gt; 0] whileTrue:[
		bb basicSize; basicSize; basicSize; basicSize; basicSize; 
			basicSize; basicSize; basicSize; basicSize; basicSize.
		index := index - 1.
	].
	baseTime := self millisecondClockValue - baseTime.

	"Setup the active delay but try to never make it active"
	[(Delay forMilliseconds: delayTime + delayTime) wait] 
		forkAt: Processor userInterruptPriority.

	"And run the loop"
	actualTime := self millisecondClockValue.
	index := nLoops.
	[index &gt; 0] whileTrue:[
		bb basicSize; basicSize; basicSize; basicSize; basicSize; 
			basicSize; basicSize; basicSize; basicSize; basicSize.
		index := index - 1.
	].
	actualTime := self millisecondClockValue - actualTime.

	"And get us some result"
	^((actualTime - baseTime) * 1000 asFloat / (nLoops * 10) truncateTo: 0.001) printString,
		' microseconds overhead per primitive call'</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">dateAndTimeNow
	"Answer a two-element Array of (Date today, Time now)."

	^ self dateAndTimeFromSeconds: self totalSeconds</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">new
	"Answer a Time representing midnight"

	^ self midnight</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>instance creation</category>
<body package="Squeak">noon
	"Answer a new instance at noon."

	^self fromSeconds: 43200</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">readFrom: aStream
	"Read a Time from the stream in the form:
		&lt;hour&gt;:&lt;minute&gt;:&lt;second&gt; &lt;am/pm&gt;

	&lt;minute&gt;, &lt;second&gt; or &lt;am/pm&gt; may be omitted.  e.g. 1:59:30 pm; 8AM; 15:30"

	| hour minute second ampm |
	hour := Integer readFrom: aStream.
	minute := 0.
	second := 0.
	(aStream peekFor: $:) ifTrue:
	
	[ minute := Integer readFrom: aStream.
		(aStream peekFor: $:) ifTrue: [ second := Integer readFrom: aStream ]].
	aStream skipSeparators.
	(aStream atEnd not and: [aStream peek isLetter]) ifTrue: 
		[ampm := aStream next asLowercase.
	
	(ampm = $p and: [hour &lt; 12]) ifTrue: [hour := hour + 12].
		(ampm = $a and: [hour = 12]) ifTrue: [hour := 0].
	
	(aStream peekFor: $m) ifFalse: [aStream peekFor: $M ]].

	^ self hour: hour minute: minute second: second

	"Time readFrom: (ReadStream on: '2:23:09 pm')"
</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">current 

	^ self now</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">seconds: seconds
	"Answer a Time from midnight"

	^ self seconds: seconds nanoSeconds: 0</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">fromSeconds: secondCount 
	"Answer an instance of me that is secondCount number of seconds since midnight."

	^ self seconds: secondCount
</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>ansi protocol</category>
<body package="Squeak">now
	"Answer a Time representing the time right now - this is a 24 hour clock."

	^ self seconds: self totalSeconds \\ 86400.
</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">totalSeconds
	"Answer the total seconds since the Squeck epoch: 1 January 1901."

	^ self primSecondsClock</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">hour: hour minute: minute second: second  nanoSecond: nanoCount
	"Answer a Time - only second precision for now"

	^ self 
		seconds: (hour * SecondsInHour) + (minute * SecondsInMinute) + second 
		nanoSeconds: nanoCount</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>general inquiries</category>
<body package="Squeak">condenseBunches: aCollectionOfSeconds
	| secArray pause now out prev bunchEnd ago |
	"Identify the major intervals in a bunch of numbers.  
	Each number is a seconds since 1901 that represents a date and time.
	We want the last event in a bunch.  Return array of seconds for:
	
	Every event in the last half hour.
		Every bunch separated by 30 min in the last 24 hours.
	
	Every bunch separated by two hours before that."

	"Time condenseBunches: 
		(#(20 400 401  20000 20200 20300 40000 45000  200000 201000 202000) 
			collect: [ :tt | self totalSeconds - tt])
"

	secArray := aCollectionOfSeconds asSortedCollection.
	pause := 1.
	now := self totalSeconds.
	out := OrderedCollection new.
	prev := 0.
	bunchEnd := nil.
	secArray reverseDo: [:secs | "descending"
		ago := now - secs.
		ago &gt; (60*30) ifTrue: [pause := "60*30" 1800].
		ago &gt; (60*60*24) ifTrue: [pause := "60*120" 7200].
		ago - prev &gt;= pause ifTrue: [out add: bunchEnd.  bunchEnd := secs].
		prev := ago].
	out add: bunchEnd.
	out removeFirst.
	^ out</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>general inquiries</category>
<body package="Squeak">namesForTimes: arrayOfSeconds
	| simpleEnglish prev final prevPair myPair |
	"Return English descriptions of the times in the array.  They are each seconds since 1901.  If two names are the same, append the date and time to distinguish them."

	simpleEnglish := arrayOfSeconds collect: [:secsAgo |
		self humanWordsForSecondsAgo: self totalSeconds - secsAgo].
	prev := ''.
	final := simpleEnglish copy.
	simpleEnglish withIndexDo: [:eng :ind | 
		eng = prev ifFalse: [eng]
			ifTrue: ["both say 'a month ago'"
				prevPair := self dateAndTimeFromSeconds: 
						(arrayOfSeconds at: ind-1).
				myPair := self dateAndTimeFromSeconds: 
						(arrayOfSeconds at: ind).
				(final at: ind-1) = prev ifTrue: ["only has 'a month ago'"
					final at: ind-1 put: 
							(final at: ind-1), ', ', prevPair first mmddyyyy].
				final at: ind put: 
							(final at: ind), ', ', myPair first mmddyyyy.
				prevPair first = myPair first 
					ifTrue: [
						(final at: ind-1) last == $m ifFalse: ["date but no time"
							final at: ind-1 put: 
								(final at: ind-1), ', ', prevPair second printMinutes].
						final at: ind put: 
							(final at: ind), ', ', myPair second printMinutes]].
		prev := eng].
	^ final</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>general inquiries</category>
<body package="Squeak">millisecondClockValue
	"Answer the number of milliseconds since the millisecond clock was last reset or rolled over.
	Answer 0 if the primitive fails."

	&lt;primitive: 135&gt;
	^ 0</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">millisecondsToRun: timedBlock 
	"Answer the number of milliseconds timedBlock takes to return its value."

	| initialMilliseconds |
	initialMilliseconds := self millisecondClockValue.
	timedBlock value.
	^ self millisecondClockValue - initialMilliseconds</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>instance creation</category>
<body package="Squeak">midnight
	"Answer a new instance at midnight."

	^self fromSeconds: 0</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>instance creation</category>
<body package="Squeak">fromString: aString
	"Answer a new instance for the value given by aString.

	 Time fromString: '11:55:23 am'
	"

	^self readFrom: (ReadStream on: aString)</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">primMillisecondClock
	"Primitive. Answer the number of milliseconds since the millisecond clock
	 was last reset or rolled over. Answer zero if the primitive fails.
	 Optional. See Object documentation whatIsAPrimitive."

	&lt;primitive: 135&gt;
	^ 0</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>general inquiries</category>
<body package="Squeak">humanWordsForSecondsAgo: secs
	| date today |
	"Return natural language for this date and time in the past."

	secs &lt;= 1 ifTrue: [^ 'a second ago'].
	secs &lt; 45 ifTrue: [^ secs printString, ' seconds ago'].
	secs &lt; 90 ifTrue: [^ 'a minute ago'].
	secs &lt; "45*60" 2700 ifTrue: [^ (secs//60) printString, ' minutes ago'].
	secs &lt; "90*60" 5400 ifTrue: [^ 'an hour ago'].
	secs &lt; "18*60*60" 64800 ifTrue: [^ (secs//3600) printString, ' hours ago'].
	date := Date fromSeconds: self totalSeconds - secs.		"now work with dates"
	today := Date today.
	date &gt; (today subtractDays: 2) ifTrue: [^ 'yesterday'].
	date &gt; (today subtractDays: 8) ifTrue: [^ 'last ', date dayOfWeekName].
	date &gt; (today subtractDays: 13) ifTrue: [^ 'a week ago'].
	date &gt; (today subtractDays: 28) ifTrue: [
		^ ((today subtractDate: date)//7) printString, ' weeks ago'].
	date &gt; (today subtractDays: 45) ifTrue: [^ 'a month ago'].
	date &gt; (today subtractDays: 300) ifTrue: [^ 'last ', date monthName].
	^ date monthName, ', ', date year printString

"Example
#(0.5 30 62 130 4000 10000 60000 90000 345600 864000 1728000 3456000 17280000 34560000 345600000) 
		collect: [:ss | Time humanWordsForSecondsAgo: ss].
"</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">primSecondsClock
	"Answer the number of seconds since 00:00 on the morning of
	 January 1, 1901 (a 32-bit unsigned number).
	 Essential. See Object documentation whatIsAPrimitive. "

	&lt;primitive: 137&gt;
	self primitiveFailed</body>
</methods>
<methods>
<class-id>Squeak.Time class</class-id>
<category>squeak protocol</category>
<body package="Squeak">seconds: seconds nanoSeconds: nanoCount
	"Answer a Time from midnight"

	^ self basicNew
		ticks: (Duration seconds: seconds nanoSeconds: nanoCount) ticks;
		yourself
</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp class</class-id>
<category>deprecated</category>
<body package="Squeak">midnightOn: aDate
	"Answer a new instance that represents aDate at midnight."

	^ self 
		deprecatedExplanation: 'Deprecated';
		date: aDate time: Time midnight</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp class</class-id>
<category>deprecated</category>
<body package="Squeak">noonOn: aDate
	"Answer a new instance that represents aDate at noon."

	^ self 
		deprecatedExplanation: 'Deprecated';
		date: aDate time: Time noon</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp class</class-id>
<category>ansi protocol</category>
<body package="Squeak">now

	| ts ticks |
	ts := super now.
	
	ticks := ts ticks.
	ticks at: 3 put: 0.
	ts ticks: ticks offset: ts offset.
	
	^ ts</body>
</methods>
<methods>
<class-id>Squeak.TimeStamp class</class-id>
<category>squeak protocol</category>
<body package="Squeak">current

	^ self now
		
</body>
</methods>
<methods>
<class-id>Squeak.TimeZone class</class-id>
<category>accessing</category>
<body package="Squeak">timeZones

	^ OrderedCollection new
		add: (self offset:  0 hours name: 'Universal Time' abbreviation: 'UTC');
		add: (self offset:  0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT');
		add: (self offset:  0 hours name: 'British Summer Time' abbreviation: 'BST');
		add: (self offset:  2 hours name: 'South African Standard Time' abbreviation: 'SAST');
		add: (self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST');
		add: (self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT');
		asArray

</body>
</methods>
<methods>
<class-id>Squeak.TimeZone class</class-id>
<category>accessing</category>
<body package="Squeak">default
	"Answer the default time zone - GMT"

	^ self timeZones detect: [ :tz | tz offset = Duration zero ]
</body>
</methods>
<methods>
<class-id>Squeak.TimeZone class</class-id>
<category>instance creation</category>
<body package="Squeak">offset: aDuration name: aName abbreviation: anAbbreviation

	^ self new
		offset: aDuration;
		name: aName;
		abbreviation: anAbbreviation;
		yourself</body>
</methods>
<methods>
<class-id>Squeak.Timespan class</class-id>
<category>squeak protocol</category>
<body package="Squeak">new
	"Answer a Timespan starting on the Squeak epoch: 1 January 1901"

	^ self starting: DateAndTime new
</body>
</methods>
<methods>
<class-id>Squeak.Timespan class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: startDateAndTime ending: endDateAndTime

	^ self 
		starting: startDateAndTime 
		duration: (endDateAndTime asDateAndTime - startDateAndTime).
</body>
</methods>
<methods>
<class-id>Squeak.Timespan class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: aDateAndTime duration: aDuration

	^ self basicNew
 		start: aDateAndTime asDateAndTime;
		duration: aDuration;
		yourself.</body>
</methods>
<methods>
<class-id>Squeak.Timespan class</class-id>
<category>squeak protocol</category>
<body package="Squeak">current


	^ self starting: DateAndTime now
</body>
</methods>
<methods>
<class-id>Squeak.Timespan class</class-id>
<category>deprecated</category>
<body package="Squeak">fromDate: aDate

	^ self
		deprecated: 'Use #starting: ';
		starting: aDate
</body>
</methods>
<methods>
<class-id>Squeak.Timespan class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: aDateAndTime


	^ self starting: aDateAndTime duration: Duration zero
</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>squeak protocol</category>
<body package="Squeak">indexOfDay: aSymbol

	^ DayNames indexOf: aSymbol
</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>deprecated</category>
<body package="Squeak">startMonday

	self deprecated: 'Use #startDay'.

	^ self startDay = #Monday</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: aDateAndTime duration: aDuration
	"Override - the duration is always one week.
	 Week will start from the Week class&gt;&gt;startDay"

	| midnight delta adjusted |
	midnight := aDateAndTime asDateAndTime midnight.
	delta := ((midnight dayOfWeek + 7 - (DayNames indexOf: self startDay)) rem: 7) abs.
	adjusted := midnight - (Duration days: delta hours: 0 minutes: 0 seconds: 0).

	^ super starting: adjusted duration: (Duration weeks: 1).</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>squeak protocol</category>
<body package="Squeak">startDay

	^ StartDay
ifNil: [ StartDay
 := DayNames first ]</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>squeak protocol</category>
<body package="Squeak">startDay: aSymbol

	(DayNames includes: aSymbol)
		ifTrue: [ StartDay := aSymbol ]
		ifFalse: [ self error: aSymbol, ' is not a recognised day name' ]
</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">nameOfDay: anIndex

	^ DayNames at: anIndex
</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>deprecated</category>
<body package="Squeak">toggleStartMonday

	self deprecated: 'Use #startDay:'.

	(self startDay = #Monday)
		ifTrue: [ self startDay: #Sunday ]
		ifFalse: [ self startDay: #Monday ]</body>
</methods>
<methods>
<class-id>Squeak.Week class</class-id>
<category>squeak protocol</category>
<body package="Squeak">dayNames

	^ DayNames
</body>
</methods>
<methods>
<class-id>Squeak.Year class</class-id>
<category>squeak protocol</category>
<body package="Squeak">starting: aDateAndTime duration: aDuration 
	"Override - start from midnight"
	| midnight |
	midnight := aDateAndTime asDateAndTime midnight.

	^ super
		starting: midnight
		duration: (Duration days: (self daysInYear: midnight year)).</body>
</methods>
<methods>
<class-id>Squeak.Year class</class-id>
<category>squeak protocol</category>
<body package="Squeak">current
 
	^ self year: (DateAndTime now year)
</body>
</methods>
<methods>
<class-id>Squeak.Year class</class-id>
<category>squeak protocol</category>
<body package="Squeak">year: aYear

	^ self starting: (DateAndTime year: aYear month: 1 day: 1).</body>
</methods>
<methods>
<class-id>Squeak.Year class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">daysInYear: yearInteger

	^ 365 + ((self isLeapYear: yearInteger) ifTrue: [1] ifFalse: [0]).
</body>
</methods>
<methods>
<class-id>Squeak.Year class</class-id>
<category>smalltalk-80</category>
<body package="Squeak">leapYear: yearInteger 

	^ (self isLeapYear: yearInteger)
		ifTrue: [1]
		ifFalse: [0]</body>
</methods>
<methods>
<class-id>Squeak.Year class</class-id>
<category>squeak protocol</category>
<body package="Squeak">isLeapYear: aYearInteger


	| adjustedYear |
	adjustedYear := aYearInteger &gt; 0
		ifTrue: [aYearInteger]
		ifFalse: [(aYearInteger + 1) negated].

	"There was no year 0"
	^ ((adjustedYear \\ 4 ~= 0) or: [(adjustedYear \\ 100 = 0) and: [adjustedYear \\ 400 ~= 0]]) not.</body>
</methods>
<initialize>
<class-id>Squeak.ChronologyConstants</class-id>
</initialize>
</st-source>
