OSDN Git Service

Fix #36230: Support Fischer Time Control
[shogi-server/shogi-server.git] / csa-file-filter
index 297edc0..a9a3f8f 100755 (executable)
@@ -5,7 +5,7 @@
 # Homepage:: http://sourceforge.jp/projects/shogi-server/
 #
 #--
-# Copyright (C) 2008 Daigo Moriwaki <daigo at debian dot org>
+# Copyright (C) 2008-2012 Daigo Moriwaki <daigo at debian dot org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -50,9 +50,9 @@
 # 
 # Sample Command lines that isntall prerequires will work on Debian.
 # 
-# * Ruby 1.8.7 including RDoc
+# * Ruby 2.0.0 or later including RDoc
 # 
-#   $ sudo aptitude install ruby ruby1.8
+#   $ sudo aptitude install ruby ruby
 # 
 # == Example
 #
@@ -76,10 +76,8 @@ def filter(filename)
     return unless /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.csa$/ =~ filename
 
     file_date = Date.new($1.to_i, $2.to_i, $3.to_i)
-    now       = Time.now
-    now_date  = Date.new(now.year, now.month, now.day)
 
-    return if now_date - file_date > $options["within"]
+    return if $now_date - file_date > $options["within"]
   end
     
   puts filename
@@ -145,6 +143,8 @@ def main
 end
 
 if __FILE__ == $0
+  now       = Time.now
+  $now_date  = Date.new(now.year, now.month, now.day)
   main
 end