From: gotoken@... (GOTO Kentaro) Date: 2000-12-21T00:42:59+09:00 Subject: [ruby-talk:7770] Re: Code sample for improvement In message "[ruby-talk:7705] Code sample for improvement" on 00/12/20, Stephen White writes: >Example run: > > [steve@localhost steve]$ ./a 10000 > 2 hours 46 mins 40 secs > >I was interested in how the new constructs available in Ruby, like >closures and co-routines, could help clean up what really is pretty >ghastly code. > >I've played around with a few other approaches, but nothing really >seems to stand out as being a better way of doing things. Can I send joke? :-) zsh> ruby -e '#!/usr/bin/env ruby require "date" ("%d years %d months %d days %s\n" % [ARGV[0].to_i.divmod 86400].map{|days,secs| [Date.new0(days+5373485), Time.at(secs).gmtime] }.map{|d,t| [d.year-10000, d.month-1, d.mday-1, "%d hours %d mins %d secs" % t.to_a.indices(2,1,0)] }.shift).display ' 0123456789012346789 3912189903 years 10 months 26 days 5 hours 39 mins 49 secs zsh> -- Gotoken