From 564ae0145475b7563a6033790cbe4e1aede9bfeb Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Petteri=20R=C3=A4ty?= Date: Mon, 12 Oct 2009 14:20:28 +0300 Subject: [PATCH] Make use of config.time_zone Currently hobo ignores config.time_zone from environment.rb which means that times that are shown are not intuitive for users. This commit uses Time.zone.now and falls back on Time.now when config.time_zone is not set. Fixes ticket #473. --- hobo/lib/hobo/model.rb | 2 +- hobo/lib/hobo/rapid_helper.rb | 3 +++ hobo/taglibs/rapid_forms.dryml | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hobo/lib/hobo/model.rb b/hobo/lib/hobo/model.rb index 7db95c3..a724168 100644 --- a/hobo/lib/hobo/model.rb +++ b/hobo/lib/hobo/model.rb @@ -490,7 +490,7 @@ module Hobo if parts[0..2].include?(0) nil else - Time.local(*parts) + Time.zone ? Time.zone.local(*parts) : Time.local(*parts) end else value diff --git a/hobo/lib/hobo/rapid_helper.rb b/hobo/lib/hobo/rapid_helper.rb index 818b862..69d443b 100644 --- a/hobo/lib/hobo/rapid_helper.rb +++ b/hobo/lib/hobo/rapid_helper.rb @@ -146,4 +146,7 @@ module Hobo::RapidHelper fields end + def current_time + Time.now ? Time.zone.now : Time.now + end end diff --git a/hobo/taglibs/rapid_forms.dryml b/hobo/taglibs/rapid_forms.dryml index 70db926..8d548e0 100644 --- a/hobo/taglibs/rapid_forms.dryml +++ b/hobo/taglibs/rapid_forms.dryml @@ -342,7 +342,7 @@ The menus default to the current date if the current value is nil. --> <% order = order.nil? ? [:year, :month, :day] : comma_split(order).*.to_sym -%> - <%= select_date(this || Time.now, attributes.merge(:prefix => param_name_for_this, :order => order)) %> + <%= select_date(this || current_time, attributes.merge(:prefix => param_name_for_this, :order => order)) %> @@ -360,7 +360,7 @@ The menus default to the current time if the current value is nil. --> <% order = order.nil? ? [:year, :month, :day, :hour, :minute, :second] : comma_split(order).*.to_sym -%> - <%= select_date(this || Time.now, attributes.merge(:prefix => param_name_for_this, :order => order)) %> + <%= select_date(this || current_time, attributes.merge(:prefix => param_name_for_this, :order => order)) %> @@ -383,7 +383,7 @@ The menus default to the current time if the current value is nil. require 'ruby-debug' debugger end -%> - <%= select_datetime(this || Time.now, attributes.merge(:prefix => param_name_for_this)) %> + <%= select_datetime(this || current_time, attributes.merge(:prefix => param_name_for_this)) %> -- 1.6.3.3