Patch #22320 » 0001-Replace-Date.today-with-User.current.today.patch
| app/controllers/activities_controller.rb | ||
|---|---|---|
|
begin; @date_to = params[:from].to_date + 1; rescue; end
|
||
|
end
|
||
|
@date_to ||= Date.today + 1
|
||
|
@date_to ||= User.current.today + 1
|
||
|
@date_from = @date_to - @days
|
||
|
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||
|
if params[:user_id].present?
|
||
| app/controllers/calendars_controller.rb | ||
|---|---|---|
|
@month = params[:month].to_i
|
||
|
end
|
||
|
end
|
||
|
@year ||= Date.today.year
|
||
|
@month ||= Date.today.month
|
||
|
@year ||= User.current.today.year
|
||
|
@month ||= User.current.today.month
|
||
|
@calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
|
||
|
retrieve_query
|
||
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
@issue.project ||= @issue.allowed_target_projects.first
|
||
|
end
|
||
|
@issue.author ||= User.current
|
||
|
@issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
|
||
|
@issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
|
||
|
attrs = (params[:issue] || {}).deep_dup
|
||
|
if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
|
||
| app/controllers/repositories_controller.rb | ||
|---|---|---|
|
end
|
||
|
def graph_commits_per_month(repository)
|
||
|
@date_to = Date.today
|
||
|
@date_to = User.current.today
|
||
|
@date_from = @date_to << 11
|
||
|
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
||
|
commits_by_day = Changeset.
|
||
| ... | ... | |
|
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
||
|
fields = []
|
||
|
12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
|
||
|
today = User.current.today
|
||
|
12.times {|m| fields << month_name(((today.month - 1 - m) % 12) + 1)}
|
||
|
graph = SVG::Graph::Bar.new(
|
||
|
:height => 300,
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
def due_date_distance_in_words(date)
|
||
|
if date
|
||
|
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
|
||
|
l((date < User.current.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(User.current.today, date))
|
||
|
end
|
||
|
end
|
||
| app/helpers/my_helper.rb | ||
|---|---|---|
|
def timelog_items
|
||
|
TimeEntry.
|
||
|
where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today).
|
||
|
where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, User.current.today - 6, User.current.today).
|
||
|
joins(:activity, :project).
|
||
|
references(:issue => [:tracker, :status]).
|
||
|
includes(:issue => [:tracker, :status]).
|
||
| app/helpers/settings_helper.rb | ||
|---|---|---|
|
# Returns the options for the date_format setting
|
||
|
def date_format_setting_options(locale)
|
||
|
Setting::DATE_FORMATS.map do |f|
|
||
|
today = ::I18n.l(Date.today, :locale => locale, :format => f)
|
||
|
today = ::I18n.l(User.current.today, :locale => locale, :format => f)
|
||
|
format = f.gsub('%', '').gsub(/[dmY]/) do
|
||
|
{'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]
|
||
|
end
|
||
| app/models/issue.rb | ||
|---|---|---|
|
# Returns true if the issue is overdue
|
||
|
def overdue?
|
||
|
due_date.present? && (due_date < Date.today) && !closed?
|
||
|
due_date.present? && (due_date < User.current.today) && !closed?
|
||
|
end
|
||
|
# Is the amount of work done less than it should for the due date
|
||
|
def behind_schedule?
|
||
|
return false if start_date.nil? || due_date.nil?
|
||
|
done_date = start_date + ((due_date - start_date + 1) * done_ratio / 100).floor
|
||
|
return done_date <= Date.today
|
||
|
return done_date <= User.current.today
|
||
|
end
|
||
|
# Does this issue have children?
|
||
| app/models/mail_handler.rb | ||
|---|---|---|
|
issue.subject = '(no subject)'
|
||
|
end
|
||
|
issue.description = cleaned_up_text_body
|
||
|
issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
|
||
|
issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
|
||
|
issue.is_private = (handler_options[:issue][:is_private] == '1')
|
||
|
# add To and Cc as watchers before saving so the watchers can reply to Redmine
|
||
| app/models/project.rb | ||
|---|---|---|
|
end
|
||
|
def overdue?
|
||
|
active? && !due_date.nil? && (due_date < Date.today)
|
||
|
active? && !due_date.nil? && (due_date < User.current.today)
|
||
|
end
|
||
|
# Returns the percent completed for this project, based on the
|
||
| app/models/query.rb | ||
|---|---|---|
|
when "w"
|
||
|
# = this week
|
||
|
first_day_of_week = l(:general_first_day_of_week).to_i
|
||
|
day_of_week = Date.today.cwday
|
||
|
day_of_week = User.current.today.cwday
|
||
|
days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)
|
||
|
sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6, is_custom_filter)
|
||
|
when "lw"
|
||
|
# = last week
|
||
|
first_day_of_week = l(:general_first_day_of_week).to_i
|
||
|
day_of_week = Date.today.cwday
|
||
|
day_of_week = User.current.today.cwday
|
||
|
days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)
|
||
|
sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1, is_custom_filter)
|
||
|
when "l2w"
|
||
|
# = last 2 weeks
|
||
|
first_day_of_week = l(:general_first_day_of_week).to_i
|
||
|
day_of_week = Date.today.cwday
|
||
|
day_of_week = User.current.today.cwday
|
||
|
days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)
|
||
|
sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1, is_custom_filter)
|
||
|
when "m"
|
||
|
# = this month
|
||
|
date = Date.today
|
||
|
date = User.current.today
|
||
|
sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)
|
||
|
when "lm"
|
||
|
# = last month
|
||
|
date = Date.today.prev_month
|
||
|
date = User.current.today.prev_month
|
||
|
sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)
|
||
|
when "y"
|
||
|
# = this year
|
||
|
date = Date.today
|
||
|
date = User.current.today
|
||
|
sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year, is_custom_filter)
|
||
|
when "~"
|
||
|
sql = sql_contains("#{db_table}.#{db_field}", value.first)
|
||
| ... | ... | |
|
# Returns a SQL clause for a date or datetime field using relative dates.
|
||
|
def relative_date_clause(table, field, days_from, days_to, is_custom_filter)
|
||
|
date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil), is_custom_filter)
|
||
|
date_clause(table, field, (days_from ? User.current.today + days_from : nil), (days_to ? User.current.today + days_to : nil), is_custom_filter)
|
||
|
end
|
||
|
# Returns a Date or Time from the given filter value
|
||
| app/models/user.rb | ||
|---|---|---|
|
if time_zone.nil?
|
||
|
Date.today
|
||
|
else
|
||
|
# TODO replace with time_zone.today
|
||
|
Time.now.in_time_zone(time_zone).to_date
|
||
|
end
|
||
|
end
|
||
| app/models/version.rb | ||
|---|---|---|
|
# Returns true if the version is completed: closed or due date reached and no open issues
|
||
|
def completed?
|
||
|
closed? || (effective_date && (effective_date < Date.today) && (open_issues_count == 0))
|
||
|
closed? || (effective_date && (effective_date < User.current.today) && (open_issues_count == 0))
|
||
|
end
|
||
|
def behind_schedule?
|
||
| ... | ... | |
|
return false
|
||
|
elsif due_date && start_date
|
||
|
done_date = start_date + ((due_date - start_date+1)* completed_percent/100).floor
|
||
|
return done_date <= Date.today
|
||
|
return done_date <= User.current.today
|
||
|
else
|
||
|
false # No issues so it's not late
|
||
|
end
|
||
| ... | ... | |
|
# Returns true if the version is overdue: due date reached and some open issues
|
||
|
def overdue?
|
||
|
effective_date && (effective_date < Date.today) && (open_issues_count > 0)
|
||
|
effective_date && (effective_date < User.current.today) && (open_issues_count > 0)
|
||
|
end
|
||
|
# Returns assigned issues count
|
||
| app/views/activities/index.html.erb | ||
|---|---|---|
|
<%= link_to_content_update(l(:label_next) + " \xc2\xbb",
|
||
|
params.merge(:from => @date_to + @days - 1),
|
||
|
:title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1)),
|
||
|
:accesskey => accesskey(:next)) unless @date_to >= Date.today %>
|
||
|
:accesskey => accesskey(:next)) unless @date_to >= User.current.today %>
|
||
|
</div>
|
||
|
|
||
|
<% other_formats_links do |f| %>
|
||
| app/views/common/_calendar.html.erb | ||
|---|---|---|
|
<% day = calendar.startdt
|
||
|
while day <= calendar.enddt %>
|
||
|
<%= ("<td class='week-number' title='#{ l(:label_week) }'>#{(day+(11-day.cwday)%7).cweek}</td>".html_safe) if day.cwday == calendar.first_wday %>
|
||
|
<td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>">
|
||
|
<td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if User.current.today == day %>">
|
||
|
<p class="day-num"><%= day.day %></p>
|
||
|
<% calendar.events_on(day).each do |i| %>
|
||
|
<% if i.is_a? Issue %>
|
||
| app/views/gantts/show.html.erb | ||
|---|---|---|
|
<%= @gantt.lines.html_safe %>
|
||
|
<% ###### Today red line (excluded from cache) ###### %>
|
||
|
<% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
|
||
|
<% if User.current.today >= @gantt.date_from and User.current.today <= @gantt.date_to %>
|
||
|
<%
|
||
|
today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
|
||
|
today_left = (((User.current.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
|
||
|
style = ""
|
||
|
style += "position: absolute;"
|
||
|
style += "height: #{g_height}px;"
|
||
| app/views/my/blocks/_calendar.html.erb | ||
|---|---|---|
|
<h3><%= l(:label_calendar) %></h3>
|
||
|
<% calendar = Redmine::Helpers::Calendar.new(Date.today, current_language, :week)
|
||
|
<% calendar = Redmine::Helpers::Calendar.new(User.current.today, current_language, :week)
|
||
|
calendar.events = calendar_items(calendar.startdt, calendar.enddt) %>
|
||
|
<%= render :partial => 'common/calendar', :locals => {:calendar => calendar } %>
|
||
| app/views/my/blocks/_timelog.html.erb | ||
|---|---|---|
|
<tbody>
|
||
|
<% entries_by_day.keys.sort.reverse.each do |day| %>
|
||
|
<tr class="odd">
|
||
|
<td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
|
||
|
<td><strong><%= day == User.current.today ? l(:label_today).titleize : format_date(day) %></strong></td>
|
||
|
<td colspan="2"></td>
|
||
|
<td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
|
||
|
<td></td>
|
||
| lib/redmine/export/pdf/issues_pdf_helper.rb | ||
|---|---|---|
|
pdf = ITCPDF.new(current_language)
|
||
|
pdf.set_title("#{issue.project} - #{issue.tracker} ##{issue.id}")
|
||
|
pdf.alias_nb_pages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.footer_date = format_date(User.current.today)
|
||
|
pdf.add_page
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
buf = "#{issue.project} - #{issue.tracker} ##{issue.id}"
|
||
| ... | ... | |
|
title = "#{project} - #{title}" if project
|
||
|
pdf.set_title(title)
|
||
|
pdf.alias_nb_pages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.footer_date = format_date(User.current.today)
|
||
|
pdf.set_auto_page_break(false)
|
||
|
pdf.add_page("L")
|
||
|
|
||
| lib/redmine/export/pdf/wiki_pdf_helper.rb | ||
|---|---|---|
|
pdf = Redmine::Export::PDF::ITCPDF.new(current_language)
|
||
|
pdf.set_title(project.name)
|
||
|
pdf.alias_nb_pages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.footer_date = format_date(User.current.today)
|
||
|
pdf.add_page
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
pdf.RDMMultiCell(190,5, project.name)
|
||
| ... | ... | |
|
pdf = ITCPDF.new(current_language)
|
||
|
pdf.set_title("#{project} - #{page.title}")
|
||
|
pdf.alias_nb_pages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.footer_date = format_date(User.current.today)
|
||
|
pdf.add_page
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
pdf.RDMMultiCell(190,5,
|
||
| lib/redmine/helpers/gantt.rb | ||
|---|---|---|
|
@month_from = 1
|
||
|
end
|
||
|
else
|
||
|
@month_from ||= Date.today.month
|
||
|
@year_from ||= Date.today.year
|
||
|
@month_from ||= User.current.today.month
|
||
|
@year_from ||= User.current.today.year
|
||
|
end
|
||
|
zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
|
||
|
@zoom = (zoom > 0 && zoom < 5) ? zoom : 2
|
||
| ... | ... | |
|
lines(:image => gc, :top => top, :zoom => zoom,
|
||
|
:subject_width => subject_width, :format => :image)
|
||
|
# today red line
|
||
|
if Date.today >= @date_from and Date.today <= date_to
|
||
|
if User.current.today >= @date_from and User.current.today <= date_to
|
||
|
gc.stroke('red')
|
||
|
x = (Date.today - @date_from + 1) * zoom + subject_width
|
||
|
x = (User.current.today - @date_from + 1) * zoom + subject_width
|
||
|
gc.line(x, headers_height, x, headers_height + g_height - 1)
|
||
|
end
|
||
|
gc.draw(imgl)
|
||
| ... | ... | |
|
pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
|
||
|
pdf.SetTitle("#{l(:label_gantt)} #{project}")
|
||
|
pdf.alias_nb_pages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.footer_date = format_date(User.current.today)
|
||
|
pdf.AddPage("L")
|
||
|
pdf.SetFontStyle('B', 12)
|
||
|
pdf.SetX(15)
|
||
| ... | ... | |
|
coords[:bar_progress_end] = self.date_to - self.date_from + 1
|
||
|
end
|
||
|
end
|
||
|
if progress_date < Date.today
|
||
|
late_date = [Date.today, end_date].min
|
||
|
if progress_date < User.current.today
|
||
|
late_date = [User.current.today, end_date].min
|
||
|
if late_date > self.date_from && late_date > start_date
|
||
|
if late_date < self.date_to
|
||
|
coords[:bar_late_end] = late_date - self.date_from + 1
|
||
| lib/redmine/helpers/time_report.rb | ||
|---|---|---|
|
end
|
||
|
|
||
|
min = @hours.collect {|row| row['spent_on']}.min
|
||
|
@from = min ? min.to_date : Date.today
|
||
|
@from = min ? min.to_date : User.current.today
|
||
|
max = @hours.collect {|row| row['spent_on']}.max
|
||
|
@to = max ? max.to_date : Date.today
|
||
|
@to = max ? max.to_date : User.current.today
|
||
|
|
||
|
@total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f}
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
issue.reload.assigned_to = nil
|
||
|
assert_equal group, issue.assigned_to_was
|
||
|
end
|
||
|
def test_issue_overdue_should_respect_user_timezone
|
||
|
user_in_europe = users(:users_001)
|
||
|
user_in_europe.pref.update_attribute :time_zone, 'UTC'
|
||
|
user_in_asia = users(:users_002)
|
||
|
user_in_asia.pref.update_attribute :time_zone, 'Hongkong'
|
||
|
issue = Issue.generate! :due_date => Date.parse('2016-03-20')
|
||
|
# server time is UTC
|
||
|
time = Time.parse '2016-03-20 20:00 UTC'
|
||
|
Time.stubs(:now).returns(time)
|
||
|
Date.stubs(:today).returns(time.to_date)
|
||
|
# for a user in the same time zone as the server the issue is not overdue
|
||
|
# yet
|
||
|
User.current = user_in_europe
|
||
|
assert !issue.overdue?
|
||
|
# at the same time, a user in East Asia looks at the issue - it's already
|
||
|
# March 21st and the issue should be marked overdue
|
||
|
User.current = user_in_asia
|
||
|
assert issue.overdue?
|
||
|
end
|
||
|
end
|
||