-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: $) ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters