Redmineで2203年の予定を立てようとしたところ、エラーが出たので原因を調べていました。
どうやら、Railsのdistance_of_time_in_wordsでエラーが出ているようです。

ruby>>
def distance_of_time_in_words(
from_time, to_time = 0, include_seconds = false)
from_time = from_time.to_time if
from_time.respond_to?(:to_time)
to_time = to_time.to_time if
to_time.respond_to?(:to_time)
distance_in_minutes =
(((to_time - from_time).abs)/60).round
distance_in_seconds =
((to_time - from_time).abs).round
<<--

8行目あたりの減算でエラーが出ているようです。
実際、以下のような減算をしようとするとエラーが出ます。

ruby>>
Time.now - Date.parse("Mon, 01 Aug 2203").to_time
#=> RangeError: time - 7371010800.000000 out of Time range
<<--

ということで、あまりにも長い時間である場合には、
以下のような例外処理で対処するようにしました。

ruby>>
module ActionView
module Helpers
module DateHelper
def distance_of_time_in_words_with_limit(
from_time, to_time = 0, include_seconds = false
)
distance_of_time_in_words_without_limit(
from_time, to_time, include_seconds)
rescue
'a long time'
end
alias_method_chain :distance_of_time_in_words, :limit
end
end
end
<<--

これで23世紀の予定も思いのままです。

posted by genki genki on Fri 8 Aug 2008 at 06:44 with 0 comments
Contents rssrss
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Droonga関連の記事のまとめ
RuntimeErrorの特定のメッセージに限定してrescueする方法
jQueryでscriptタグを実行せずにappendする
Tags
coffeescriptdefergroongajsmemonodenodejs
Comments rssrss
https://www.thegameroom.org/de/sportwetten/neu/ https://www.thegameroom.org/de/sportwetten/neu/: Развлечения для взрослых доступен через безопасные... 05/30 23:29
https://zwinkle.co/2026/05/24/emotional-availability-the-quality-that-determines-whether-love-can-actually-grow/ https://zwinkle.co/2026/05/24/emotional-availability-the-quality-that-determines-whether-love-can-actually-grow/: When some one searches for his required thing, the... 05/30 23:19
http://dailyplaza.co.kr/bbs/board.php?bo_table=1301&wr_id=297372 http://dailyplaza.co.kr/bbs/board.php?bo_table=1301&wr_id=297372: Experience Singapore’ѕ leading furniture store a... 05/30 22:47
https://meneercasino.com/slot-reviews/wolf-gold https://meneercasino.com/slot-reviews/wolf-gold: Смотрите видео для взрослых на безопасных и наде... 05/30 22:36
http://82.165.16.39/index.php?title=User:MadelineWysocki http://82.165.16.39/index.php?title=User:MadelineWysocki: пинап играть 05/30 22:28
http://series60.ru/go.php?url=https://www.518fans.com/ http://series60.ru/go.php?url=https://www.518fans.com/: Article writing is also a fun, if you be familiar ... 05/30 20:49
https://www.1337games.org/online-casinos/betaalmogelijkheden/ideal/ https://www.1337games.org/online-casinos/betaalmogelijkheden/ideal/: 优质xxx平台 提供高质量的成人娱乐内容。选择 有保障的平台 以获得安全且愉快的观看体验。 05/30 20:44
https://scapaflow.org https://scapaflow.org: Thank you for the good writeup. It in fact was a a... 05/30 19:28
Services from s21g
YOMU Web小説リーダー
小説投稿サイトの公式ページを開き、WebView表示と読み上げ向け表示を切り替えて、移動中や作業中にもWeb小説の続きを聴きやすくするiPhoneアプリです。
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
個人開発者のためのホスティング一体型ノートサービス
ハンドミラー
iPhone向けの手鏡アプリ
ツイプロ(twpro)
Twitterプロフィールの高速検索エンジン