diff options
-rwxr-xr-x | atom.cgi | 3 | ||||
-rwxr-xr-x | config.cgi | 1 | ||||
-rw-r--r-- | overview.rb | 8 | ||||
-rw-r--r-- | participate.rb | 4 | ||||
-rw-r--r-- | poll.rb | 3 | ||||
-rw-r--r-- | timepoll.rb (renamed from datetimepoll.rb) | 34 |
6 files changed, 26 insertions, 27 deletions
@@ -10,6 +10,7 @@ require "rubygems" require "atom" require "yaml" require "cgi" +require "time" $cgi = CGI.new @@ -17,7 +18,7 @@ def readhistory dir log = `export LC_ALL=de_DE.UTF-8; bzr log -r -10.. "#{dir}"`.split("-"*60) log.collect!{|s| s.scan(/\nrevno: (.*)\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} log.shift - log.collect!{|r,t,c| [r.to_i,DateTime.parse(t),c]} + log.collect!{|r,t,c| [r.to_i,Time.parse(t),c]} end feed = Atom::Feed.new @@ -42,7 +42,6 @@ else table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) if $cgi.include?("add_remove_column") table.toggle_hidden if $cgi.include?("toggle_hidden") end -table.init $htmlout += <<HTMLHEAD <head> diff --git a/overview.rb b/overview.rb index 2c1903a..622ad57 100644 --- a/overview.rb +++ b/overview.rb @@ -6,7 +6,7 @@ require "poll" require "datepoll" -require "datetimepoll" +require "timepoll" $htmlout += <<HEAD <head> @@ -32,8 +32,8 @@ if $cgi.include?("create_poll") case $cgi["poll_type"] when "Poll" Poll.new SITE - when "DatePoll" - DatePoll.new SITE + when "TimePoll" + TimePoll.new SITE end Dir.chdir("..") else @@ -77,7 +77,7 @@ $htmlout += <<CREATE <td> <select id="poll_type" name="poll_type"> <option value="Poll" selected="selected">normal</option> - <option value="DatePoll">date</option> + <option value="TimePoll">date</option> </select> </td> </tr> diff --git a/participate.rb b/participate.rb index 1f36630..a203e11 100644 --- a/participate.rb +++ b/participate.rb @@ -8,7 +8,7 @@ olddir = File.expand_path(".") Dir.chdir("..") require "poll" require "datepoll" -require "datetimepoll" +require "timepoll" Dir.chdir(olddir) if $cgi.include?("revision") @@ -32,8 +32,6 @@ else table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") end -table.init - $htmlout += <<HEAD <head> <meta http-equiv="Content-Type" content="#{TYPE}; charset=#{CHARSET}" /> @@ -6,6 +6,7 @@ require "hash" require "yaml" +require "time" class Poll attr_reader :head, :name, :hidden @@ -210,7 +211,7 @@ ADDCOMMENT log = VCS.history log.shift log.collect!{|s| s.scan(/\nrevno:.*\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} - log.collect!{|t,c| [DateTime.parse(t),c]} + log.collect!{|t,c| [Time.parse(t),c]} ((revision-2)..(revision+2)).each do |i| if i >0 && i<=maxrev diff --git a/datetimepoll.rb b/timepoll.rb index dd4b62e..a4de3d4 100644 --- a/datetimepoll.rb +++ b/timepoll.rb @@ -6,9 +6,9 @@ require "date" require "poll" -load "time.rb" +require "time" -class DateTimePoll < Poll +class TimePoll < Poll def init #FIXME: quick 'n' dirty hack, because Time <=> Date is not possible and yaml loads Time instead of DateTime! #better solution would be to overwrite <=> @@ -21,7 +21,7 @@ class DateTimePoll < Poll end def sort_data fields datefields = fields.collect{|field| - field == "timestamp" || field == "name" ? field : DateTime.parse(field) + field == "timestamp" || field == "name" ? field : Time.parse(field) } super datefields end @@ -31,7 +31,7 @@ class DateTimePoll < Poll def head_count(big,small) ret = Hash.new(0) @head.keys.collect{|curdate| - DateTime.parse(curdate.strftime(big + small)) + Time.parse(curdate.strftime(big + small)) }.uniq.each{|day| ret[day.strftime(big)] += 1 } @@ -63,25 +63,25 @@ class DateTimePoll < Poll def add_remove_column_htmlform if $cgi.include?("add_remove_column_month") begin - startdate = DateTime.parse("#{$cgi["add_remove_column_month"]}-1") + startdate = Time.parse("#{$cgi["add_remove_column_month"]}-1") rescue ArgumentError olddate = $cgi.params["add_remove_column_month"][1] case $cgi["add_remove_column_month"] when CGI.unescapeHTML(YEARBACK) - startdate = DateTime.parse("#{olddate}-1")-365 + startdate = Time.parse("#{olddate}-1")-365 when CGI.unescapeHTML(MONTHBACK) - startdate = DateTime.parse("#{olddate}-1")-1 + startdate = Time.parse("#{olddate}-1")-1 when CGI.unescapeHTML(MONTHFORWARD) - startdate = DateTime.parse("#{olddate}-1")+31 + startdate = Time.parse("#{olddate}-1")+31 when CGI.unescapeHTML(YEARFORWARD) - startdate = DateTime.parse("#{olddate}-1")+366 + startdate = Time.parse("#{olddate}-1")+366 else exit end - startdate = DateTime.parse(startdate.strftime("%Y-%m-1")) + startdate = Time.parse(startdate.strftime("%Y-%m-1")) end else - startdate = DateTime.parse(Date.today.strftime("%Y-%m-1")) + startdate = Time.parse(Date.today.strftime("%Y-%m-1")) end ret = <<END <form method='post' action=''> @@ -142,9 +142,9 @@ END @head.sort.collect{|day,descr| Date.parse(day.strftime("%Y-%m-%d")) }.uniq.each{|date| - timestamp = DateTime.parse("#{date} #{time} #{Time.now.zone}") + timestamp = Time.parse("#{date} #{time} #{Time.now.zone}") klasse = "notchoosen" - klasse = "disabled" if timestamp < DateTime.now + klasse = "disabled" if timestamp < Time.now klasse = "choosen" if @head.include?(timestamp) ret += <<END <td class='calendarday'> @@ -176,7 +176,7 @@ END def add_remove_column col,description if $cgi.include?("add_remove_column_day") begin - parsed_date = YAML::load(DateTime.parse("#{$cgi["add_remove_column_month"]}-#{$cgi["add_remove_column_day"]} #{col} #{Time.now.zone}").to_yaml) + parsed_date = YAML::load(Time.parse("#{$cgi["add_remove_column_month"]}-#{$cgi["add_remove_column_day"]} #{col} #{Time.now.zone}").to_yaml) day = Date.parse(parsed_date.to_s) @head.delete(day) if @head.include?(day) rescue ArgumentError @@ -196,7 +196,7 @@ end if __FILE__ == $0 require 'test/unit' require 'pp' -class DatePoll +class TimePoll def store comment end end @@ -208,9 +208,9 @@ CGI_PARAMS={"add_remove_column_month" => ["2008-02"]} CGI_COOKIES={} $cgi = CGI.new -class DatePollTest < Test::Unit::TestCase +class TimePollTest < Test::Unit::TestCase def setup - @poll = DatePoll.new(SITE) + @poll = TimePoll.new(SITE) end #TODO def test_add_remove_column |