The Trunk: Kernel-bf.991.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-bf.991.mcz

commits-2
Bert Freudenberg uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-bf.991.mcz

==================== Summary ====================

Name: Kernel-bf.991
Author: bf
Time: 17 February 2016, 6:33:53.746681 pm
UUID: 1d2c150b-bafd-43be-a1ea-648007f13215
Ancestors: Kernel-dtl.990

Use proper timezone in DateAndTime now.

=============== Diff against Kernel-dtl.990 ===============

Item was changed:
  ----- Method: DateAndTime class>>initialize (in category 'initialize-release') -----
  initialize
+ ClockProvider ifNil: [ClockProvider := Time].
+ Smalltalk addToStartUpList: self after: Delay.
+ self startUp: true.
+ !
-
- super initialize.
-
- ClockProvider := Time.
- Smalltalk addToStartUpList: self.
- self startUp: true!

Item was added:
+ ----- Method: DateAndTime class>>localOffset: (in category 'squeak protocol') -----
+ localOffset: aDuration
+ "Set the duration we are offset from UTC (done automatically in #now)"
+ self localTimeZone: (TimeZone offset: aDuration name: 'Local Time' abbreviation: 'LT').
+ !

Item was changed:
  ----- Method: DateAndTime class>>now (in category 'ansi protocol') -----
+ now
+ | clockAndOffset |
+ clockAndOffset := self clock localMicrosecondClockWithOffset.
+ self localOffset asSeconds ~= clockAndOffset second ifTrue: [
+ self localOffset: (Duration seconds: clockAndOffset second)].
+ ^self now: clockAndOffset first offset: self localOffset!
- now
- ^ self nowWithOffset: self localOffset!

Item was added:
+ ----- Method: DateAndTime class>>now:offset: (in category 'squeak protocol') -----
+ now: clockValue offset: aDuration
+
+ | seconds nanos |
+ "Ensure that consecutive sends of this method return increasing values, by adding small values to the nanosecond part of the created object. The next few lines are assumed to be executed atomically - having no suspension points."
+ ((LastClockValue ifNil: [ 0 ]) digitCompare: clockValue) = 0
+ ifTrue: [ NanoOffset := NanoOffset + 1 ]
+ ifFalse: [ NanoOffset := 0 ].
+ LastClockValue := clockValue.
+ nanos := clockValue \\ 1000000 * 1000 + NanoOffset.
+ seconds := clockValue // 1000000.
+ ^self basicNew
+ setJdn: seconds // SecondsInDay + SqueakEpoch
+ seconds: seconds \\ SecondsInDay
+ nano: nanos
+ offset: aDuration!

Item was removed:
- ----- Method: DateAndTime class>>nowWithOffset: (in category 'squeak protocol') -----
- nowWithOffset: aDuration
-
- | clockValue nanos |
- clockValue := Time utcMicrosecondClock.
- "Ensure that consecutive sends of this method return increasing values, by adding small values to the nanosecond part of the created object. The next few lines are assumed to be executed atomically - having no suspension points."
- ((LastClockValue ifNil: [ 0 ]) digitCompare: clockValue) = 0
- ifTrue: [ NanoOffset := NanoOffset + 1 ]
- ifFalse: [ NanoOffset := 0 ].
- LastClockValue := clockValue.
- nanos := clockValue \\ 1000000 * 1000 + NanoOffset.
- clockValue := (clockValue // 1000000) + aDuration asSeconds.
- ^self basicNew
- setJdn: clockValue // SecondsInDay + SqueakEpoch
- seconds: clockValue \\ SecondsInDay
- nano: nanos
- offset: aDuration!

Item was added:
+ ----- Method: DateAndTime class>>startUp: (in category 'system startup') -----
+ startUp: startingAfresh
+ "Set local timezone"
+ startingAfresh ifTrue: [self now].
+ !

Item was added:
+ ----- 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>>primPosixMicrosecondClockWithOffset (in category 'private') -----
- ----- Method: Time class>>primPosixMicrosecondClockWithOffset (in category 'clock') -----
  primPosixMicrosecondClockWithOffset
  "Answer an array with UTC microseconds since the Posix epoch and the
  current seconds offset from GMT in the local time zone."
 
  <primitive: 'primitiveUtcWithOffset'>
+ ^{0. 0}!
- ^#(0 0)!

Item was changed:
  ----- Method: Timespan class>>current (in category 'squeak protocol') -----
  current
+ ^ self starting: DateAndTime now!
- ^ self starting: (DateAndTime nowWithOffset: self defaultOffset)!

Item was changed:
  ----- Method: Timespan>>= (in category 'ansi protocol') -----
  = comparand
  ^ self class = comparand class
+ and: [ "defaultOffset means ignore time zone"
+ ((self start offset == self class defaultOffset
+ or: [comparand start offset ==  self class defaultOffset])
+ ifTrue: [self start hasEqualTicks: comparand start]
+ ifFalse: [self start = comparand start])
- and: [ self start = comparand start
  and: [ self duration = comparand duration ] ]
  .!