Fixed: Roadmap crashes when a version has a due date > 2037.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1887 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-09-20 14:07:52 +00:00
parent 5452fd2f5a
commit 6854827f1a
32 changed files with 57 additions and 32 deletions

View File

@ -100,6 +100,19 @@ module ApplicationHelper
@time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format)
include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
end
def distance_of_date_in_words(from_date, to_date = 0)
from_date = from_date.to_date if from_date.respond_to?(:to_date)
to_date = to_date.to_date if to_date.respond_to?(:to_date)
distance_in_days = (to_date - from_date).abs
lwr(:actionview_datehelper_time_in_words_day, distance_in_days)
end
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))
end
end
# Truncates and returns the string as a single line
def truncate_single_line(string, *args)

View File

@ -1,9 +1,7 @@
<% if version.completed? %>
<p><%= format_date(version.effective_date) %></p>
<% elsif version.overdue? %>
<p><strong><%= l(:label_roadmap_overdue, distance_of_time_in_words(Time.now, version.effective_date)) %> (<%= format_date(version.effective_date) %>)</strong></p>
<% elsif version.effective_date %>
<p><strong><%=l(:label_roadmap_due_in)%> <%= distance_of_time_in_words Time.now, version.effective_date %> (<%= format_date(version.effective_date) %>)</strong></p>
<p><strong><%= due_date_distance_in_words(version.effective_date) %></strong> (<%= format_date(version.effective_date) %>)</p>
<% end %>
<p><%=h version.description %></p>

View File

@ -352,7 +352,7 @@ label_sort_higher: Премести по-горе
label_sort_lower: Премести по-долу
label_sort_lowest: Премести най-долу
label_roadmap: Пътна карта
label_roadmap_due_in: Излиза след
label_roadmap_due_in: Излиза след %s
label_roadmap_overdue: %s закъснение
label_roadmap_no_issues: Няма задачи за тази версия
label_search: Търсене

View File

@ -413,7 +413,7 @@ label_sort_higher: Mou cap amunt
label_sort_lower: Mou cap avall
label_sort_lowest: Mou a la part inferior
label_roadmap: Planificació
label_roadmap_due_in: Venç en
label_roadmap_due_in: Venç en %s
label_roadmap_overdue: %s tard
label_roadmap_no_issues: No hi ha assumptes per a aquesta versió
label_search: Cerca

View File

@ -409,7 +409,7 @@ label_sort_higher: Přesunout nahoru
label_sort_lower: Přesunout dolů
label_sort_lowest: Přesunout na konec
label_roadmap: Plán
label_roadmap_due_in: Zbývá
label_roadmap_due_in: Zbývá %s
label_roadmap_overdue: %s pozdě
label_roadmap_no_issues: Pro tuto verzi nejsou žádné úkoly
label_search: Hledat

View File

@ -418,7 +418,7 @@ label_sort_higher: Flyt op
label_sort_lower: Flyt ned
label_sort_lowest: Flyt til bunden
label_roadmap: Plan
label_roadmap_due_in: Deadline
label_roadmap_due_in: Deadline %s
label_roadmap_overdue: %s forsinket
label_roadmap_no_issues: Ingen sager i denne version
label_search: Søg

View File

@ -406,7 +406,7 @@ label_sort_higher: Eins höher
label_sort_lower: Eins tiefer
label_sort_lowest: Ans Ende
label_roadmap: Roadmap
label_roadmap_due_in: Fällig in
label_roadmap_due_in: Fällig in %s
label_roadmap_overdue: %s verspätet
label_roadmap_no_issues: Keine Tickets für diese Version
label_search: Suche

View File

@ -418,7 +418,7 @@ label_sort_higher: Move up
label_sort_lower: Move down
label_sort_lowest: Move to bottom
label_roadmap: Roadmap
label_roadmap_due_in: Due in
label_roadmap_due_in: Due in %s
label_roadmap_overdue: %s late
label_roadmap_no_issues: No issues for this version
label_search: Search

View File

@ -344,7 +344,7 @@ label_sort_higher: Subir
label_sort_lower: Bajar
label_sort_lowest: Último
label_roadmap: Roadmap
label_roadmap_due_in: Finaliza en
label_roadmap_due_in: Finaliza en %s
label_roadmap_no_issues: No hay peticiones para esta versión
label_search: Búsqueda
label_result: %d resultado

View File

@ -373,7 +373,7 @@ label_sort_higher: Siirrä ylös
label_sort_lower: Siirrä alas
label_sort_lowest: Siirrä alimmaiseksi
label_roadmap: Roadmap
label_roadmap_due_in: Määräaika
label_roadmap_due_in: Määräaika %s
label_roadmap_overdue: %s myöhässä
label_roadmap_no_issues: Ei tapahtumia tälle versiolle
label_search: Haku

View File

