From: Kazuhiro NISHIYAMA Date: 2000-07-14T01:00:08+09:00 Subject: [ruby-list:23840] Re: 紅玉すうぉっち Again 掲示板とかが無かったのでruby-listに :-) http://www.duelists.org/~crouton/ruby/rdds/diary/?page=200007B#200007131 より引用 ここから class Time def beat was_gmt = 'GMT' == zone gmtime unless was_gmt beat = ((((hour + 1) * 60 + min) * 60 + sec) * 1000) / 86400 localtime unless was_gmt beat end alias :old_strftime :strftime def strftime(format) out = '' format.scan(/%@|./o) do |c| case c when '%@' out << beat.to_s else out << c end end old_strftime(out) end end if $0 == __FILE__ print(Time.now.strftime("%H:%M:%S @%@ %%@"), "\n") end とかやってみる。 $ ruby beat.rb 00:13:14 @675 %675 ……あれれ? あー、最長一致しちゃうのか。むむむ。 http://www.duelists.org/~crouton/ruby/rdds/diary/?page=200007B#200007131 より引用 ここまで scanのところを format.scan(/%.|./o) do |c| とすればいいのではないでしょうか? --- ZnZ(ゼット エヌ ゼット) 西山和広(Kazuhiro Nishiyama) mailto:zn@mbf.nifty.com