[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[sharing] S8-VSE DateTime

Expression to dump DateTime instances
Stringifier @ DateTime now
'{"origin":"S8","id":3,"contents":{"id":2,"class":{"id":3,"global":"DateTime"},"contents":"2018/12/17 16:49:01"}}'

Stringifier @ (DateTime fromString: '1962/12/15 01:40:00')
'{"origin":"S8","id":3,"contents":{"id":2,"class":{"id":3,"global":"DateTime"},"contents":"1962/12/15 01:40:00"}}'

Reading a DateTime in S8

It can be done reading the stringified string in a workspace
(Stringifier @ DateTime now) asObject

Reading a DateTime instance in VSE

Evaluate the following expressions in VSE workspace

"Testing we get a TimeStamp"
(Smalltalk includesKey: #TimeStamp) ifFalse: [ ^nil ].
('{"origin":"S8","id":3,"contents":{"id":2,"class":{"id":3,"global":"DateTime"},"contents":"2018/12/17 16:49:01"}}'
 asObject isKindOf: TimeStamp) ifFalse: [ self error: 'Must be a TimeStamp instance' ].
^#Ok


"Testing birthday contents"
| birth |
(Smalltalk includesKey: #TimeStamp) ifFalse: [ ^nil ].
birth := '{"origin":"S8","id":3,"contents":{"id":2,"class":{"id":3,"global":"DateTime"},"contents":"1962/12/15 01:40:00"}}' asObject.
(birth isKindOf: TimeStamp) ifFalse: [ self error: 'Must be a TimeStamp instance' ].
(birth = (TimeStamp date: (Date fromString: '15-12-62') time: (Time hours: 1 minutes: 40 seconds: 0))) ifFalse: [
	self error: 'Wrong birthday'
].
^#Ok