The Trunk: Chronology-Core-ul.23.mcz

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

The Trunk: Chronology-Core-ul.23.mcz

commits-2
Levente Uzonyi uploaded a new version of Chronology-Core to project The Trunk:
http://source.squeak.org/trunk/Chronology-Core-ul.23.mcz

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

Name: Chronology-Core-ul.23
Author: ul
Time: 21 January 2019, 11:37:59.846788 pm
UUID: 18de3a91-5246-44e9-94dc-190924f9b969
Ancestors: Chronology-Core-ul.21

- added an accessor to Time's ClockPolicy, so that tests can depend on its current value
- optimized various DateAndTime methods

=============== Diff against Chronology-Core-ul.21 ===============

Item was changed:
  ----- Method: DateAndTime>>asUTC (in category 'ansi protocol') -----
  asUTC
 
  localOffsetSeconds = 0 ifTrue: [ ^self ].
+ ^self copy makeUTC!
- ^self copy
- utcMicroseconds: utcMicroseconds
- offset: 0
- !

Item was changed:
  ----- Method: DateAndTime>>asUnixTime (in category 'squeak protocol') -----
  asUnixTime
  "answer number of seconds since unix epoch (midnight Jan 1, 1970, UTC)"
 
+ ^utcMicroseconds // 1000000!
- ^(self - self class unixEpoch) asSeconds!

Item was changed:
  ----- Method: DateAndTime>>dayMonthYearDo: (in category 'squeak protocol') -----
  dayMonthYearDo: aBlock
  "Evaluation the block with three arguments: day month, year."
 
+ | l n i j dd |
- | l n i j dd mm yyyy |
  l := self julianDayNumber + 68569.
  n := 4 * l // 146097.
  l := l - (146097 * n + 3 // 4).
+ i := l + 1 * 4000 // 1461001.
- i := 4000 * (l + 1) // 1461001.
  l := l - (1461 * i // 4) + 31.
  j := 80 * l // 2447.
  dd := l - (2447 * j // 80).
  l := j // 11.
- mm := j + 2 - (12 * l).
- yyyy := 100 * (n - 49) + i + l.
 
  ^ aBlock
  value: dd
+ value: -12 * l + 2 + j "month"
+ value: n - 49 * 100 + i + l "year"!
- value: mm
- value: yyyy!

Item was changed:
  ----- Method: DateAndTime>>floor (in category 'squeak protocol') -----
  floor
  "Answer a copy with magnitude rounded down to the nearest whole second"
  ^self class
+ utcMicroseconds: utcMicroseconds // 1000000 * 1000000
- utcMicroseconds: utcMicroseconds - (utcMicroseconds \\ 1000000)
  offset: localOffsetSeconds!

Item was changed:
  ----- Method: DateAndTime>>getSeconds (in category 'accessing') -----
  getSeconds
+
+ ^utcMicroseconds // 1000000 + localOffsetSeconds \\ 86400!
-
- | posixDays posixSeconds localSeconds |
- posixSeconds := utcMicroseconds // 1000000.
- localSeconds := posixSeconds + localOffsetSeconds.
- localSeconds < 0 ifTrue: [localSeconds := localSeconds \\ SecondsInDay]. "normalize"
- posixDays := localSeconds // SecondsInDay.
- ^localSeconds - (posixDays * SecondsInDay).
- !

Item was changed:
  ----- Method: DateAndTime>>julianDayNumber (in category 'squeak protocol') -----
  julianDayNumber
 
+ ^utcMicroseconds // 1000000 + localOffsetSeconds // 86400 + PosixEpochJulianDays!
- | posixDays posixSeconds localSeconds negativeDays |
- posixSeconds := utcMicroseconds // 1000000.
- localSeconds := posixSeconds + localOffsetSeconds.
- negativeDays := 0.
- localSeconds < 0 ifTrue: [ "normalize"
- negativeDays := localSeconds // SecondsInDay.
- localSeconds := negativeDays * SecondsInDay + localSeconds].
- posixDays := localSeconds // SecondsInDay.
- ^posixDays + PosixEpochJulianDays - negativeDays.
- !

Item was changed:
  ----- Method: DateAndTime>>microsecondsFromDay:seconds:nanos:offset: (in category 'private') -----
  microsecondsFromDay: jdn seconds: s nanos: n offset: localOffsetSeconds
 
+ ^jdn - PosixEpochJulianDays "days" * 86400
+ + s - localOffsetSeconds "seconds" * 1000000
+ + (n / 1000) "nanos"!
- | days totalSeconds micros |
- days := jdn - PosixEpochJulianDays.
- totalSeconds := days * 86400 + s - localOffsetSeconds. "n.g. const 86400 is faster than SecondsInDay"
- micros := totalSeconds * 1000000.
- ^micros + (n / 1000)
- !

Item was added:
+ ----- Method: Time class>>clockPolicy (in category 'class initialization') -----
+ clockPolicy
+
+ ^ClockPolicy!