Date>>printOn:like: - keeping changes local?

Ingo Hohmann ingo at 2b1.de
Sun May 25 12:34:05 UTC 2003


Hi Squeakers,

Date>>printOn:format: is a little too simplistic to do the date outputs 
I wanted, so I gave printOn:like: a try.

printOn: aStream like: formatArray
  "Print a description of the receiver on aStream using the
  format denoted the argument, formatArray:
  yy - two digit year
  yyyy - four digit year
  m	 - 1 digit month
  mm		- 2 digit month
  mmm	- abbreviated month name
  mmmm	- full month name
  d .. dddd - like m .. mmmm, but for days
  everything else is copied as is, e.g.:
	
  Date today printLike: #( 'yyyy' '-' 'mm' '-' 'dd')
    -> '2003-05-25'
  Date today printLike: #( 'ddd' ', ' 'dd' '. ' 'mmmm' ' ' 'yyyy')
    -> 'Sun, 25. May 2003'

But the method looks a bit fishy to me, does anyone have a better idea 
on how to decide what to do, than having a Dictionary of formatStrings 
and actionBlocks? I tried to make the changes stay in the method I added.


Kind regards,

Ingo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Date-printOnlike.st.gz
Type: application/gzip
Size: 705 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030525/236df169/Date-printOnlike.st.bin


More information about the Squeak-dev mailing list