Skip to content

Commit

Permalink
Merge pull request #116 from ba-st/superluminal_needs
Browse files Browse the repository at this point in the history
Add extensions needed for Superluminal
  • Loading branch information
gcotelli authored Feb 27, 2024
2 parents 1ea8fd3 + ae9b7f3 commit 2220ed2
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 60 deletions.
1 change: 1 addition & 0 deletions rowan/components/scripts/defineClassAliases.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ symbolDictionary at: #NotFound put: LookupError.
symbolDictionary at: #SubscriptOutOfBounds put: OffsetError.
symbolDictionary at: #SmallDictionary put: Dictionary.
symbolDictionary at: #Exit put: ExitClientError.
symbolDictionary at: #CollectionIsEmpty put: ImproperOperation.
"Temporary, it will be fixed in a post load script"
symbolDictionary at: #AssertionFailure put: nil.
8 changes: 4 additions & 4 deletions source/Buoy-Chronology-GS64-Extensions/Date.extension.st
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Extension { #name : #Date }
Extension { #name : 'Date' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Date >> asDateAndTime [

^ DateAndTime year: self year month: self monthIndex day: self dayOfMonth
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Date class >> year: year month: month day: day [

^ self newDay: day monthNumber: month year: year
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Date >> yyyymmdd [
"Format the date in ISO 8601 standard like '2002-10-22'
The result is of fixed size 10 characters long."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #DateAndTime }
Extension { #name : 'DateAndTime' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTime >> asDateAndTime [

^ self
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Extension { #name : #DateAndTimeANSI }
Extension { #name : 'DateAndTimeANSI' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTimeANSI >> monthIndex [

^ self month
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTimeANSI >> printHMSOn: aStream [

self printHMSOn: aStream separatedBy: $:
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTimeANSI >> printHMSOn: aStream separatedBy: separator [

aStream
Expand All @@ -23,7 +23,7 @@ DateAndTimeANSI >> printHMSOn: aStream separatedBy: separator [
nextPutAll: (self second asInteger printStringLength: 2 padded: true)
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTimeANSI >> printYMDOn: aStream [

aStream
Expand All @@ -34,13 +34,13 @@ DateAndTimeANSI >> printYMDOn: aStream [
nextPutAll: (self dayOfMonth printStringLength: 2 padded: true)
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTimeANSI class >> unixEpoch [

^ self posixSeconds: 0 offset: Duration zero
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
DateAndTimeANSI class >> year: year month: month day: day [
"Return a DateAndTime, midnight local time"

Expand Down
22 changes: 14 additions & 8 deletions source/Buoy-Chronology-GS64-Extensions/Duration.extension.st
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
Extension { #name : #Duration }
Extension { #name : 'Duration' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration >> asMilliSeconds [

^ self asSeconds * 1000
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration class >> days: aNumber [

^ self seconds: aNumber * 86400
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration class >> hours: aNumber [

^ self seconds: aNumber * 3600
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration class >> milliSeconds: aNumber [

^ self seconds: aNumber / 1000
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration class >> minutes: aNumber [

^ self seconds: aNumber * 60
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration >> totalSeconds [

^self asSeconds
]

{ #category : '*Buoy-Chronology-GS64-Extensions' }
Duration >> wait [

^ Delay waitForMilliseconds: self seconds * 1000
^ Delay waitForMilliseconds: (self seconds * 1000) rounded
]
18 changes: 9 additions & 9 deletions source/Buoy-Chronology-GS64-Extensions/Integer.extension.st
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
Extension { #name : #Integer }
Extension { #name : 'Integer' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> day [

^ self days
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> days [

^ Duration days: self
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> hour [

^ self hours
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> hours [

^ Duration hours: self
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> milliSecond [

^ self milliSeconds
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> milliSeconds [

^ Duration milliSeconds: self
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> minute [

^ self minutes
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Integer >> minutes [

^ Duration minutes: self
Expand Down
8 changes: 4 additions & 4 deletions source/Buoy-Chronology-GS64-Extensions/Number.extension.st
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Extension { #name : #Number }
Extension { #name : 'Number' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Number >> asDuration [

^ Duration seconds: self asInteger
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Number >> second [
"1 second printString >>> '0:00:00:01'"
"(1 minute + 1 second) printString >>> '0:00:01:01'"

^ self seconds
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Number >> seconds [

^ Duration seconds: self
Expand Down
10 changes: 5 additions & 5 deletions source/Buoy-Chronology-GS64-Extensions/Time.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Time }
Extension { #name : 'Time' }

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Time class >> milliseconds: currentTime since: lastTime [
"Answer the elapsed time since last recorded in milliseconds.
Compensate for rollover."
Expand All @@ -12,21 +12,21 @@ Time class >> milliseconds: currentTime since: lastTime [
ifFalse: [delta]
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Time class >> millisecondsSince: lastTime [
"Answer the elapsed time since last recorded in milliseconds.
Compensate for rollover."

^self milliseconds: self millisecondClockValue since: lastTime
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Time class >> millisecondsToRun: timedBlock [

^ self millisecondsElapsedTime: timedBlock
]

{ #category : #'*Buoy-Chronology-GS64-Extensions' }
{ #category : '*Buoy-Chronology-GS64-Extensions' }
Time class >> totalSeconds [
"Answer the total seconds ellapsed since the epoch: 1 January 1901 00:00 UTC"

Expand Down
2 changes: 1 addition & 1 deletion source/Buoy-Chronology-GS64-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Buoy-Chronology-GS64-Extensions' }
Package { #name : 'Buoy-Chronology-GS64-Extensions' }
11 changes: 6 additions & 5 deletions source/Buoy-Chronology-Tests/DateAndTimeExtensionsTest.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #DateAndTimeExtensionsTest,
#superclass : #TestCase,
#category : #'Buoy-Chronology-Tests'
#name : 'DateAndTimeExtensionsTest',
#superclass : 'TestCase',
#category : 'Buoy-Chronology-Tests',
#package : 'Buoy-Chronology-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
DateAndTimeExtensionsTest >> testPrintHMS [

| dateAndTime |
Expand All @@ -21,7 +22,7 @@ DateAndTimeExtensionsTest >> testPrintHMS [
equals: '04:06:01'
]

{ #category : #tests }
{ #category : 'tests' }
DateAndTimeExtensionsTest >> testPrintYMD [

| dateAndTime |
Expand Down
11 changes: 6 additions & 5 deletions source/Buoy-Chronology-Tests/DateExtensionsTest.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #DateExtensionsTest,
#superclass : #TestCase,
#category : #'Buoy-Chronology-Tests'
#name : 'DateExtensionsTest',
#superclass : 'TestCase',
#category : 'Buoy-Chronology-Tests',
#package : 'Buoy-Chronology-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
DateExtensionsTest >> testAsDateAndTime [

| date dateAndTime |
Expand All @@ -20,7 +21,7 @@ DateExtensionsTest >> testAsDateAndTime [
assert: dateAndTime second isZero
]

{ #category : #tests }
{ #category : 'tests' }
DateExtensionsTest >> testCreation [

| date |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Class {
#name : 'DurationChronologyExtensionsTest',
#superclass : 'TestCase',
#category : 'Buoy-Chronology-Tests',
#package : 'Buoy-Chronology-Tests'
}

{ #category : 'tests' }
DurationChronologyExtensionsTest >> testTotalSeconds [

self assert: 0 seconds totalSeconds equals: 0.
self assert: 1 second totalSeconds equals: 1.
self assert: 100 second totalSeconds equals: 100.
self assert: 500 milliSeconds totalSeconds equals: 1 / 2.
self assert: 1500 milliSeconds totalSeconds equals: 3 / 2.
self assert: 2500 milliSeconds totalSeconds equals: 5 / 2.
self assert: 1 second negated totalSeconds equals: -1
]

{ #category : 'tests' }
DurationChronologyExtensionsTest >> testWait [

| ms |

ms := Time millisecondsToRun: [ 2.1 seconds wait ].
self assert: ms >= 2100
]
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
Class {
#name : #NumberChronologyExtensionsTest,
#superclass : #TestCase,
#category : #'Buoy-Chronology-Tests'
#name : 'NumberChronologyExtensionsTest',
#superclass : 'TestCase',
#category : 'Buoy-Chronology-Tests',
#package : 'Buoy-Chronology-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
NumberChronologyExtensionsTest >> testDays [

self
assert: 1 day equals: (Duration days: 1);
assert: 2 days equals: (Duration days: 2)
]

{ #category : #tests }
{ #category : 'tests' }
NumberChronologyExtensionsTest >> testHours [

self
assert: 1 hour equals: (Duration hours: 1);
assert: 2 hours equals: (Duration hours: 2)
]

{ #category : #tests }
{ #category : 'tests' }
NumberChronologyExtensionsTest >> testMilliSeconds [

self
assert: 1000 milliSeconds equals: 1 second;
assert: 2000 milliSeconds equals: 2 seconds
]

{ #category : #tests }
{ #category : 'tests' }
NumberChronologyExtensionsTest >> testSeconds [

self
Expand Down
2 changes: 1 addition & 1 deletion source/Buoy-Chronology-Tests/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Buoy-Chronology-Tests' }
Package { #name : 'Buoy-Chronology-Tests' }
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ Collection >> detect: aBlock ifFound: foundBlock ifNone: exceptionBlock [
^ exceptionBlock value
]

{ #category : '*Buoy-Collections-GS64-Extensions' }
Collection >> errorEmptyCollection [

CollectionIsEmpty signal: 'Collection is empty'
]

{ #category : '*Buoy-Collections-GS64-Extensions' }
Collection >> fillFrom: aCollection with: aBlock [
"Private.
Expand Down
Loading

0 comments on commit 2220ed2

Please sign in to comment.