@ -417,7 +417,7 @@ label_sort_higher: Remonter
label_sort_lower: Descendre
label_sort_lowest: Descendre en dernier
label_roadmap: Roadmap
label_roadmap_due_in: Echéance dans
label_roadmap_due_in: Echéance dans %s
label_roadmap_overdue: En retard de %s
label_roadmap_no_issues: Aucune demande pour cette version
label_search: Recherche

View File

@ -357,7 +357,7 @@ label_sort_higher: הזז למעלה
label_sort_lower: הזז למטה
label_sort_lowest: הזז לתחתית
label_roadmap: מפת הדרכים
label_roadmap_due_in: נגמר בעוד
label_roadmap_due_in: %s נגמר בעוד
label_roadmap_overdue: %s מאחר
label_roadmap_no_issues: אין נושאים לגירסא זו
label_search: חפש

View File

@ -407,7 +407,7 @@ label_sort_higher: Eggyel feljebb
label_sort_lower: Eggyel lejjebb
label_sort_lowest: Az aljára
label_roadmap: Életút
label_roadmap_due_in: Elkészültéig várhatóan még
label_roadmap_due_in: Elkészültéig várhatóan még %s
label_roadmap_overdue: %s késésben
label_roadmap_no_issues: Nincsenek feladatok ehhez a verzióhoz
label_search: Keresés

View File

@ -352,7 +352,7 @@ label_sort_higher: Su
label_sort_lower: Giù
label_sort_lowest: Sposta in fondo
label_roadmap: Roadmap
label_roadmap_due_in: Da ultimare in
label_roadmap_due_in: Da ultimare in %s
label_roadmap_overdue: %s late
label_roadmap_no_issues: Nessuna segnalazione per questa versione
label_search: Ricerca

View File

@ -353,7 +353,7 @@ label_sort_higher: 上へ
label_sort_lower: 下へ
label_sort_lowest: 一番下へ
label_roadmap: ロードマップ
label_roadmap_due_in: 期日まで
label_roadmap_due_in: 期日まで %s
label_roadmap_overdue: %s late
label_roadmap_no_issues: このバージョンに向けてのチケットはありません
label_search: 検索

View File

@ -359,7 +359,7 @@ label_sort_higher: 위로
label_sort_lower: 아래로
label_sort_lowest: 최하단으로
label_roadmap: 로드맵
label_roadmap_due_in: 기한
label_roadmap_due_in: 기한 %s
label_roadmap_overdue: %s 지연
label_roadmap_no_issues: 이버전에 해당하는 이슈 없음
label_search: 검색

View File

@ -371,7 +371,7 @@ label_sort_higher: Perkelti į viršų
label_sort_lower: Perkelti žemyn
label_sort_lowest: Perkelti į apačią
label_roadmap: Veiklos grafikas
label_roadmap_due_in: Baigiasi po
label_roadmap_due_in: Baigiasi po %s
label_roadmap_overdue: %s vėluojama
label_roadmap_no_issues: Jokio darbo šiai versijai nėra
label_search: Ieškoti

View File

@ -352,7 +352,7 @@ label_sort_higher: Verplaats naar boven
label_sort_lower: Verplaats naar beneden
label_sort_lowest: Verplaats naar eind
label_roadmap: Roadmap
label_roadmap_due_in: Voldaan in
label_roadmap_due_in: Voldaan in %s
label_roadmap_overdue: %s overtijd
label_roadmap_no_issues: Geen issues voor deze versie
label_search: Zoeken

View File

@ -410,7 +410,7 @@ label_sort_higher: Flytt opp
label_sort_lower: Flytt ned
label_sort_lowest: Flytt til bunnen
label_roadmap: Veikart
label_roadmap_due_in: Frist om
label_roadmap_due_in: Frist om %s
label_roadmap_overdue: %s over fristen
label_roadmap_no_issues: Ingen saker for denne versjonen
label_search: Søk

View File

@ -344,7 +344,7 @@ label_sort_higher: Do góry
label_sort_lower: Do dołu
label_sort_lowest: Przesuń na dół
label_roadmap: Mapa
label_roadmap_due_in: W czasie
label_roadmap_due_in: W czasie %s
label_roadmap_no_issues: Brak zagadnień do tej wersji
label_search: Szukaj
label_result_plural: Rezultatów

View File

@ -415,7 +415,7 @@ label_sort_higher: Mover para cima
label_sort_lower: Mover para baixo
label_sort_lowest: Mover para o fim
label_roadmap: Planejamento
label_roadmap_due_in: Previsto para
label_roadmap_due_in: Previsto para %s
label_roadmap_overdue: %s atrasado
label_roadmap_no_issues: Sem tickets para esta versão
label_search: Busca

View File

