remove trailing white-spaces from lib/redmine/helpers/calendar.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6952 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
09d4503eb5
commit
325f6a721a
|
@ -1,34 +1,34 @@
|
||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module Redmine
|
module Redmine
|
||||||
module Helpers
|
module Helpers
|
||||||
|
|
||||||
# Simple class to compute the start and end dates of a calendar
|
# Simple class to compute the start and end dates of a calendar
|
||||||
class Calendar
|
class Calendar
|
||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
attr_reader :startdt, :enddt
|
attr_reader :startdt, :enddt
|
||||||
|
|
||||||
def initialize(date, lang = current_language, period = :month)
|
def initialize(date, lang = current_language, period = :month)
|
||||||
@date = date
|
@date = date
|
||||||
@events = []
|
@events = []
|
||||||
@ending_events_by_days = {}
|
@ending_events_by_days = {}
|
||||||
@starting_events_by_days = {}
|
@starting_events_by_days = {}
|
||||||
set_language_if_valid lang
|
set_language_if_valid lang
|
||||||
case period
|
case period
|
||||||
when :month
|
when :month
|
||||||
@startdt = Date.civil(date.year, date.month, 1)
|
@startdt = Date.civil(date.year, date.month, 1)
|
||||||
|
@ -44,24 +44,24 @@ module Redmine
|
||||||
raise 'Invalid period'
|
raise 'Invalid period'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets calendar events
|
# Sets calendar events
|
||||||
def events=(events)
|
def events=(events)
|
||||||
@events = events
|
@events = events
|
||||||
@ending_events_by_days = @events.group_by {|event| event.due_date}
|
@ending_events_by_days = @events.group_by {|event| event.due_date}
|
||||||
@starting_events_by_days = @events.group_by {|event| event.start_date}
|
@starting_events_by_days = @events.group_by {|event| event.start_date}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns events for the given day
|
# Returns events for the given day
|
||||||
def events_on(day)
|
def events_on(day)
|
||||||
((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq
|
((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calendar current month
|
# Calendar current month
|
||||||
def month
|
def month
|
||||||
@date.month
|
@date.month
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the first day of week
|
# Return the first day of week
|
||||||
# 1 = Monday ... 7 = Sunday
|
# 1 = Monday ... 7 = Sunday
|
||||||
def first_wday
|
def first_wday
|
||||||
|
@ -76,10 +76,10 @@ module Redmine
|
||||||
@first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1
|
@first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_wday
|
def last_wday
|
||||||
@last_dow ||= (first_wday + 5)%7 + 1
|
@last_dow ||= (first_wday + 5)%7 + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue