Skip to content

Commit

Permalink
Add ZTeamCoordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvc committed Nov 7, 2023
1 parent 5296346 commit 69b5407
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 1 deletion.
118 changes: 118 additions & 0 deletions repository/ZTimestamp-GT/ZTeamCoordinator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"
I am ZTeamCoordinator, a tool to coordinate team members working in different timezones.
I hold a list of ZTeamCoordinatorMembers, each with a name and timezone.
I have a GT view that shows the details and differences of each member with respect to the current timezone of the image.
Try the example
ZTeamCoordinator feenk
To set the current timezone
ZTimezone current: (ZTimezone id: #'America/New_York').
"
Class {
#name : #ZTeamCoordinator,
#superclass : #Object,
#instVars : [
'members',
'name'
],
#category : #'ZTimestamp-GT'
}

{ #category : #accessing }
ZTeamCoordinator class >> feenk [
<gtExample>
| team |
team := self new.
team name: 'feenk'.
self feenkTeamSpecification do: [ :each |
| member |
member := ZTeamCoordinatorMember new
name: each first;
timezone: (ZTimezone id: each second);
yourself.
team addMember: member ].
^ team
]

{ #category : #accessing }
ZTeamCoordinator class >> feenkTeamSpecification [
^ #(
(alistair 'Europe/Prague')
(andrei 'Europe/Zurich')
(edward 'America/Toronto')
(iona 'Europe/Zurich')
(john 'America/Chicago')
(juraj 'America/Santiago')
(doru 'Europe/Zurich')
(aliaksei 'Europe/Zurich')
(don 'America/Chicago')
(manuel 'Europe/Zurich')
(oscar 'Europe/Zurich')
(veit 'Europe/Berlin')
(sven 'Europe/Brussels')
)
]

{ #category : #accessing }
ZTeamCoordinator >> addMember: member [
self members add: member
]

{ #category : #accessing }
ZTeamCoordinator >> gtViewMembersFor: aView [
<gtView>
| now |
now := ZTimestamp now.
^ aView columnedList
title: 'Members';
items: (self members sorted: #name ascending);
column: 'Name' text: [ :each | each name ];
column: 'Timezone' text: [ :each | each timezone id ];
column: 'Date' text: [ :each |
(ZTimestampFormat fromString: '2001-02-03')
timezone: each timezone;
format: now ];
column: 'Clock' text: [ :each |
(ZTimestampFormat fromString: '16:05')
timezone: each timezone;
format: now ];
column: 'Offset' text: [ :each |
(ZTimestampFormat fromString: '+00:00')
timezone: each timezone;
format: now ];
column: 'Difference' text: [ :each |
| difference |
difference := (each timezone offsetForTimestamp: now)
- (ZTimezone current offsetForTimestamp: now).
difference isZero
ifTrue: [ 0 ]
ifFalse: [ difference humanReadablePrintString ] ]
]

{ #category : #accessing }
ZTeamCoordinator >> members [
^ members ifNil: [ members := OrderedCollection new ]
]

{ #category : #accessing }
ZTeamCoordinator >> name [
^ name
]

{ #category : #accessing }
ZTeamCoordinator >> name: anObject [
name := anObject
]

{ #category : #accessing }
ZTeamCoordinator >> printOn: stream [
super printOn: stream.
self name ifNotNil: [
stream nextPut: $(; print: self name; nextPut: $) ]
]
77 changes: 77 additions & 0 deletions repository/ZTimestamp-GT/ZTeamCoordinatorMember.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"
I am ZTeamCoordinatorMember.
I am used together with ZTeamCoordinator.
I hold a name and timezone (ZTimezone).
"
Class {
#name : #ZTeamCoordinatorMember,
#superclass : #Object,
#instVars : [
'name',
'timezone'
],
#category : #'ZTimestamp-GT'
}

{ #category : #accessing }
ZTeamCoordinatorMember class >> example [
<gtExample>
^ self new
name: 'sven';
timezone: (ZTimezone id: 'Europe/Brussels');
yourself
]

{ #category : #accessing }
ZTeamCoordinatorMember >> gtViewDetailsIn: composite [
<gtView>
| now difference |
now := ZTimestamp now.
difference := (self timezone offsetForTimestamp: now)
- (ZTimezone current offsetForTimestamp: now).
^ composite columnedList
title: 'Details';
items: [ {
('name' -> self name).
('timezone' -> self timezone id).
('clock' -> ((ZTimestampFormat fromString: '16:05')
timezone: self timezone;
format: now )).
('offset' -> ((ZTimestampFormat fromString: 'GMT+00:00')
timezone: self timezone;
format: now)).
('difference' -> (difference isZero
ifTrue: [ 0 ]
ifFalse: [ difference humanReadablePrintString ]))} ];
column: 'Key' text: #key;
column: 'Value' text: #value;
send: #value
]

{ #category : #accessing }
ZTeamCoordinatorMember >> name [
^ name
]

{ #category : #accessing }
ZTeamCoordinatorMember >> name: anObject [
name := anObject
]

{ #category : #printing }
ZTeamCoordinatorMember >> printOn: stream [
super printOn: stream.
stream nextPut: $(; print: self name; nextPut: $)
]

{ #category : #accessing }
ZTeamCoordinatorMember >> timezone [
^ timezone
]

{ #category : #accessing }
ZTeamCoordinatorMember >> timezone: anObject [
timezone := anObject
]
2 changes: 1 addition & 1 deletion repository/ZTimestamp-GT/ZTimezone.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ZTimezone class >> gtViewCurrentTimezoneIn: composite [
<gtView>
<gtClassView>
^ composite columnedList
title: 'Default';
title: 'Current';
priority: 11;
items: [ {('image default' -> self current id)} ];
column: 'Key' text: #key;
Expand Down

0 comments on commit 69b5407

Please sign in to comment.