Skip to content

Commit 735e0e8

Browse files
authored
Merge pull request #118 from ba-st/stargate-consul_needs
Add chronology extensions needed by Stargate-Consul
2 parents 50c0440 + 779302f commit 735e0e8

File tree

4 files changed

+77
-24
lines changed

4 files changed

+77
-24
lines changed

source/Buoy-Chronology-GS64-Extensions/Duration.extension.st

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
Extension { #name : 'Duration' }
22

3+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
4+
Duration >> asMicroseconds [
5+
6+
^ self asSeconds * 1000000
7+
]
8+
39
{ #category : '*Buoy-Chronology-GS64-Extensions' }
410
Duration >> asMilliSeconds [
511

612
^ self asSeconds * 1000
713
]
814

15+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
16+
Duration >> asNanoSeconds [
17+
18+
^ self asSeconds * 1000000000
19+
]
20+
921
{ #category : '*Buoy-Chronology-GS64-Extensions' }
1022
Duration class >> days: aNumber [
1123

@@ -18,6 +30,12 @@ Duration class >> hours: aNumber [
1830
^ self seconds: aNumber * 3600
1931
]
2032

33+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
34+
Duration >> isZero [
35+
36+
^ self totalSeconds isZero
37+
]
38+
2139
{ #category : '*Buoy-Chronology-GS64-Extensions' }
2240
Duration class >> milliSeconds: aNumber [
2341

@@ -41,3 +59,21 @@ Duration >> wait [
4159

4260
^ Delay waitForMilliseconds: (self seconds * 1000) rounded
4361
]
62+
63+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
64+
Duration >> wholeMicroseconds [
65+
66+
^ (self asMicroseconds rem: 1000) truncated
67+
]
68+
69+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
70+
Duration >> wholeMilliseconds [
71+
72+
^ (self asMilliSeconds rem: 1000) truncated
73+
]
74+
75+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
76+
Duration >> wholeNanoseconds [
77+
78+
^ (self asNanoSeconds rem: 1000) truncated
79+
]

source/Buoy-Chronology-GS64-Extensions/Integer.extension.st

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ Integer >> days [
1212
^ Duration days: self
1313
]
1414

15-
{ #category : '*Buoy-Chronology-GS64-Extensions' }
16-
Integer >> hour [
17-
18-
^ self hours
19-
]
20-
21-
{ #category : '*Buoy-Chronology-GS64-Extensions' }
22-
Integer >> hours [
23-
24-
^ Duration hours: self
25-
]
26-
2715
{ #category : '*Buoy-Chronology-GS64-Extensions' }
2816
Integer >> milliSecond [
2917

@@ -35,15 +23,3 @@ Integer >> milliSeconds [
3523

3624
^ Duration milliSeconds: self
3725
]
38-
39-
{ #category : '*Buoy-Chronology-GS64-Extensions' }
40-
Integer >> minute [
41-
42-
^ self minutes
43-
]
44-
45-
{ #category : '*Buoy-Chronology-GS64-Extensions' }
46-
Integer >> minutes [
47-
48-
^ Duration minutes: self
49-
]

source/Buoy-Chronology-GS64-Extensions/Number.extension.st

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ Number >> asDuration [
66
^ Duration seconds: self asInteger
77
]
88

9+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
10+
Number >> hour [
11+
12+
^ self hours
13+
]
14+
15+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
16+
Number >> hours [
17+
18+
^ Duration hours: self
19+
]
20+
21+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
22+
Number >> minute [
23+
24+
^ self minutes
25+
]
26+
27+
{ #category : '*Buoy-Chronology-GS64-Extensions' }
28+
Number >> minutes [
29+
30+
^ Duration minutes: self
31+
]
32+
933
{ #category : '*Buoy-Chronology-GS64-Extensions' }
1034
Number >> second [
1135
"1 second printString >>> '0:00:00:01'"

source/Buoy-Chronology-Tests/DurationChronologyExtensionsTest.class.st

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ Class {
55
#package : 'Buoy-Chronology-Tests'
66
}
77

8+
{ #category : 'tests' }
9+
DurationChronologyExtensionsTest >> testIsZero [
10+
11+
self
12+
assert: 0 seconds isZero;
13+
deny: 1 second isZero
14+
]
15+
816
{ #category : 'tests' }
917
DurationChronologyExtensionsTest >> testTotalSeconds [
1018

@@ -25,3 +33,12 @@ DurationChronologyExtensionsTest >> testWait [
2533
ms := Time millisecondsToRun: [ 2.1 seconds wait ].
2634
self assert: ms >= 2100
2735
]
36+
37+
{ #category : 'tests' }
38+
DurationChronologyExtensionsTest >> testWholeSeconds [
39+
40+
self
41+
assert: 1.002003004 seconds wholeMilliseconds equals: 2;
42+
assert: 1.002003004 seconds wholeMicroseconds equals: 3;
43+
assert: 1.002003004 seconds wholeNanoseconds equals: 4
44+
]

0 commit comments

Comments
 (0)