@ -352,7 +352,7 @@ label_sort_higher: Mover para cima
label_sort_lower: Mover para baixo
label_sort_lowest: Mover para o fim
label_roadmap: Roadmap
label_roadmap_due_in: Termina em
label_roadmap_due_in: Termina em %s
label_roadmap_overdue: %s late
label_roadmap_no_issues: Sem tarefas para essa versão
label_search: Busca

View File

@ -352,7 +352,7 @@ label_sort_higher: Muta sus
label_sort_lower: Mota jos
label_sort_lowest: Mota ultima
label_roadmap: Harta activitatiilor
label_roadmap_due_in: Rezolvat in
label_roadmap_due_in: Rezolvat in %s
label_roadmap_overdue: %s intarziere
label_roadmap_no_issues: Nu sunt tichete pentru aceasta reviziune
label_search: Cauta

View File

@ -477,7 +477,7 @@ label_result_plural: Результаты
label_reverse_chronological_order: В обратном порядке
label_revision_plural: Редакции
label_revision: Редакция
label_roadmap_due_in: Вовремя
label_roadmap_due_in: Вовремя %s
label_roadmap_no_issues: Нет задач для данной версии
label_roadmap_overdue: %s опоздание
label_roadmap: Оперативный план

View File

@ -362,7 +362,7 @@ label_sort_higher: premesti na gore
label_sort_lower: Premesti na dole
label_sort_lowest: Premesti na dno
label_roadmap: Roadmap
label_roadmap_due_in: Završava se za
label_roadmap_due_in: Završava se za %s
label_roadmap_overdue: %s kasni
label_roadmap_no_issues: Nema kartica za ovu verziju
label_search: Traži

View File

@ -352,7 +352,7 @@ label_sort_higher: Flytta up
label_sort_lower: Flytta ner
label_sort_lowest: Flytta till botten
label_roadmap: Roadmap
label_roadmap_due_in: Färdig om
label_roadmap_due_in: Färdig om %s
label_roadmap_overdue: %s late
label_roadmap_no_issues: Inga brister för denna version
label_search: Sök

View File

@ -408,7 +408,7 @@ label_sort_higher: ย้ายขึ้น
label_sort_lower: ย้ายลง
label_sort_lowest: ย้ายไปล่างสุด
label_roadmap: แผนงาน
label_roadmap_due_in: ถึงกำหนดใน
label_roadmap_due_in: ถึงกำหนดใน %s
label_roadmap_overdue: %s ช้ากว่ากำหนด
label_roadmap_no_issues: ไม่มีปัญหาสำหรับรุ่นนี้
label_search: ค้นหา

View File

@ -405,7 +405,7 @@ label_sort_higher: Yukarı taşı
label_sort_lower: Aşağı taşı
label_sort_lowest: Dibe taşı
label_roadmap: Yol Haritası
label_roadmap_due_in: Due in
label_roadmap_due_in: Due in %s
label_roadmap_overdue: %s geç
label_roadmap_no_issues: Bu versiyon için ileti yok
label_search: Ara

View File

@ -368,7 +368,7 @@ label_sort_higher: Вгору
label_sort_lower: Вниз
label_sort_lowest: У кінець
label_roadmap: Оперативний план
label_roadmap_due_in: Строк
label_roadmap_due_in: Строк %s
label_roadmap_overdue: %s запізнення
label_roadmap_no_issues: Немає питань для даної версії
label_search: Пошук

View File

@ -418,7 +418,7 @@ label_sort_higher: 往上移動
label_sort_lower: 往下移動
label_sort_lowest: 移動至結尾
label_roadmap: 版本藍圖
label_roadmap_due_in: 倒數天數
label_roadmap_due_in: 倒數天數 %s
label_roadmap_overdue: %s 逾期
label_roadmap_no_issues: 此版本尚未包含任何項目
label_search: 搜尋

View File

@ -418,7 +418,7 @@ label_sort_higher: 上移
label_sort_lower: 下移
label_sort_lowest: 置底
label_roadmap: 路线图
label_roadmap_due_in: 截止日期到
label_roadmap_due_in: 截止日期到 %s
label_roadmap_overdue: %s 延期
label_roadmap_no_issues: 该版本没有问题
label_search: 搜索

View File

@ -367,4 +367,18 @@ EXPECTED
assert_equal Time.now.strftime('%d %m %Y %H %M'), format_time(now)
assert_equal Time.now.strftime('%H %M'), format_time(now, false)
end
def test_due_date_distance_in_words
to_test = { Date.today => 'Due in 0 days',
Date.today + 1 => 'Due in 1 day',
Date.today + 100 => 'Due in 100 days',
Date.today + 20000 => 'Due in 20000 days',
Date.today - 1 => '1 day late',
Date.today - 100 => '100 days late',
Date.today - 20000 => '20000 days late',
}
to_test.each do |date, expected|
assert_equal expected, due_date_distance_in_words(date)
end
end
end