David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
Save existing TimeZone instances in the package preamble and migrate them to FixedTimeZone in the postscript.
=============== Diff against Chronology-Core-mt.82 ===============
Item was added: + (PackageInfo named: 'Chronology-Core') preamble: '"below, add code to be run before the loading of this package" + + "Remember all instances of TimeZone. These will become FixedTimeZone in the postscript" + TimeZone instSize = 3 ifTrue: [ + Smalltalk at: #TimeZoneInstances put: + (Dictionary newFrom: ( + TimeZone allInstances collect: [:tz | + tz -> { tz offset . tz name . tz abbreviation }]))]. + '!
Item was changed: ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') ----- localOffset: aDuration "Override the local time zone (for testing). This disables the #automaticTimezone: preference" + self localTimeZone: (FixedTimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO'). - self localTimeZone: (TimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO'). !
Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now + "Answer time now as reported by #primitiveUtcWithOffset. If the automaticTimeZone + preference is false, use the offset provided by LocalTimeZone rather than the offset + provided by the primitive." - "Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not - available, answer the Posix epoch GMT."
self automaticTimezone ifTrue: [ ^ self basicNew initializeFromPrimitive ] ifFalse: [ | timeArray | timeArray := Time posixMicrosecondClockWithOffset. ^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ] !
Item was added: + TimeZone subclass: #FixedTimeZone + instanceVariableNames: 'offset abbreviation name' + classVariableNames: '' + poolDictionaries: 'ChronologyConstants' + category: 'Chronology-Core'! + + !FixedTimeZone commentStamp: 'dtl 6/20/2023 08:07' prior: 0! + FixedTimeZone is a simple class to collect the information identifying a UTC time zone. It is typically used in unit tests to specify specific time zone offsets. + + offset - Duration - the time zone's offset from UTC + abbreviation - String - the abbreviated name for the time zone. + name - String - the name of the time zone. + + StaticTimeZone class >> #timeZones returns an array of the known time zones + StaticTimeZone class >> #default returns the default time zone (Greenwich Mean Time) + !
Item was added: + ----- Method: FixedTimeZone class>>allTimeZones (in category 'accessing') ----- + allTimeZones + + ^ self timeZones , self timeZonesDST!
Item was added: + ----- Method: FixedTimeZone class>>default (in category 'accessing') ----- + default + "Answer the default time zone - GMT" + + ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was added: + ----- Method: FixedTimeZone class>>offset:name:abbreviation: (in category 'instance creation') ----- + offset: aDuration name: aName abbreviation: anAbbreviation + + ^ self new + offset: aDuration; + name: aName; + abbreviation: anAbbreviation; + yourself + !
Item was added: + ----- Method: FixedTimeZone class>>timeZones (in category 'accessing') ----- + timeZones + ^{ + self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'. + self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'. + self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'. + self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'. + self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'. + self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'. + self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'. + self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'. + }!
Item was added: + ----- Method: FixedTimeZone class>>timeZonesDST (in category 'accessing') ----- + timeZonesDST + ^{ + self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'. + self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'. + self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'. + self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'. + self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'. + self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'. + }!
Item was added: + ----- Method: FixedTimeZone>>abbreviation (in category 'accessing') ----- + abbreviation + + ^ abbreviation!
Item was added: + ----- Method: FixedTimeZone>>abbreviation: (in category 'accessing') ----- + abbreviation: aString + + abbreviation := aString!
Item was added: + ----- Method: FixedTimeZone>>name (in category 'accessing') ----- + name + + ^ name!
Item was added: + ----- Method: FixedTimeZone>>name: (in category 'accessing') ----- + name: aString + + name := aString!
Item was added: + ----- Method: FixedTimeZone>>offset: (in category 'accessing') ----- + offset: aDuration + + offset := aDuration + !
Item was added: + ----- Method: FixedTimeZone>>offsetAt: (in category 'accessing') ----- + offsetAt: dateAndTime + "A FixedTimeZone has a constant offset, ignoring daylight savings time transitions" + + ^ offset + !
Item was added: + ----- Method: FixedTimeZone>>printOn: (in category 'private') ----- + printOn: aStream + + super printOn: aStream. + aStream + nextPut: $(; + nextPutAll: self abbreviation; + nextPut: $)!
Item was changed: Object subclass: #TimeZone + instanceVariableNames: '' - instanceVariableNames: 'offset abbreviation name' classVariableNames: '' poolDictionaries: 'ChronologyConstants' category: 'Chronology-Core'!
+ !TimeZone commentStamp: 'dtl 6/15/2023 22:27' prior: 0! + A TimeZone answers the UTC offset for a DateAndTime based on local rules for a geographic region. For each regional time zone, the UTC offset varies as a function of the DateAndTime, notably in support of daylight savings time changes. The UTC offset for a TimeZone also may change over time as local rules are updated for various regions and political jurisdictions. - !TimeZone commentStamp: 'dtl 7/11/2009 15:03' prior: 0! - TimeZone is a simple class to colect the information identifying a UTC time zone.
+ Concrete subclasses are expected to implement UTC offset rules. The simple case of FixedTimeZone implements a time zone with constant offset, which is useful for unit test support.! - offset - Duration - the time zone's offset from UTC - abbreviation - String - the abbreviated name for the time zone. - name - String - the name of the time zone. - - TimeZone class >> #timeZones returns an array of the known time zones - TimeZone class >> #default returns the default time zone (Grenwich Mean Time) - !
Item was added: + ----- Method: TimeZone class>>allForOffset: (in category 'accessing') ----- + allForOffset: aDuration + + ^ self allTimeZones select: [:ea | ea offset = aDuration]!
Item was added: + ----- Method: TimeZone class>>allTimeZones (in category 'accessing') ----- + allTimeZones + "Various concrete implementations may be available. These may include a + simple StaticTimeZone or e.g. the TZ-Olson time zone tables with daylight + savings time offset transitions." + + ^ self allSubclasses + inject: OrderedCollection new + into: [ :result :cls | + (cls class includesLocalSelector: #allTimeZones) + ifTrue: [result addAll: cls allTimeZones]. + result]. + !
Item was changed: ----- Method: TimeZone class>>default (in category 'accessing') ----- default "Answer the default time zone - GMT"
+ ^ FixedTimeZone default! - ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was removed: - ----- Method: TimeZone class>>offset:name:abbreviation: (in category 'instance creation') ----- - offset: aDuration name: aName abbreviation: anAbbreviation - - ^ self new - offset: aDuration; - name: aName; - abbreviation: anAbbreviation; - yourself - !
Item was removed: - ----- Method: TimeZone class>>timeZones (in category 'accessing') ----- - timeZones - ^{ - self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'. - self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'. - self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'. - self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'. - self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'. - self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'. - self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'. - self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'. - }!
Item was removed: - ----- Method: TimeZone class>>timeZonesDST (in category 'accessing') ----- - timeZonesDST - ^{ - self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'. - self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'. - self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'. - self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'. - self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'. - self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'. - }!
Item was changed: ----- Method: TimeZone>>abbreviation (in category 'accessing') ----- abbreviation
+ ^ self subclassResponsibility! - ^ abbreviation!
Item was removed: - ----- Method: TimeZone>>abbreviation: (in category 'accessing') ----- - abbreviation: aString - - abbreviation := aString!
Item was changed: ----- Method: TimeZone>>name (in category 'accessing') ----- name
+ ^ self subclassResponsibility! - ^ name!
Item was removed: - ----- Method: TimeZone>>name: (in category 'accessing') ----- - name: aString - - name := aString!
Item was changed: ----- Method: TimeZone>>offset (in category 'accessing') ----- offset + "Answer the current offset"
+ ^ self offsetAt: DateAndTime basicNew initializeFromPrimitive - ^ offset !
Item was removed: - ----- Method: TimeZone>>offset: (in category 'accessing') ----- - offset: aDuration - - offset := aDuration - !
Item was added: + ----- Method: TimeZone>>offsetAt: (in category 'accessing') ----- + offsetAt: dateAndTime + + ^ self subclassResponsibility + !
Item was removed: - ----- Method: TimeZone>>printOn: (in category 'private') ----- - printOn: aStream - - super printOn: aStream. - aStream - nextPut: $(; - nextPutAll: self abbreviation; - nextPut: $)!
Item was changed: + (PackageInfo named: 'Chronology-Core') postscript: '"Let all old instances of TimeZone become FixedTimeZone" + (Smalltalk globals removeKey: #TimeZoneInstances ifAbsent: []) + ifNotNil: [ :instanceData | + instanceData keysAndValuesDo: [ :instance :data | | newInstance | + newInstance := FixedTimeZone + offset: data first + name: data second + abbreviation: data third. + instance becomeForward: newInstance ]]. + '! - (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
Hi Dave,
TimeZone class >> local still uses the removed TimeZone class >> offset:name:abbreviation:
It is an extension method from System-Localization. Assuming that you went through all senders, maybe have you forgotten to commit that package?
For what it is worth, I have to use an expression like this now in two places of FileSystem-Git to keep it somewhat compatible with older Squeak versions:
((self environment classNamed: #FixedTimeZone) ifNil: [TimeZone]) "then the send of offset:name:abbreviation:"
(This is on the class side, elsewhere it might be `self class environment` at the front.)
Kind regards, Jakob
Am Sa., 8. Juli 2023 um 17:54 Uhr schrieb commits@source.squeak.org:
David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
Save existing TimeZone instances in the package preamble and migrate them to FixedTimeZone in the postscript.
=============== Diff against Chronology-Core-mt.82 ===============
Item was added:
- (PackageInfo named: 'Chronology-Core') preamble: '"below, add code to be run before the loading of this package"
- "Remember all instances of TimeZone. These will become FixedTimeZone in the postscript"
- TimeZone instSize = 3 ifTrue: [
Smalltalk at: #TimeZoneInstances put:
(Dictionary newFrom: (
TimeZone allInstances collect: [:tz |
tz -> { tz offset . tz name . tz abbreviation }]))].
- '!
Item was changed: ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') ----- localOffset: aDuration "Override the local time zone (for testing). This disables the #automaticTimezone: preference"
self localTimeZone: (FixedTimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
!self localTimeZone: (TimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now
"Answer time now as reported by #primitiveUtcWithOffset. If the automaticTimeZone
preference is false, use the offset provided by LocalTimeZone rather than the offset
provided by the primitive."
"Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not
available, answer the Posix epoch GMT." self automaticTimezone ifTrue: [ ^ self basicNew initializeFromPrimitive ] ifFalse: [ | timeArray | timeArray := Time posixMicrosecondClockWithOffset. ^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ]
!
Item was added:
- TimeZone subclass: #FixedTimeZone
instanceVariableNames: 'offset abbreviation name'
classVariableNames: ''
poolDictionaries: 'ChronologyConstants'
category: 'Chronology-Core'!
- !FixedTimeZone commentStamp: 'dtl 6/20/2023 08:07' prior: 0!
- FixedTimeZone is a simple class to collect the information identifying a UTC time zone. It is typically used in unit tests to specify specific time zone offsets.
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- StaticTimeZone class >> #timeZones returns an array of the known time zones
- StaticTimeZone class >> #default returns the default time zone (Greenwich Mean Time)
- !
Item was added:
- ----- Method: FixedTimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
^ self timeZones , self timeZonesDST!
Item was added:
- ----- Method: FixedTimeZone class>>default (in category 'accessing') -----
- default
"Answer the default time zone - GMT"
^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was added:
- ----- Method: FixedTimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
^ self new
offset: aDuration;
name: aName;
abbreviation: anAbbreviation;
yourself
- !
Item was added:
- ----- Method: FixedTimeZone class>>timeZones (in category 'accessing') -----
- timeZones
^{
self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
}!
Item was added:
- ----- Method: FixedTimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
^{
self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
}!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation (in category 'accessing') -----
- abbreviation
^ abbreviation!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
abbreviation := aString!
Item was added:
- ----- Method: FixedTimeZone>>name (in category 'accessing') -----
- name
^ name!
Item was added:
- ----- Method: FixedTimeZone>>name: (in category 'accessing') -----
- name: aString
name := aString!
Item was added:
- ----- Method: FixedTimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
offset := aDuration
- !
Item was added:
- ----- Method: FixedTimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
"A FixedTimeZone has a constant offset, ignoring daylight savings time transitions"
^ offset
- !
Item was added:
- ----- Method: FixedTimeZone>>printOn: (in category 'private') -----
- printOn: aStream
super printOn: aStream.
aStream
nextPut: $(;
nextPutAll: self abbreviation;
nextPut: $)!
Item was changed: Object subclass: #TimeZone
instanceVariableNames: ''
instanceVariableNames: 'offset abbreviation name' classVariableNames: '' poolDictionaries: 'ChronologyConstants' category: 'Chronology-Core'!
- !TimeZone commentStamp: 'dtl 6/15/2023 22:27' prior: 0!
- A TimeZone answers the UTC offset for a DateAndTime based on local rules for a geographic region. For each regional time zone, the UTC offset varies as a function of the DateAndTime, notably in support of daylight savings time changes. The UTC offset for a TimeZone also may change over time as local rules are updated for various regions and political jurisdictions.
- !TimeZone commentStamp: 'dtl 7/11/2009 15:03' prior: 0!
- TimeZone is a simple class to colect the information identifying a UTC time zone.
- Concrete subclasses are expected to implement UTC offset rules. The simple case of FixedTimeZone implements a time zone with constant offset, which is useful for unit test support.!
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- TimeZone class >> #timeZones returns an array of the known time zones
- TimeZone class >> #default returns the default time zone (Grenwich Mean Time)
- !
Item was added:
- ----- Method: TimeZone class>>allForOffset: (in category 'accessing') -----
- allForOffset: aDuration
^ self allTimeZones select: [:ea | ea offset = aDuration]!
Item was added:
- ----- Method: TimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
"Various concrete implementations may be available. These may include a
simple StaticTimeZone or e.g. the TZ-Olson time zone tables with daylight
savings time offset transitions."
^ self allSubclasses
inject: OrderedCollection new
into: [ :result :cls |
(cls class includesLocalSelector: #allTimeZones)
ifTrue: [result addAll: cls allTimeZones].
result].
- !
Item was changed: ----- Method: TimeZone class>>default (in category 'accessing') ----- default "Answer the default time zone - GMT"
^ FixedTimeZone default!
^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was removed:
- ----- Method: TimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
^ self new
offset: aDuration;
name: aName;
abbreviation: anAbbreviation;
yourself
- !
Item was removed:
- ----- Method: TimeZone class>>timeZones (in category 'accessing') -----
- timeZones
^{
self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
}!
Item was removed:
- ----- Method: TimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
^{
self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
}!
Item was changed: ----- Method: TimeZone>>abbreviation (in category 'accessing') ----- abbreviation
^ self subclassResponsibility!
^ abbreviation!
Item was removed:
- ----- Method: TimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
abbreviation := aString!
Item was changed: ----- Method: TimeZone>>name (in category 'accessing') ----- name
^ self subclassResponsibility!
^ name!
Item was removed:
- ----- Method: TimeZone>>name: (in category 'accessing') -----
- name: aString
name := aString!
Item was changed: ----- Method: TimeZone>>offset (in category 'accessing') ----- offset
"Answer the current offset"
^ self offsetAt: DateAndTime basicNew initializeFromPrimitive
!^ offset
Item was removed:
- ----- Method: TimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
offset := aDuration
- !
Item was added:
- ----- Method: TimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
^ self subclassResponsibility
- !
Item was removed:
- ----- Method: TimeZone>>printOn: (in category 'private') -----
- printOn: aStream
super printOn: aStream.
aStream
nextPut: $(;
nextPutAll: self abbreviation;
nextPut: $)!
Item was changed:
- (PackageInfo named: 'Chronology-Core') postscript: '"Let all old instances of TimeZone become FixedTimeZone"
- (Smalltalk globals removeKey: #TimeZoneInstances ifAbsent: [])
ifNotNil: [ :instanceData |
instanceData keysAndValuesDo: [ :instance :data | | newInstance |
newInstance := FixedTimeZone
offset: data first
name: data second
abbreviation: data third.
instance becomeForward: newInstance ]].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
I'm very sorry, I must have missed something in the commits. I was working with some local file based repositories and I must have mixed something up.
I am away for a couple of days so I may not be able to fix it until I get back.
Sorry! Dave
On Sat, Aug 05, 2023 at 05:35:27PM +0200, Jakob Reschke wrote:
Hi Dave,
TimeZone class >> local still uses the removed TimeZone class >> offset:name:abbreviation:
It is an extension method from System-Localization. Assuming that you went through all senders, maybe have you forgotten to commit that package?
For what it is worth, I have to use an expression like this now in two places of FileSystem-Git to keep it somewhat compatible with older Squeak versions:
((self environment classNamed: #FixedTimeZone) ifNil: [TimeZone])
"then the send of offset:name:abbreviation:"
(This is on the class side, elsewhere it might be `self class environment` at the front.)
Kind regards, Jakob
Am Sa., 8. Juli 2023 um 17:54 Uhr schrieb commits@source.squeak.org:
David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
Save existing TimeZone instances in the package preamble and migrate them to FixedTimeZone in the postscript.
=============== Diff against Chronology-Core-mt.82 ===============
Item was added:
- (PackageInfo named: 'Chronology-Core') preamble: '"below, add code to be run before the loading of this package"
- "Remember all instances of TimeZone. These will become FixedTimeZone in the postscript"
- TimeZone instSize = 3 ifTrue: [
Smalltalk at: #TimeZoneInstances put:
(Dictionary newFrom: (
TimeZone allInstances collect: [:tz |
tz -> { tz offset . tz name . tz abbreviation }]))].
- '!
Item was changed: ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') ----- localOffset: aDuration "Override the local time zone (for testing). This disables the #automaticTimezone: preference"
self localTimeZone: (FixedTimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
!self localTimeZone: (TimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now
"Answer time now as reported by #primitiveUtcWithOffset. If the automaticTimeZone
preference is false, use the offset provided by LocalTimeZone rather than the offset
provided by the primitive."
"Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not
available, answer the Posix epoch GMT." self automaticTimezone ifTrue: [ ^ self basicNew initializeFromPrimitive ] ifFalse: [ | timeArray | timeArray := Time posixMicrosecondClockWithOffset. ^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ]
!
Item was added:
- TimeZone subclass: #FixedTimeZone
instanceVariableNames: 'offset abbreviation name'
classVariableNames: ''
poolDictionaries: 'ChronologyConstants'
category: 'Chronology-Core'!
- !FixedTimeZone commentStamp: 'dtl 6/20/2023 08:07' prior: 0!
- FixedTimeZone is a simple class to collect the information identifying a UTC time zone. It is typically used in unit tests to specify specific time zone offsets.
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- StaticTimeZone class >> #timeZones returns an array of the known time zones
- StaticTimeZone class >> #default returns the default time zone (Greenwich Mean Time)
- !
Item was added:
- ----- Method: FixedTimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
^ self timeZones , self timeZonesDST!
Item was added:
- ----- Method: FixedTimeZone class>>default (in category 'accessing') -----
- default
"Answer the default time zone - GMT"
^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was added:
- ----- Method: FixedTimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
^ self new
offset: aDuration;
name: aName;
abbreviation: anAbbreviation;
yourself
- !
Item was added:
- ----- Method: FixedTimeZone class>>timeZones (in category 'accessing') -----
- timeZones
^{
self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
}!
Item was added:
- ----- Method: FixedTimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
^{
self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
}!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation (in category 'accessing') -----
- abbreviation
^ abbreviation!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
abbreviation := aString!
Item was added:
- ----- Method: FixedTimeZone>>name (in category 'accessing') -----
- name
^ name!
Item was added:
- ----- Method: FixedTimeZone>>name: (in category 'accessing') -----
- name: aString
name := aString!
Item was added:
- ----- Method: FixedTimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
offset := aDuration
- !
Item was added:
- ----- Method: FixedTimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
"A FixedTimeZone has a constant offset, ignoring daylight savings time transitions"
^ offset
- !
Item was added:
- ----- Method: FixedTimeZone>>printOn: (in category 'private') -----
- printOn: aStream
super printOn: aStream.
aStream
nextPut: $(;
nextPutAll: self abbreviation;
nextPut: $)!
Item was changed: Object subclass: #TimeZone
instanceVariableNames: ''
instanceVariableNames: 'offset abbreviation name' classVariableNames: '' poolDictionaries: 'ChronologyConstants' category: 'Chronology-Core'!
- !TimeZone commentStamp: 'dtl 6/15/2023 22:27' prior: 0!
- A TimeZone answers the UTC offset for a DateAndTime based on local rules for a geographic region. For each regional time zone, the UTC offset varies as a function of the DateAndTime, notably in support of daylight savings time changes. The UTC offset for a TimeZone also may change over time as local rules are updated for various regions and political jurisdictions.
- !TimeZone commentStamp: 'dtl 7/11/2009 15:03' prior: 0!
- TimeZone is a simple class to colect the information identifying a UTC time zone.
- Concrete subclasses are expected to implement UTC offset rules. The simple case of FixedTimeZone implements a time zone with constant offset, which is useful for unit test support.!
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- TimeZone class >> #timeZones returns an array of the known time zones
- TimeZone class >> #default returns the default time zone (Grenwich Mean Time)
- !
Item was added:
- ----- Method: TimeZone class>>allForOffset: (in category 'accessing') -----
- allForOffset: aDuration
^ self allTimeZones select: [:ea | ea offset = aDuration]!
Item was added:
- ----- Method: TimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
"Various concrete implementations may be available. These may include a
simple StaticTimeZone or e.g. the TZ-Olson time zone tables with daylight
savings time offset transitions."
^ self allSubclasses
inject: OrderedCollection new
into: [ :result :cls |
(cls class includesLocalSelector: #allTimeZones)
ifTrue: [result addAll: cls allTimeZones].
result].
- !
Item was changed: ----- Method: TimeZone class>>default (in category 'accessing') ----- default "Answer the default time zone - GMT"
^ FixedTimeZone default!
^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was removed:
- ----- Method: TimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
^ self new
offset: aDuration;
name: aName;
abbreviation: anAbbreviation;
yourself
- !
Item was removed:
- ----- Method: TimeZone class>>timeZones (in category 'accessing') -----
- timeZones
^{
self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
}!
Item was removed:
- ----- Method: TimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
^{
self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
}!
Item was changed: ----- Method: TimeZone>>abbreviation (in category 'accessing') ----- abbreviation
^ self subclassResponsibility!
^ abbreviation!
Item was removed:
- ----- Method: TimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
abbreviation := aString!
Item was changed: ----- Method: TimeZone>>name (in category 'accessing') ----- name
^ self subclassResponsibility!
^ name!
Item was removed:
- ----- Method: TimeZone>>name: (in category 'accessing') -----
- name: aString
name := aString!
Item was changed: ----- Method: TimeZone>>offset (in category 'accessing') ----- offset
"Answer the current offset"
^ self offsetAt: DateAndTime basicNew initializeFromPrimitive
!^ offset
Item was removed:
- ----- Method: TimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
offset := aDuration
- !
Item was added:
- ----- Method: TimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
^ self subclassResponsibility
- !
Item was removed:
- ----- Method: TimeZone>>printOn: (in category 'private') -----
- printOn: aStream
super printOn: aStream.
aStream
nextPut: $(;
nextPutAll: self abbreviation;
nextPut: $)!
Item was changed:
- (PackageInfo named: 'Chronology-Core') postscript: '"Let all old instances of TimeZone become FixedTimeZone"
- (Smalltalk globals removeKey: #TimeZoneInstances ifAbsent: [])
ifNotNil: [ :instanceData |
instanceData keysAndValuesDo: [ :instance :data | | newInstance |
newInstance := FixedTimeZone
offset: data first
name: data second
abbreviation: data third.
instance becomeForward: newInstance ]].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
Thank you Dave! The follow-up questions:
1. I noted that Chronology-Core-dtl.83 and Chronology-Core-dtl.84 are still in the inbox. Should they be moved to trunk? 2. Our list of timezones is very incomplete at the moment. Do you think we should update the list? I don't have an overview of the TZ-Olson package, would it be worth merging in the trunk? Or could we just import the recent database once and generate an updated version of the constants in FixedTimeZone? I imagine that we could have a similar solution to Unicode class>>#initializeUnicodeData, so that in the end, a maintainer only has to rerun the database update once a while and we don't have additional dependencies in the image.
Best, Christoph
--- Sent from Squeak Inbox Talk
On 2023-07-08T15:54:15+00:00, commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
Save existing TimeZone instances in the package preamble and migrate them to FixedTimeZone in the postscript.
=============== Diff against Chronology-Core-mt.82 ===============
Item was added:
- (PackageInfo named: 'Chronology-Core') preamble: '"below, add code to be run before the loading of this package"
- "Remember all instances of TimeZone. These will become FixedTimeZone in the postscript"
- TimeZone instSize = 3 ifTrue: [
- Smalltalk at: #TimeZoneInstances put:
- (Dictionary newFrom: (
- TimeZone allInstances collect: [:tz |
- tz -> { tz offset . tz name . tz abbreviation }]))].
- '!
Item was changed: ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') ----- localOffset: aDuration "Override the local time zone (for testing). This disables the #automaticTimezone: preference"
- self localTimeZone: (FixedTimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
- self localTimeZone: (TimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
!
Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now
- "Answer time now as reported by #primitiveUtcWithOffset. If the automaticTimeZone
- preference is false, use the offset provided by LocalTimeZone rather than the offset
- provided by the primitive."
- "Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not
- available, answer the Posix epoch GMT."
self automaticTimezone ifTrue: [ ^ self basicNew initializeFromPrimitive ] ifFalse: [ | timeArray | timeArray := Time posixMicrosecondClockWithOffset. ^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ] !
Item was added:
- TimeZone subclass: #FixedTimeZone
- instanceVariableNames: 'offset abbreviation name'
- classVariableNames: ''
- poolDictionaries: 'ChronologyConstants'
- category: 'Chronology-Core'!
- !FixedTimeZone commentStamp: 'dtl 6/20/2023 08:07' prior: 0!
- FixedTimeZone is a simple class to collect the information identifying a UTC time zone. It is typically used in unit tests to specify specific time zone offsets.
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- StaticTimeZone class >> #timeZones returns an array of the known time zones
- StaticTimeZone class >> #default returns the default time zone (Greenwich Mean Time)
- !
Item was added:
- ----- Method: FixedTimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
- ^ self timeZones , self timeZonesDST!
Item was added:
- ----- Method: FixedTimeZone class>>default (in category 'accessing') -----
- default
- "Answer the default time zone - GMT"
- ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was added:
- ----- Method: FixedTimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
- ^ self new
- offset: aDuration;
- name: aName;
- abbreviation: anAbbreviation;
- yourself
- !
Item was added:
- ----- Method: FixedTimeZone class>>timeZones (in category 'accessing') -----
- timeZones
- ^{
- self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
- self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
- self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
- self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
- self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
- self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
- self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
- self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
- }!
Item was added:
- ----- Method: FixedTimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
- ^{
- self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
- self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
- self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
- self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
- self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
- self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
- }!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation (in category 'accessing') -----
- abbreviation
- ^ abbreviation!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
- abbreviation := aString!
Item was added:
- ----- Method: FixedTimeZone>>name (in category 'accessing') -----
- name
- ^ name!
Item was added:
- ----- Method: FixedTimeZone>>name: (in category 'accessing') -----
- name: aString
- name := aString!
Item was added:
- ----- Method: FixedTimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
- offset := aDuration
- !
Item was added:
- ----- Method: FixedTimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
- "A FixedTimeZone has a constant offset, ignoring daylight savings time transitions"
- ^ offset
- !
Item was added:
- ----- Method: FixedTimeZone>>printOn: (in category 'private') -----
- printOn: aStream
- super printOn: aStream.
- aStream
- nextPut: $(;
- nextPutAll: self abbreviation;
- nextPut: $)!
Item was changed: Object subclass: #TimeZone
- instanceVariableNames: ''
- instanceVariableNames: 'offset abbreviation name'
classVariableNames: '' poolDictionaries: 'ChronologyConstants' category: 'Chronology-Core'!
- !TimeZone commentStamp: 'dtl 6/15/2023 22:27' prior: 0!
- A TimeZone answers the UTC offset for a DateAndTime based on local rules for a geographic region. For each regional time zone, the UTC offset varies as a function of the DateAndTime, notably in support of daylight savings time changes. The UTC offset for a TimeZone also may change over time as local rules are updated for various regions and political jurisdictions.
- !TimeZone commentStamp: 'dtl 7/11/2009 15:03' prior: 0!
- TimeZone is a simple class to colect the information identifying a UTC time zone.
- Concrete subclasses are expected to implement UTC offset rules. The simple case of FixedTimeZone implements a time zone with constant offset, which is useful for unit test support.!
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- TimeZone class >> #timeZones returns an array of the known time zones
- TimeZone class >> #default returns the default time zone (Grenwich Mean Time)
- !
Item was added:
- ----- Method: TimeZone class>>allForOffset: (in category 'accessing') -----
- allForOffset: aDuration
- ^ self allTimeZones select: [:ea | ea offset = aDuration]!
Item was added:
- ----- Method: TimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
- "Various concrete implementations may be available. These may include a
- simple StaticTimeZone or e.g. the TZ-Olson time zone tables with daylight
- savings time offset transitions."
- ^ self allSubclasses
- inject: OrderedCollection new
- into: [ :result :cls |
- (cls class includesLocalSelector: #allTimeZones)
- ifTrue: [result addAll: cls allTimeZones].
- result].
- !
Item was changed: ----- Method: TimeZone class>>default (in category 'accessing') ----- default "Answer the default time zone - GMT"
- ^ FixedTimeZone default!
- ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was removed:
- ----- Method: TimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
- ^ self new
- offset: aDuration;
- name: aName;
- abbreviation: anAbbreviation;
- yourself
- !
Item was removed:
- ----- Method: TimeZone class>>timeZones (in category 'accessing') -----
- timeZones
- ^{
- self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
- self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
- self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
- self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
- self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
- self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
- self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
- self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
- }!
Item was removed:
- ----- Method: TimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
- ^{
- self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
- self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
- self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
- self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
- self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
- self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
- }!
Item was changed: ----- Method: TimeZone>>abbreviation (in category 'accessing') ----- abbreviation
- ^ self subclassResponsibility!
- ^ abbreviation!
Item was removed:
- ----- Method: TimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
- abbreviation := aString!
Item was changed: ----- Method: TimeZone>>name (in category 'accessing') ----- name
- ^ self subclassResponsibility!
- ^ name!
Item was removed:
- ----- Method: TimeZone>>name: (in category 'accessing') -----
- name: aString
- name := aString!
Item was changed: ----- Method: TimeZone>>offset (in category 'accessing') ----- offset
"Answer the current offset"
^ self offsetAt: DateAndTime basicNew initializeFromPrimitive
- ^ offset
!
Item was removed:
- ----- Method: TimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
- offset := aDuration
- !
Item was added:
- ----- Method: TimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
- ^ self subclassResponsibility
- !
Item was removed:
- ----- Method: TimeZone>>printOn: (in category 'private') -----
- printOn: aStream
- super printOn: aStream.
- aStream
- nextPut: $(;
- nextPutAll: self abbreviation;
- nextPut: $)!
Item was changed:
- (PackageInfo named: 'Chronology-Core') postscript: '"Let all old instances of TimeZone become FixedTimeZone"
- (Smalltalk globals removeKey: #TimeZoneInstances ifAbsent: [])
- ifNotNil: [ :instanceData |
- instanceData keysAndValuesDo: [ :instance :data | | newInstance |
- newInstance := FixedTimeZone
- offset: data first
- name: data second
- abbreviation: data third.
- instance becomeForward: newInstance ]].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
1. I noted that Chronology-Core-dtl.83 and Chronology-Core-dtl.84 are still in the inbox. Should they be moved to trunk?
Both are already in Treated bc. not in ancestry of their more recent Trunk versions.
Best, Marcel Am 17.08.2023 10:06:37 schrieb christoph.thiede@student.hpi.uni-potsdam.de christoph.thiede@student.hpi.uni-potsdam.de: Thank you Dave! The follow-up questions:
1. I noted that Chronology-Core-dtl.83 and Chronology-Core-dtl.84 are still in the inbox. Should they be moved to trunk? 2. Our list of timezones is very incomplete at the moment. Do you think we should update the list? I don't have an overview of the TZ-Olson package, would it be worth merging in the trunk? Or could we just import the recent database once and generate an updated version of the constants in FixedTimeZone? I imagine that we could have a similar solution to Unicode class>>#initializeUnicodeData, so that in the end, a maintainer only has to rerun the database update once a while and we don't have additional dependencies in the image.
Best, Christoph
--- Sent from Squeak Inbox Talk [https://github.com/hpi-swa-lab/squeak-inbox-talk]
On 2023-07-08T15:54:15+00:00, commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
Save existing TimeZone instances in the package preamble and migrate them to FixedTimeZone in the postscript.
=============== Diff against Chronology-Core-mt.82 ===============
Item was added:
- (PackageInfo named: 'Chronology-Core') preamble: '"below, add code to be run before the loading of this package"
- "Remember all instances of TimeZone. These will become FixedTimeZone in the postscript"
- TimeZone instSize = 3 ifTrue: [
- Smalltalk at: #TimeZoneInstances put:
- (Dictionary newFrom: (
- TimeZone allInstances collect: [:tz |
- tz -> { tz offset . tz name . tz abbreviation }]))].
- '!
Item was changed: ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') ----- localOffset: aDuration "Override the local time zone (for testing). This disables the #automaticTimezone: preference"
- self localTimeZone: (FixedTimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
- self localTimeZone: (TimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
!
Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now
- "Answer time now as reported by #primitiveUtcWithOffset. If the automaticTimeZone
- preference is false, use the offset provided by LocalTimeZone rather than the offset
- provided by the primitive."
- "Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not
- available, answer the Posix epoch GMT."
self automaticTimezone ifTrue: [ ^ self basicNew initializeFromPrimitive ] ifFalse: [ | timeArray | timeArray := Time posixMicrosecondClockWithOffset. ^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ] !
Item was added:
- TimeZone subclass: #FixedTimeZone
- instanceVariableNames: 'offset abbreviation name'
- classVariableNames: ''
- poolDictionaries: 'ChronologyConstants'
- category: 'Chronology-Core'!
- !FixedTimeZone commentStamp: 'dtl 6/20/2023 08:07' prior: 0!
- FixedTimeZone is a simple class to collect the information identifying a UTC time zone. It is typically used in unit tests to specify specific time zone offsets.
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- StaticTimeZone class >> #timeZones returns an array of the known time zones
- StaticTimeZone class >> #default returns the default time zone (Greenwich Mean Time)
- !
Item was added:
- ----- Method: FixedTimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
- ^ self timeZones , self timeZonesDST!
Item was added:
- ----- Method: FixedTimeZone class>>default (in category 'accessing') -----
- default
- "Answer the default time zone - GMT"
- ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was added:
- ----- Method: FixedTimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
- ^ self new
- offset: aDuration;
- name: aName;
- abbreviation: anAbbreviation;
- yourself
- !
Item was added:
- ----- Method: FixedTimeZone class>>timeZones (in category 'accessing') -----
- timeZones
- ^{
- self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
- self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
- self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
- self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
- self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
- self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
- self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
- self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
- }!
Item was added:
- ----- Method: FixedTimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
- ^{
- self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
- self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
- self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
- self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
- self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
- self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
- }!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation (in category 'accessing') -----
- abbreviation
- ^ abbreviation!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
- abbreviation := aString!
Item was added:
- ----- Method: FixedTimeZone>>name (in category 'accessing') -----
- name
- ^ name!
Item was added:
- ----- Method: FixedTimeZone>>name: (in category 'accessing') -----
- name: aString
- name := aString!
Item was added:
- ----- Method: FixedTimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
- offset := aDuration
- !
Item was added:
- ----- Method: FixedTimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
- "A FixedTimeZone has a constant offset, ignoring daylight savings time transitions"
- ^ offset
- !
Item was added:
- ----- Method: FixedTimeZone>>printOn: (in category 'private') -----
- printOn: aStream
- super printOn: aStream.
- aStream
- nextPut: $(;
- nextPutAll: self abbreviation;
- nextPut: $)!
Item was changed: Object subclass: #TimeZone
- instanceVariableNames: ''
- instanceVariableNames: 'offset abbreviation name'
classVariableNames: '' poolDictionaries: 'ChronologyConstants' category: 'Chronology-Core'!
- !TimeZone commentStamp: 'dtl 6/15/2023 22:27' prior: 0!
- A TimeZone answers the UTC offset for a DateAndTime based on local rules for a geographic region. For each regional time zone, the UTC offset varies as a function of the DateAndTime, notably in support of daylight savings time changes. The UTC offset for a TimeZone also may change over time as local rules are updated for various regions and political jurisdictions.
- !TimeZone commentStamp: 'dtl 7/11/2009 15:03' prior: 0!
- TimeZone is a simple class to colect the information identifying a UTC time zone.
- Concrete subclasses are expected to implement UTC offset rules. The simple case of FixedTimeZone implements a time zone with constant offset, which is useful for unit test support.!
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- TimeZone class >> #timeZones returns an array of the known time zones
- TimeZone class >> #default returns the default time zone (Grenwich Mean Time)
- !
Item was added:
- ----- Method: TimeZone class>>allForOffset: (in category 'accessing') -----
- allForOffset: aDuration
- ^ self allTimeZones select: [:ea | ea offset = aDuration]!
Item was added:
- ----- Method: TimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
- "Various concrete implementations may be available. These may include a
- simple StaticTimeZone or e.g. the TZ-Olson time zone tables with daylight
- savings time offset transitions."
- ^ self allSubclasses
- inject: OrderedCollection new
- into: [ :result :cls |
- (cls class includesLocalSelector: #allTimeZones)
- ifTrue: [result addAll: cls allTimeZones].
- result].
- !
Item was changed: ----- Method: TimeZone class>>default (in category 'accessing') ----- default "Answer the default time zone - GMT"
- ^ FixedTimeZone default!
- ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was removed:
- ----- Method: TimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
- ^ self new
- offset: aDuration;
- name: aName;
- abbreviation: anAbbreviation;
- yourself
- !
Item was removed:
- ----- Method: TimeZone class>>timeZones (in category 'accessing') -----
- timeZones
- ^{
- self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
- self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
- self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
- self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
- self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
- self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
- self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
- self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
- }!
Item was removed:
- ----- Method: TimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
- ^{
- self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
- self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
- self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
- self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
- self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
- self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
- }!
Item was changed: ----- Method: TimeZone>>abbreviation (in category 'accessing') ----- abbreviation
- ^ self subclassResponsibility!
- ^ abbreviation!
Item was removed:
- ----- Method: TimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
- abbreviation := aString!
Item was changed: ----- Method: TimeZone>>name (in category 'accessing') ----- name
- ^ self subclassResponsibility!
- ^ name!
Item was removed:
- ----- Method: TimeZone>>name: (in category 'accessing') -----
- name: aString
- name := aString!
Item was changed: ----- Method: TimeZone>>offset (in category 'accessing') ----- offset
"Answer the current offset"
^ self offsetAt: DateAndTime basicNew initializeFromPrimitive
- ^ offset
!
Item was removed:
- ----- Method: TimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
- offset := aDuration
- !
Item was added:
- ----- Method: TimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
- ^ self subclassResponsibility
- !
Item was removed:
- ----- Method: TimeZone>>printOn: (in category 'private') -----
- printOn: aStream
- super printOn: aStream.
- aStream
- nextPut: $(;
- nextPutAll: self abbreviation;
- nextPut: $)!
Item was changed:
- (PackageInfo named: 'Chronology-Core') postscript: '"Let all old instances of TimeZone become FixedTimeZone"
- (Smalltalk globals removeKey: #TimeZoneInstances ifAbsent: [])
- ifNotNil: [ :instanceData |
- instanceData keysAndValuesDo: [ :instance :data | | newInstance |
- newInstance := FixedTimeZone
- offset: data first
- name: data second
- abbreviation: data third.
- instance becomeForward: newInstance ]].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
Sorry, my bad. This was a caching issue in Squeak Inbox Talk ...
--- Sent from Squeak Inbox Talk
On 2023-08-17T10:37:56+02:00, marcel.taeumel@hpi.de wrote:
1. I noted that Chronology-Core-dtl.83 and Chronology-Core-dtl.84 are still in the inbox. Should they be moved to trunk?
Both are already in Treated bc. not in ancestry of their more recent Trunk versions.
Best, Marcel Am 17.08.2023 10:06:37 schrieb christoph.thiede(a)student.hpi.uni-potsdam.de <christoph.thiede(a)student.hpi.uni-potsdam.de>: Thank you Dave! The follow-up questions:
- I noted that Chronology-Core-dtl.83 and Chronology-Core-dtl.84 are still in the inbox. Should they be moved to trunk?
- Our list of timezones is very incomplete at the moment. Do you think we should update the list? I don't have an overview of the TZ-Olson package, would it be worth merging in the trunk? Or could we just import the recent database once and generate an updated version of the constants in FixedTimeZone? I imagine that we could have a similar solution to Unicode class>>#initializeUnicodeData, so that in the end, a maintainer only has to rerun the database update once a while and we don't have additional dependencies in the image.
Best, Christoph
Sent from Squeak Inbox Talk [https://github.com/hpi-swa-lab/squeak-inbox-talk]
On 2023-07-08T15:54:15+00:00, commits(a)source.squeak.org wrote:
David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
Save existing TimeZone instances in the package preamble and migrate them to FixedTimeZone in the postscript.
=============== Diff against Chronology-Core-mt.82 ===============
Item was added:
- (PackageInfo named: 'Chronology-Core') preamble: '"below, add code to be run before the loading of this package"
- "Remember all instances of TimeZone. These will become FixedTimeZone in the postscript"
- TimeZone instSize = 3 ifTrue: [
- Smalltalk at: #TimeZoneInstances put:
- (Dictionary newFrom: (
- TimeZone allInstances collect: [:tz |
- tz -> { tz offset . tz name . tz abbreviation }]))].
- '!
Item was changed: ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') ----- localOffset: aDuration "Override the local time zone (for testing). This disables the #automaticTimezone: preference"
- self localTimeZone: (FixedTimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
- self localTimeZone: (TimeZone offset: aDuration name: 'Local Time (override)' abbreviation: 'LTO').
!
Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now
- "Answer time now as reported by #primitiveUtcWithOffset. If the automaticTimeZone
- preference is false, use the offset provided by LocalTimeZone rather than the offset
- provided by the primitive."
- "Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not
- available, answer the Posix epoch GMT."
self automaticTimezone ifTrue: [ ^ self basicNew initializeFromPrimitive ] ifFalse: [ | timeArray | timeArray := Time posixMicrosecondClockWithOffset. ^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ] !
Item was added:
- TimeZone subclass: #FixedTimeZone
- instanceVariableNames: 'offset abbreviation name'
- classVariableNames: ''
- poolDictionaries: 'ChronologyConstants'
- category: 'Chronology-Core'!
- !FixedTimeZone commentStamp: 'dtl 6/20/2023 08:07' prior: 0!
- FixedTimeZone is a simple class to collect the information identifying a UTC time zone. It is typically used in unit tests to specify specific time zone offsets.
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- StaticTimeZone class >> #timeZones returns an array of the known time zones
- StaticTimeZone class >> #default returns the default time zone (Greenwich Mean Time)
- !
Item was added:
- ----- Method: FixedTimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
- ^ self timeZones , self timeZonesDST!
Item was added:
- ----- Method: FixedTimeZone class>>default (in category 'accessing') -----
- default
- "Answer the default time zone - GMT"
- ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was added:
- ----- Method: FixedTimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
- ^ self new
- offset: aDuration;
- name: aName;
- abbreviation: anAbbreviation;
- yourself
- !
Item was added:
- ----- Method: FixedTimeZone class>>timeZones (in category 'accessing') -----
- timeZones
- ^{
- self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
- self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
- self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
- self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
- self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
- self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
- self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
- self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
- }!
Item was added:
- ----- Method: FixedTimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
- ^{
- self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
- self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
- self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
- self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
- self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
- self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
- }!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation (in category 'accessing') -----
- abbreviation
- ^ abbreviation!
Item was added:
- ----- Method: FixedTimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
- abbreviation := aString!
Item was added:
- ----- Method: FixedTimeZone>>name (in category 'accessing') -----
- name
- ^ name!
Item was added:
- ----- Method: FixedTimeZone>>name: (in category 'accessing') -----
- name: aString
- name := aString!
Item was added:
- ----- Method: FixedTimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
- offset := aDuration
- !
Item was added:
- ----- Method: FixedTimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
- "A FixedTimeZone has a constant offset, ignoring daylight savings time transitions"
- ^ offset
- !
Item was added:
- ----- Method: FixedTimeZone>>printOn: (in category 'private') -----
- printOn: aStream
- super printOn: aStream.
- aStream
- nextPut: $(;
- nextPutAll: self abbreviation;
- nextPut: $)!
Item was changed: Object subclass: #TimeZone
- instanceVariableNames: ''
- instanceVariableNames: 'offset abbreviation name'
classVariableNames: '' poolDictionaries: 'ChronologyConstants' category: 'Chronology-Core'!
- !TimeZone commentStamp: 'dtl 6/15/2023 22:27' prior: 0!
- A TimeZone answers the UTC offset for a DateAndTime based on local rules for a geographic region. For each regional time zone, the UTC offset varies as a function of the DateAndTime, notably in support of daylight savings time changes. The UTC offset for a TimeZone also may change over time as local rules are updated for various regions and political jurisdictions.
- !TimeZone commentStamp: 'dtl 7/11/2009 15:03' prior: 0!
- TimeZone is a simple class to colect the information identifying a UTC time zone.
- Concrete subclasses are expected to implement UTC offset rules. The simple case of FixedTimeZone implements a time zone with constant offset, which is useful for unit test support.!
- offset - Duration - the time zone's offset from UTC
- abbreviation - String - the abbreviated name for the time zone.
- name - String - the name of the time zone.
- TimeZone class >> #timeZones returns an array of the known time zones
- TimeZone class >> #default returns the default time zone (Grenwich Mean Time)
- !
Item was added:
- ----- Method: TimeZone class>>allForOffset: (in category 'accessing') -----
- allForOffset: aDuration
- ^ self allTimeZones select: [:ea | ea offset = aDuration]!
Item was added:
- ----- Method: TimeZone class>>allTimeZones (in category 'accessing') -----
- allTimeZones
- "Various concrete implementations may be available. These may include a
- simple StaticTimeZone or e.g. the TZ-Olson time zone tables with daylight
- savings time offset transitions."
- ^ self allSubclasses
- inject: OrderedCollection new
- into: [ :result :cls |
- (cls class includesLocalSelector: #allTimeZones)
- ifTrue: [result addAll: cls allTimeZones].
- result].
- !
Item was changed: ----- Method: TimeZone class>>default (in category 'accessing') ----- default "Answer the default time zone - GMT"
- ^ FixedTimeZone default!
- ^ self timeZones detect: [ :tz | tz offset = Duration zero ]!
Item was removed:
- ----- Method: TimeZone class>>offset:name:abbreviation: (in category 'instance creation') -----
- offset: aDuration name: aName abbreviation: anAbbreviation
- ^ self new
- offset: aDuration;
- name: aName;
- abbreviation: anAbbreviation;
- yourself
- !
Item was removed:
- ----- Method: TimeZone class>>timeZones (in category 'accessing') -----
- timeZones
- ^{
- self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'.
- self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'.
- self offset: 1 hours name: 'Central European Time' abbreviation: 'CET'.
- self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'.
- self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'.
- self offset: -7 hours name: 'Mountain Standard Time' abbreviation: 'MST'.
- self offset: -6 hours name: 'Central Standard Time' abbreviation: 'CST'.
- self offset: -5 hours name: 'Eastern Standard Time' abbreviation: 'EST'.
- }!
Item was removed:
- ----- Method: TimeZone class>>timeZonesDST (in category 'accessing') -----
- timeZonesDST
- ^{
- self offset: 1 hours name: 'British Summer Time' abbreviation: 'BST'.
- self offset: 2 hours name: 'Central European Summer Time' abbreviation: 'CEST'.
- self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'.
- self offset: -6 hours name: 'Mountain Daylight Time' abbreviation: 'MDT'.
- self offset: -5 hours name: 'Central Daylight Time' abbreviation: 'CDT'.
- self offset: -4 hours name: 'Eastern Daylight Time' abbreviation: 'EDT'.
- }!
Item was changed: ----- Method: TimeZone>>abbreviation (in category 'accessing') ----- abbreviation
- ^ self subclassResponsibility!
- ^ abbreviation!
Item was removed:
- ----- Method: TimeZone>>abbreviation: (in category 'accessing') -----
- abbreviation: aString
- abbreviation := aString!
Item was changed: ----- Method: TimeZone>>name (in category 'accessing') ----- name
- ^ self subclassResponsibility!
- ^ name!
Item was removed:
- ----- Method: TimeZone>>name: (in category 'accessing') -----
- name: aString
- name := aString!
Item was changed: ----- Method: TimeZone>>offset (in category 'accessing') ----- offset
"Answer the current offset"
^ self offsetAt: DateAndTime basicNew initializeFromPrimitive
- ^ offset
!
Item was removed:
- ----- Method: TimeZone>>offset: (in category 'accessing') -----
- offset: aDuration
- offset := aDuration
- !
Item was added:
- ----- Method: TimeZone>>offsetAt: (in category 'accessing') -----
- offsetAt: dateAndTime
- ^ self subclassResponsibility
- !
Item was removed:
- ----- Method: TimeZone>>printOn: (in category 'private') -----
- printOn: aStream
- super printOn: aStream.
- aStream
- nextPut: $(;
- nextPutAll: self abbreviation;
- nextPut: $)!
Item was changed:
- (PackageInfo named: 'Chronology-Core') postscript: '"Let all old instances of TimeZone become FixedTimeZone"
- (Smalltalk globals removeKey: #TimeZoneInstances ifAbsent: [])
- ifNotNil: [ :instanceData |
- instanceData keysAndValuesDo: [ :instance :data | | newInstance |
- newInstance := FixedTimeZone
- offset: data first
- name: data second
- abbreviation: data third.
- instance becomeForward: newInstance ]].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
On Thu, Aug 17, 2023 at 10:06:14AM +0200, christoph.thiede@student.hpi.uni-potsdam.de wrote:
Thank you Dave! The follow-up questions:
- I noted that Chronology-Core-dtl.83 and Chronology-Core-dtl.84 are
still in the inbox. Should they be moved to trunk?
- Our list of timezones is very incomplete at the moment. Do you think
we should update the list?
I would suggest no, keep the list as small as possible for two reasons:
- There too many potential entries, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- For many of the time zones, the UTC offset changes with daylight savings time changes, so you would probably need to define two of FixedTimeZone for each actual time zone.
I don't have an overview of the TZ-Olson package, would it be worth merging in the trunk?
I do not think that it needs to be in trunk. When I wrote the original version of TimeZoneDatabase (in 1999 I think), the date and time handling in Squeak was not very good. But nowadays we have better support in the VM, and the newer UTC-based DateAndTime in the image removes a lot of the earlier confusion. There are still things that can only be done with the TZ-Olson support, but the package is easy to load for those who have an interest.
Or could we just import the recent database once and generate an updated version of the constants in FixedTimeZone?
No, because the constants are not constant. The UTC offset is a function of the point in time, so you can't set it as a constant for the current time and then apply that constant to all other points in time.
I imagine that we could have a similar solution to Unicode class>>#initializeUnicodeData, so that in the end, a maintainer only has to rerun the database update once a while and we don't have additional dependencies in the image.
Yes, if the TZ-Olson database was being kept in the image, then it could be maintained in this way.
Overall, my best suggestion is to load the TZ-Olson package into a Squeak image running on Linux, and take a look at it. If you don't have Linux available let me know and I'll find a better way to get a copy of the database to you.
Dave
Best, Christoph
Sent from Squeak Inbox Talk
On 2023-07-08T15:54:15+00:00, commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of Chronology-Core to project The Trunk: http://source.squeak.org/trunk/Chronology-Core-dtl.85.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.85 Author: dtl Time: 1 July 2023, 9:01:03.976799 pm UUID: bdd66b0f-97e1-4fd5-bca6-4194eaf60096 Ancestors: Chronology-Core-mt.82
Establish protocol for aTimeZone offsetAt: aDateAndTime. Let TimeZone be abstract and let FixedTimeZone implement the previous behavior with offset represented as a constant (no DST transition support). Other packages (e.g. TZ-Olson) may implement concrete TimeZone with DST support.
On Sun, Aug 20, 2023 at 12:06:14PM -0400, David T. Lewis wrote:
Overall, my best suggestion is to load the TZ-Olson package into a Squeak image running on Linux, and take a look at it. If you don't have Linux available let me know and I'll find a better way to get a copy of the database to you.
I should say also that the /usr/share/zoneinfo files are probably available on OS-X, so the TZ-Olson database would probably be loaded properly on that platform also. But I have only actually tried in on Linux so I am not sure.
Dave
On 20. Aug 2023, at 19:25, David T. Lewis lewis@mail.msen.com wrote:
On Sun, Aug 20, 2023 at 12:06:14PM -0400, David T. Lewis wrote:
Overall, my best suggestion is to load the TZ-Olson package into a Squeak image running on Linux, and take a look at it. If you don't have Linux available let me know and I'll find a better way to get a copy of the database to you.
I should say also that the /usr/share/zoneinfo files are probably available on OS-X, so the TZ-Olson database would probably be loaded properly on that platform also. But I have only actually tried in on Linux so I am not sure.
You seem to be correct:
% ls -l /usr/share/zoneinfo lrwxr-xr-x 1 root wheel 25 11 Jul 10:56 /usr/share/zoneinfo -> /var/db/timezone/zoneinfo % ls -ld /var/db/timezone/zoneinfo lrwxr-xr-x 1 root wheel 38 1 Aug 13:28 /var/db/timezone/zoneinfo -> /var/db/timezone/tz/2023c.1.0/zoneinfo % ls -ld /var/db/timezone/tz/2023c.1.0/zoneinfo drwxr-xr-x 68 root wheel 2176 20 Jul 17:16 /var/db/timezone/tz/2023c.1.0/zoneinfo % cat /var/db/timezone/tz/2023c.1.0/zoneinfo/+VERSION 2023c
-Tobias
On Sun, Aug 20, 2023 at 12:06:14PM -0400, David T. Lewis wrote:
Overall, my best suggestion is to load the TZ-Olson package into a Squeak image running on Linux, and take a look at it. If you don't have Linux available let me know and I'll find a better way to get a copy of the database to you.
I have made a number of updates to the TZ-Olson package in https://www.squeaksource.com/TimeZoneDatabase. Details below, but the main thing is that if you are using Squeak on Windows you can now install TZ-Olson from SqueakMap package loader, then load the database from a zip archive of the latest files.
I put a downloadable zoneinfo.zip file at https://drive.google.com/file/d/1IeRStow0Kuba80G2_beNIDm_GdxY6rCN/view?usp=s....
Put the zip file in your Squeak working directory, then load TZ-Olson and evaluate this:
"TimeZoneDatabase buildSystemDatabaseFromZipArchive"
You can create your own zip file on a Linux/OSX platform with OSProcess/CommandShell installed by evaluating this:
"TimeZoneDatabase buildTzFileZip"
Or if you are Windows, see the command script embedded in buildTzFileZip and do something similar on Windows. The script follows the instructions available at https://data.iana.org/time-zones/tz-link.html.
Background:
After googling around the internet, I found to my surprise that there seems to be no convenient way to load up-to-date TZif timezone files from the internet. They are installed on most unix systems in /usr/share/zoneinfo, and they are used in Java, Python, and all sorts of other runtimes. But if you just want e.g. a zip of the compiled TZif files, they are hard to find. Based on that, I decided to implement a TzFileLoader that can read TZif files from a zip archive, and also made a Squeak script method to show how to compile the TZif files into the zip archive.
The latest update to TZ-Olson is this:
Name: TZ-Olson-dtl.26 Author: dtl Time: 27 August 2023, 7:10:19.478246 pm UUID: 58c85609-fffd-4969-a642-006c55f2018c Ancestors: TZ-Olson-dtl.25
TimeZoneDatabase 2.1.2 Let a TimeZoneDatabase be created from a ZIP archive of TZif files. Previously TZif files could only be loaded from the file system, e.g. files installed in /usr/share/zoneinfo.
Implement buildTzFileZip using CommandShell to document the process of compiling TZif files from latest sources from https://data.iana.org/time-zones/tz-link.html.
Implement buildSystemDatabaseFromZipArchive to initialize system database from 'zoneinfo.zip' in the Squeak default directory.
Various related cleanups and refactorings. Fix an asSeconds bug that broke the examples.
Dave
squeak-dev@lists.squeakfoundation.org