Bert Freudenberg uploaded a new version of Chronology-Core to project The Trunk:
http://source.squeak.org/trunk/Chronology-Core-bf.4.mcz ==================== Summary ==================== Name: Chronology-Core-bf.4 Author: bf Time: 19 March 2016, 12:01:52.725349 am UUID: 31207206-eb6a-4f21-9e6b-dfce49f3b8a2 Ancestors: Chronology-Core-cmm.3 Make "DateAndTime now" respect its localOffset - it will be the same UTC time but different local time. Make "Time now" respect that same offset. Make "Time millisecondClockValue" use the UTC clock. Do not use posix time primitive anymore. =============== Diff against Chronology-Core-cmm.3 =============== Item was changed: ----- Method: DateAndTime class>>automaticTimezone: (in category 'preferences') ----- automaticTimezone: aBoolean + "Accessor for the system-wide preference. + Note this gets disabled in localTimeZone: to make that override stick" - "Accessor for the system-wide preference" + AutomaticTimezone := aBoolean. + aBoolean ifTrue: [self now]. "fetch timezone immediately"! - AutomaticTimezone := aBoolean! Item was changed: ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- now + | clockAndOffset localSeconds | + clockAndOffset := self clock utcMicrosecondClockWithOffset. + localSeconds := self localOffset asSeconds. + (self automaticTimezone and: [localSeconds ~= clockAndOffset second]) + ifTrue: [self setLocalOffsetAutomatically: (Duration seconds: (localSeconds := clockAndOffset second))]. + ^self now: clockAndOffset first + (localSeconds * 1000000) offset: self localOffset! - | clockAndOffset | - clockAndOffset := self clock localMicrosecondClockWithOffset. - (self automaticTimezone and: - [self localOffset asSeconds ~= clockAndOffset second]) - ifTrue: [self setLocalTimeZoneAutomatically: (Duration seconds: clockAndOffset second)]. - ^self now: clockAndOffset first offset: self localOffset! Item was added: + ----- Method: DateAndTime class>>setLocalOffsetAutomatically: (in category 'squeak protocol') ----- + setLocalOffsetAutomatically: aDuration + "Set the duration we are offset from UTC (done automatically in #now)" + LocalTimeZone := (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT'). + ! Item was removed: - ----- Method: DateAndTime class>>setLocalTimeZoneAutomatically: (in category 'squeak protocol') ----- - setLocalTimeZoneAutomatically: aDuration - "Set the duration we are offset from UTC (done automatically in #now)" - LocalTimeZone := (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT'). - ! Item was changed: ----- Method: Time class>>localMicrosecondClock (in category 'clock') ----- localMicrosecondClock "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century). + The value is derived from the current UTC wallclock time and the image's current notion of time zone." + ^self utcMicrosecondClock + (DateAndTime localOffset asSeconds * 1000000)! - The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds - between the two epochs according to RFC 868, and with an offset duration corresponding to the current - offset of local time from UTC." - <primitive: 241> - ^0! Item was added: + ----- Method: Time class>>localMicrosecondClockPrimitive (in category 'clock') ----- + localMicrosecondClockPrimitive + "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century). + The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds + between the two epochs according to RFC 868, and with an offset duration corresponding to the current + offset of local time from UTC." + <primitive: 241> + ^0! Item was removed: - ----- Method: Time class>>localMicrosecondClockWithOffset (in category 'clock') ----- - localMicrosecondClockWithOffset - "Answer an array with local microseconds since the Smalltalk epoch and the - current seconds offset from GMT in the local time zone." - - | result | - result := self primPosixMicrosecondClockWithOffset. - "DateAndTime unixEpoch asSeconds" - result at: 1 put: result first + ((2177452800 + result second) * 1000000). - ^result! Item was changed: ----- Method: Time class>>millisecondClockValue (in category 'general inquiries') ----- millisecondClockValue "Answer the value of the millisecond clock." + ^self utcMicrosecondClock // 1000! - ^self localMicrosecondClock // 1000! Item was added: + ----- Method: Time class>>utcMicrosecondClockWithOffset (in category 'clock') ----- + utcMicrosecondClockWithOffset + "Answer an array with UTC microseconds since the Smalltalk epoch and the + current seconds offset from UTC in the local time zone." + | offset utc | + utc := self utcMicrosecondClock. + offset := (self localMicrosecondClockPrimitive - utc) // 1000000. + ^{utc. offset}! |
Could you please tell us if this is going to affect applications with
existing DateAndTime instances? On Fri, Mar 18, 2016 at 6:10 PM, <[hidden email]> wrote: > Bert Freudenberg uploaded a new version of Chronology-Core to project The Trunk: > http://source.squeak.org/trunk/Chronology-Core-bf.4.mcz > > ==================== Summary ==================== > > Name: Chronology-Core-bf.4 > Author: bf > Time: 19 March 2016, 12:01:52.725349 am > UUID: 31207206-eb6a-4f21-9e6b-dfce49f3b8a2 > Ancestors: Chronology-Core-cmm.3 > > Make "DateAndTime now" respect its localOffset - it will be the same UTC time but different local time. Make "Time now" respect that same offset. Make "Time millisecondClockValue" use the UTC clock. Do not use posix time primitive anymore. > > =============== Diff against Chronology-Core-cmm.3 =============== > > Item was changed: > ----- Method: DateAndTime class>>automaticTimezone: (in category 'preferences') ----- > automaticTimezone: aBoolean > + "Accessor for the system-wide preference. > + Note this gets disabled in localTimeZone: to make that override stick" > - "Accessor for the system-wide preference" > > + AutomaticTimezone := aBoolean. > + aBoolean ifTrue: [self now]. "fetch timezone immediately"! > - AutomaticTimezone := aBoolean! > > Item was changed: > ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- > now > + | clockAndOffset localSeconds | > + clockAndOffset := self clock utcMicrosecondClockWithOffset. > + localSeconds := self localOffset asSeconds. > + (self automaticTimezone and: [localSeconds ~= clockAndOffset second]) > + ifTrue: [self setLocalOffsetAutomatically: (Duration seconds: (localSeconds := clockAndOffset second))]. > + ^self now: clockAndOffset first + (localSeconds * 1000000) offset: self localOffset! > - | clockAndOffset | > - clockAndOffset := self clock localMicrosecondClockWithOffset. > - (self automaticTimezone and: > - [self localOffset asSeconds ~= clockAndOffset second]) > - ifTrue: [self setLocalTimeZoneAutomatically: (Duration seconds: clockAndOffset second)]. > - ^self now: clockAndOffset first offset: self localOffset! > > Item was added: > + ----- Method: DateAndTime class>>setLocalOffsetAutomatically: (in category 'squeak protocol') ----- > + setLocalOffsetAutomatically: aDuration > + "Set the duration we are offset from UTC (done automatically in #now)" > + LocalTimeZone := (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT'). > + ! > > Item was removed: > - ----- Method: DateAndTime class>>setLocalTimeZoneAutomatically: (in category 'squeak protocol') ----- > - setLocalTimeZoneAutomatically: aDuration > - "Set the duration we are offset from UTC (done automatically in #now)" > - LocalTimeZone := (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT'). > - ! > > Item was changed: > ----- Method: Time class>>localMicrosecondClock (in category 'clock') ----- > localMicrosecondClock > "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century). > + The value is derived from the current UTC wallclock time and the image's current notion of time zone." > + ^self utcMicrosecondClock + (DateAndTime localOffset asSeconds * 1000000)! > - The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds > - between the two epochs according to RFC 868, and with an offset duration corresponding to the current > - offset of local time from UTC." > - <primitive: 241> > - ^0! > > Item was added: > + ----- Method: Time class>>localMicrosecondClockPrimitive (in category 'clock') ----- > + localMicrosecondClockPrimitive > + "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century). > + The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds > + between the two epochs according to RFC 868, and with an offset duration corresponding to the current > + offset of local time from UTC." > + <primitive: 241> > + ^0! > > Item was removed: > - ----- Method: Time class>>localMicrosecondClockWithOffset (in category 'clock') ----- > - localMicrosecondClockWithOffset > - "Answer an array with local microseconds since the Smalltalk epoch and the > - current seconds offset from GMT in the local time zone." > - > - | result | > - result := self primPosixMicrosecondClockWithOffset. > - "DateAndTime unixEpoch asSeconds" > - result at: 1 put: result first + ((2177452800 + result second) * 1000000). > - ^result! > > Item was changed: > ----- Method: Time class>>millisecondClockValue (in category 'general inquiries') ----- > millisecondClockValue > "Answer the value of the millisecond clock." > > + ^self utcMicrosecondClock // 1000! > - ^self localMicrosecondClock // 1000! > > Item was added: > + ----- Method: Time class>>utcMicrosecondClockWithOffset (in category 'clock') ----- > + utcMicrosecondClockWithOffset > + "Answer an array with UTC microseconds since the Smalltalk epoch and the > + current seconds offset from UTC in the local time zone." > + | offset utc | > + utc := self utcMicrosecondClock. > + offset := (self localMicrosecondClockPrimitive - utc) // 1000000. > + ^{utc. offset}! > > |
The interpretation of existing instances is unchanged.
- Bert - > On 19.03.2016, at 04:11, Chris Muller <[hidden email]> wrote: > > Could you please tell us if this is going to affect applications with > existing DateAndTime instances? > >> On Fri, Mar 18, 2016 at 6:10 PM, <[hidden email]> wrote: >> Bert Freudenberg uploaded a new version of Chronology-Core to project The Trunk: >> http://source.squeak.org/trunk/Chronology-Core-bf.4.mcz >> >> ==================== Summary ==================== >> >> Name: Chronology-Core-bf.4 >> Author: bf >> Time: 19 March 2016, 12:01:52.725349 am >> UUID: 31207206-eb6a-4f21-9e6b-dfce49f3b8a2 >> Ancestors: Chronology-Core-cmm.3 >> >> Make "DateAndTime now" respect its localOffset - it will be the same UTC time but different local time. Make "Time now" respect that same offset. Make "Time millisecondClockValue" use the UTC clock. Do not use posix time primitive anymore. >> >> =============== Diff against Chronology-Core-cmm.3 =============== >> >> Item was changed: >> ----- Method: DateAndTime class>>automaticTimezone: (in category 'preferences') ----- >> automaticTimezone: aBoolean >> + "Accessor for the system-wide preference. >> + Note this gets disabled in localTimeZone: to make that override stick" >> - "Accessor for the system-wide preference" >> >> + AutomaticTimezone := aBoolean. >> + aBoolean ifTrue: [self now]. "fetch timezone immediately"! >> - AutomaticTimezone := aBoolean! >> >> Item was changed: >> ----- Method: DateAndTime class>>now (in category 'ansi protocol') ----- >> now >> + | clockAndOffset localSeconds | >> + clockAndOffset := self clock utcMicrosecondClockWithOffset. >> + localSeconds := self localOffset asSeconds. >> + (self automaticTimezone and: [localSeconds ~= clockAndOffset second]) >> + ifTrue: [self setLocalOffsetAutomatically: (Duration seconds: (localSeconds := clockAndOffset second))]. >> + ^self now: clockAndOffset first + (localSeconds * 1000000) offset: self localOffset! >> - | clockAndOffset | >> - clockAndOffset := self clock localMicrosecondClockWithOffset. >> - (self automaticTimezone and: >> - [self localOffset asSeconds ~= clockAndOffset second]) >> - ifTrue: [self setLocalTimeZoneAutomatically: (Duration seconds: clockAndOffset second)]. >> - ^self now: clockAndOffset first offset: self localOffset! >> >> Item was added: >> + ----- Method: DateAndTime class>>setLocalOffsetAutomatically: (in category 'squeak protocol') ----- >> + setLocalOffsetAutomatically: aDuration >> + "Set the duration we are offset from UTC (done automatically in #now)" >> + LocalTimeZone := (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT'). >> + ! >> >> Item was removed: >> - ----- Method: DateAndTime class>>setLocalTimeZoneAutomatically: (in category 'squeak protocol') ----- >> - setLocalTimeZoneAutomatically: aDuration >> - "Set the duration we are offset from UTC (done automatically in #now)" >> - LocalTimeZone := (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT'). >> - ! >> >> Item was changed: >> ----- Method: Time class>>localMicrosecondClock (in category 'clock') ----- >> localMicrosecondClock >> "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century). >> + The value is derived from the current UTC wallclock time and the image's current notion of time zone." >> + ^self utcMicrosecondClock + (DateAndTime localOffset asSeconds * 1000000)! >> - The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds >> - between the two epochs according to RFC 868, and with an offset duration corresponding to the current >> - offset of local time from UTC." >> - <primitive: 241> >> - ^0! >> >> Item was added: >> + ----- Method: Time class>>localMicrosecondClockPrimitive (in category 'clock') ----- >> + localMicrosecondClockPrimitive >> + "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century). >> + The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds >> + between the two epochs according to RFC 868, and with an offset duration corresponding to the current >> + offset of local time from UTC." >> + <primitive: 241> >> + ^0! >> >> Item was removed: >> - ----- Method: Time class>>localMicrosecondClockWithOffset (in category 'clock') ----- >> - localMicrosecondClockWithOffset >> - "Answer an array with local microseconds since the Smalltalk epoch and the >> - current seconds offset from GMT in the local time zone." >> - >> - | result | >> - result := self primPosixMicrosecondClockWithOffset. >> - "DateAndTime unixEpoch asSeconds" >> - result at: 1 put: result first + ((2177452800 + result second) * 1000000). >> - ^result! >> >> Item was changed: >> ----- Method: Time class>>millisecondClockValue (in category 'general inquiries') ----- >> millisecondClockValue >> "Answer the value of the millisecond clock." >> >> + ^self utcMicrosecondClock // 1000! >> - ^self localMicrosecondClock // 1000! >> >> Item was added: >> + ----- Method: Time class>>utcMicrosecondClockWithOffset (in category 'clock') ----- >> + utcMicrosecondClockWithOffset >> + "Answer an array with UTC microseconds since the Smalltalk epoch and the >> + current seconds offset from UTC in the local time zone." >> + | offset utc | >> + utc := self utcMicrosecondClock. >> + offset := (self localMicrosecondClockPrimitive - utc) // 1000000. >> + ^{utc. offset}! > smime.p7s (8K) Download Attachment |
Free forum by Nabble | Edit this page |