Or: Date today printFormat: #(3 2 1 0 1 1 2)
On Wed, Oct 30, 2013 at 2:13 PM, Frank Shearar <[email protected]>wrote: > On 30 October 2013 20:55, blake <[email protected]> wrote: > > Heya, guys-- > > > > Converting a Ruby program to Pharo, and one of the things this program > does > > is write a file out by date. The format is "yyyymmdd" (which is my > preferred > > naming convention). In Ruby I have: > > > > "%04d" % d.year + "%02d" % d.month + "%02d" % d.day > > Why not "%04d%02d%02d" % [d.year, d.month, d.day] ? > > > In Smalltalk, the closest I can seem to get to this is: > > > > d year asString, (d monthIndex asString padLeftTo: 2 with: $0), (d > > dayOfMonth asString padLeftTo: 2 with: $0) > > > > ...which seems sort verbose. Anyone have any more elegant solutions? > > Chris has already given a near solution. You just need to "select: > #isDigit" on the end of his answer to get exactly what you want. > > frank > >
