A new version of Chronology-Core was added to project The Inbox: http://source.squeak.org/inbox/Chronology-Core-dtl.84.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.84 Author: dtl Time: 20 June 2023, 5:38:49.016554 pm UUID: 54930a93-01b0-4313-b8e5-8dbe5e53300d 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.
Also add TimeZone class>>allForOffset: as proposed by Christoph Thiede on squeak-dev (Review Request: allTimeZones.4.cs, Thu, 18 May 2023 22:11:32 +0200)
=============== Diff against Chronology-Core-mt.82 ===============
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 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 ConstantTimeZone 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 now - ^ 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: '"StaticTimeZone is now the concrete implementation of TimeZone" + + DateAndTime localTimeZone == TimeZone + ifTrue: [ | newInstance | + newInstance := StaticTimeZone + offset: DateAndTime localTimeZone offset + name: DateAndTime localTimeZone name + abbreviation: DateAndTime localTimeZone abbreviation. + DateAndTime localTimeZone: newInstance ]. + '! - (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
This replaces Chronology-Core-dtl.83 in the inbox, resaving it with a fix to a class comment (thanks Marcel). For now I will leave version 83 in the inbox because it is referenced from another email thread, and I'll move it to the treated inbox later.
Dave
On Tue, Jun 20, 2023 at 09:38:49PM +0000, commits@source.squeak.org wrote:
A new version of Chronology-Core was added to project The Inbox: http://source.squeak.org/inbox/Chronology-Core-dtl.84.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.84 Author: dtl Time: 20 June 2023, 5:38:49.016554 pm UUID: 54930a93-01b0-4313-b8e5-8dbe5e53300d 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.
Also add TimeZone class>>allForOffset: as proposed by Christoph Thiede on squeak-dev (Review Request: allTimeZones.4.cs, Thu, 18 May 2023 22:11:32 +0200)
=============== Diff against Chronology-Core-mt.82 ===============
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 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 ConstantTimeZone 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 now
- ^ 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: '"StaticTimeZone is now the concrete implementation of TimeZone"
- DateAndTime localTimeZone == TimeZone
- ifTrue: [ | newInstance |
newInstance := StaticTimeZone
offset: DateAndTime localTimeZone offset
name: DateAndTime localTimeZone name
abbreviation: DateAndTime localTimeZone abbreviation.
DateAndTime localTimeZone: newInstance ].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
Very nice! Do you think we could also have DateAndTime>>allTimeZones?
Also, would it be worth converting all existing TimeZone instances to FixedTimeZone instances in the postscript?
Best, Christoph
--- Sent from Squeak Inbox Talk
On 2023-06-20T17:55:37-04:00, lewis@mail.msen.com wrote:
This replaces Chronology-Core-dtl.83 in the inbox, resaving it with a fix to a class comment (thanks Marcel). For now I will leave version 83 in the inbox because it is referenced from another email thread, and I'll move it to the treated inbox later.
Dave
On Tue, Jun 20, 2023 at 09:38:49PM +0000, commits(a)source.squeak.org wrote:
A new version of Chronology-Core was added to project The Inbox: http://source.squeak.org/inbox/Chronology-Core-dtl.84.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.84 Author: dtl Time: 20 June 2023, 5:38:49.016554 pm UUID: 54930a93-01b0-4313-b8e5-8dbe5e53300d 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.
Also add TimeZone class>>allForOffset: as proposed by Christoph Thiede on squeak-dev (Review Request: allTimeZones.4.cs, Thu, 18 May 2023 22:11:32 +0200)
=============== Diff against Chronology-Core-mt.82 ===============
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 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 ConstantTimeZone 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 now
- ^ 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: '"StaticTimeZone is now the concrete implementation of TimeZone"
- DateAndTime localTimeZone == TimeZone
- ifTrue: [ | newInstance |
newInstance := StaticTimeZone
offset: DateAndTime localTimeZone offset
name: DateAndTime localTimeZone name
abbreviation: DateAndTime localTimeZone abbreviation.
DateAndTime localTimeZone: newInstance ].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
On Wed, Jun 21, 2023 at 12:45:20PM +0200, christoph.thiede@student.hpi.uni-potsdam.de wrote:
Very nice! Do you think we could also have DateAndTime>>allTimeZones?
Are you thinking of something like this:
DateAndTime>>allTimeZones ^ TimeZone allForOffset: self offset
It's a good idea, although I think it might be confusing because the results are quite different depending on what time zones are present in the image.
Also, would it be worth converting all existing TimeZone instances to FixedTimeZone instances in the postscript?
Good catch. The LocalTimeZone class var in DateAndTime points to an instance of TimeZone that would need to become a FixedTimeZone.
I'm not sure how to do that in a postscript, hmm...
Dave
Best, Christoph
Sent from Squeak Inbox Talk
On 2023-06-20T17:55:37-04:00, lewis@mail.msen.com wrote:
This replaces Chronology-Core-dtl.83 in the inbox, resaving it with a fix to a class comment (thanks Marcel). For now I will leave version 83 in the inbox because it is referenced from another email thread, and I'll move it to the treated inbox later.
Dave
On Tue, Jun 20, 2023 at 09:38:49PM +0000, commits(a)source.squeak.org wrote:
A new version of Chronology-Core was added to project The Inbox: http://source.squeak.org/inbox/Chronology-Core-dtl.84.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.84 Author: dtl Time: 20 June 2023, 5:38:49.016554 pm UUID: 54930a93-01b0-4313-b8e5-8dbe5e53300d 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.
Also add TimeZone class>>allForOffset: as proposed by Christoph Thiede on squeak-dev (Review Request: allTimeZones.4.cs, Thu, 18 May 2023 22:11:32 +0200)
=============== Diff against Chronology-Core-mt.82 ===============
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 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 ConstantTimeZone 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 now
- ^ 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: '"StaticTimeZone is now the concrete implementation of TimeZone"
- DateAndTime localTimeZone == TimeZone
- ifTrue: [ | newInstance |
newInstance := StaticTimeZone
offset: DateAndTime localTimeZone offset
name: DateAndTime localTimeZone name
abbreviation: DateAndTime localTimeZone abbreviation.
DateAndTime localTimeZone: newInstance ].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
Hi Dave --
I'm not sure how to do that in a postscript, hmm...
Since you moved down the state from TimeZone to FixedTimeZone, you would need both preamble and postscript to not loose information.
Preamble: Copy info of all instances of TimeZone to temporary IdentityKeyDictionary.
info := IdentityKeyDictionary new. TimeZone allInstancesDo: [:tz | info at: tz put: { tz offset. tz name. tz abbreviation }].
Postscript: Iterate over all keys in that dictionary and #becomeForward: each to a new instance of FixedTimeZone, which you fill with the info you saved in the preamble.
info keysAndValuesDo: [:tz :val | | ftz | ftz := FixedTimeZone new. ftz offset: val first. ftz name: val second. ftz abbreviation: val third. tz becomeForward: ftz].
Or something like that :-)
Best, Marcel Am 21.06.2023 21:47:01 schrieb David T. Lewis lewis@mail.msen.com: On Wed, Jun 21, 2023 at 12:45:20PM +0200, christoph.thiede@student.hpi.uni-potsdam.de wrote:
Very nice! Do you think we could also have DateAndTime>>allTimeZones?
Are you thinking of something like this:
DateAndTime>>allTimeZones ^ TimeZone allForOffset: self offset
It's a good idea, although I think it might be confusing because the results are quite different depending on what time zones are present in the image.
Also, would it be worth converting all existing TimeZone instances to FixedTimeZone instances in the postscript?
Good catch. The LocalTimeZone class var in DateAndTime points to an instance of TimeZone that would need to become a FixedTimeZone.
I'm not sure how to do that in a postscript, hmm...
Dave
Best, Christoph
Sent from Squeak Inbox Talk
On 2023-06-20T17:55:37-04:00, lewis@mail.msen.com wrote:
This replaces Chronology-Core-dtl.83 in the inbox, resaving it with a fix to a class comment (thanks Marcel). For now I will leave version 83 in the inbox because it is referenced from another email thread, and I'll move it to the treated inbox later.
Dave
On Tue, Jun 20, 2023 at 09:38:49PM +0000, commits(a)source.squeak.org wrote:
A new version of Chronology-Core was added to project The Inbox: http://source.squeak.org/inbox/Chronology-Core-dtl.84.mcz
==================== Summary ====================
Name: Chronology-Core-dtl.84 Author: dtl Time: 20 June 2023, 5:38:49.016554 pm UUID: 54930a93-01b0-4313-b8e5-8dbe5e53300d 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.
Also add TimeZone class>>allForOffset: as proposed by Christoph Thiede on squeak-dev (Review Request: allTimeZones.4.cs, Thu, 18 May 2023 22:11:32 +0200)
=============== Diff against Chronology-Core-mt.82 ===============
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 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 ConstantTimeZone 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 now
- ^ 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: '"StaticTimeZone is now the concrete implementation of TimeZone"
- DateAndTime localTimeZone == TimeZone
- ifTrue: [ | newInstance |
- newInstance := StaticTimeZone
- offset: DateAndTime localTimeZone offset
- name: DateAndTime localTimeZone name
- abbreviation: DateAndTime localTimeZone abbreviation.
- DateAndTime localTimeZone: newInstance ].
- '!
- (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
On Thu, Jun 22, 2023 at 11:34:21AM +0200, Marcel Taeumel via Squeak-dev wrote:
Hi Dave --
??I'm not sure how to do that in a postscript, hmm...
Since you moved down the state from TimeZone to FixedTimeZone, you would need both preamble and postscript to not loose information.
Preamble: Copy info of all instances of TimeZone to temporary IdentityKeyDictionary.
info :=??IdentityKeyDictionary new. TimeZone allInstancesDo: [:tz | info at: tz put: { tz offset. tz name. tz abbreviation }].
Postscript: Iterate over all keys in that dictionary and #becomeForward: each to a new instance of FixedTimeZone, which you fill with the info you saved in the preamble.
info keysAndValuesDo: [:tz :val | | ftz | ?? ftz :=??FixedTimeZone new. ?? ftz offset: val first. ?? ftz name: val second. ?? ftz abbreviation: val third. ?? tz becomeForward: ftz].
Or something like that :-)
Thanks Marcel,
Are variable declared in the preamble visible in the postscript? I did not know that, nice feature :-)
It might be a few days until I can get back to this, but I'll clean it up and move to trunk.
Thanks, Dave
Hi Dave,
Are variable declared in the preamble visible in the postscript? I did not know that, nice feature :-)
I don't think so, see MCScriptDefinition>>#evaluate. AFAIK, the required state is usually preserved as a Smalltalk global:
Smalltalk at: #TZTempConvertInfo put: info.
info := Smalltalk globals removeKey: #TZTempConvertInfo.
Best, Christoph
________________________________ Von: David T. Lewis lewis@mail.msen.com Gesendet: Donnerstag, 22. Juni 2023 23:34:05 An: Marcel Taeumel via Squeak-dev Betreff: [squeak-dev] Re: The Inbox: Chronology-Core-dtl.84.mcz
On Thu, Jun 22, 2023 at 11:34:21AM +0200, Marcel Taeumel via Squeak-dev wrote:
Hi Dave --
??I'm not sure how to do that in a postscript, hmm...
Since you moved down the state from TimeZone to FixedTimeZone, you would need both preamble and postscript to not loose information.
Preamble: Copy info of all instances of TimeZone to temporary IdentityKeyDictionary.
info :=??IdentityKeyDictionary new. TimeZone allInstancesDo: [:tz | info at: tz put: { tz offset. tz name. tz abbreviation }].
Postscript: Iterate over all keys in that dictionary and #becomeForward: each to a new instance of FixedTimeZone, which you fill with the info you saved in the preamble.
info keysAndValuesDo: [:tz :val | | ftz | ?? ftz :=??FixedTimeZone new. ?? ftz offset: val first. ?? ftz name: val second. ?? ftz abbreviation: val third. ?? tz becomeForward: ftz].
Or something like that :-)
Thanks Marcel,
Are variable declared in the preamble visible in the postscript? I did not know that, nice feature :-)
It might be a few days until I can get back to this, but I'll clean it up and move to trunk.
Thanks, Dave
squeak-dev@lists.squeakfoundation.org