def load_new_information(character_id=nil)
conds = []
- conds << ['date <= ? ', Time.zone.now]
+ conds << ['date <= ? ', Time.now]
@new_informations = NewInformation.find(:all,
:conditions => flatten_conditions(conds),
:order => "position")
+# -*- coding: utf-8 -*-
class Mail < ActiveRecord::Base
THRESHOLD = 5
def self.post_all_mail
mails.each do |mail|
begin
logger.info('Mail.post_all_mail: send %s -> %s' % [mail.from_address, mail.to_address])
- mail.update_attribute(:sent_at, Time.zone.now)
+ mail.update_attribute(:sent_at, Time.now)
smtp.send_message(Base64.decode64(mail.message), mail.from_address, mail.to_address)
rescue Net::SMTPSyntaxError => e # 5xx
handle_fatal_error(mail)
# end
# 販売期間内
- def in_sale_term?(now=Time.zone.now)
+ def in_sale_term?(now=Time.now)
sale_start_at <= now && now <= (sale_end_at + 1.day - 1 )
end
# 公開期間内
- def in_public_term?(now=Time.zone.now)
+ def in_public_term?(now=Time.now)
public_start_at <= now && now <= (public_end_at + 1.day - 1)
end
# 在庫がある
end
def self.today_utc(today)
- ud = Time.zone.local_to_utc(Time.local(today.year,today.month,today.day))
+ ud = Time.local(today.year,today.month,today.day)
DateTime.new(ud.year, ud.month, ud.day, ud.hour, ud.min, ud.sec)
end
end
+# -*- coding: utf-8 -*-
require 'open-uri'
require 'rexml/document'
require 'timeout'
RANKING_URL = "RECOMMEND_RANKING_URL" #ランキング用のURLを設定して下さい(team=w まで)
def self.recommend_get(product_id, type=TYPE_BUY)
- unless Recommend.find(:first, :conditions => ["product_id = ? and request_type = ? and created_at > ?", product_id, type, Time.zone.local_to_utc(Time.now - (60 * 60))])
+ unless Recommend.find(:first, :conditions => ["product_id = ? and request_type = ? and created_at > ?", product_id, type, Time.now - (60 * 60)])
self.recommend_network_get(product_id, type)
end
end
def self.ranking_get(limit = nil)
- unless Recommend.find(:first, :conditions => ["created_at > ? and product_id is null and request_type is null",Time.zone.local_to_utc(Time.now - (60 * 60))])
+ unless Recommend.find(:first, :conditions => ["created_at > ? and product_id is null and request_type is null",Time.now - (60 * 60)])
self.ranking_network_get
end
+# -*- coding: utf-8 -*-
# 検索条件を格納する
# 例: @search = SearchForm.new(params[:search])
elsif value.is_a?(String) &&
value =~ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/
# 日時に見える文字列は Date に
- send(name+'=', Time.zone.parse(value))
+ send(name+'=', Time.parse(value))
else
send(name+'=', value)
end
end
end
if selected_time
- Time.zone.local(year.to_i,month.to_i,day.to_i,hour.to_i,min.to_i,sec.to_i)
+ Time.local(year.to_i,month.to_i,day.to_i,hour.to_i,min.to_i,sec.to_i)
else
- Time.zone.local(year.to_i,month.to_i,day.to_i)
+ Time.local(year.to_i,month.to_i,day.to_i)
end
end
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
#config.time_zone = 'UTC'
- config.time_zone = 'Tokyo'
- #config.active_record.default_timezone = 'Tokyo'
+ #config.time_zone = 'Tokyo'
+ config.active_record.default_timezone = 'Tokyo'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
def parse_date_select params, name
return nil unless params and not params['%s(1i)' % name].blank?
args = (1..3).map {|i| params["%s(%di)" % [name, i]]}.reject(&:blank?).map(&:to_i)
- Time.zone.local(*args)
+ args << 1 if args.length < 3
+ Time.local(*args)
end
require 'gruff'
date_to = parse_date_select(params[:search], 'date_to')
else
date_from = parse_date_select(params[:search], 'month')
- date_to = Time.zone.local(date_from.year, date_from.month, -1) if date_from
+ date_to = Time.local(date_from.year, date_from.month, 1) + 1.month - 1.day if date_from
end
- date_to &&= Time.zone.local(date_to.year, date_to.month, date_to.day, 23, 59, 59)
+ date_to &&= Time.local(date_to.year, date_to.month, date_to.day, 23, 59, 59)
{ :date_from => date_from, :date_to => date_to }
end
def graph
@records or return nil
+ return nil if @records == []
g = init_graph(Gruff::Line)
g.title = self.title
g.data('価格', @records.map{|r| r['total']})
end
def columns date_column_name
- offset = "%d" % Time.zone.utc_offset
- dow_column_interval = "%s + #{MergeAdapterUtil.interval_second(offset)}" % [date_column_name]
+ #offset = "%d" % Time.zone.utc_offset
+ dow_column_interval = "%s" % [date_column_name]#+ #{MergeAdapterUtil.interval_second(offset)}" % [date_column_name]
dow_column = "#{MergeAdapterUtil.day_of_week(dow_column_interval)} as dow"
@fields.map do | f |
unless f == 'dow'
- "extract(%s from %s + #{MergeAdapterUtil.interval_second(offset)}) as %s" % [f, date_column_name, f]
+ "extract(%s from %s ) as %s" % [f, date_column_name, f]
else
dow_column
end
d = date_from
while d.year < date_to.year || d.month <= date_to.month
terms << term_of(date_to_record(d))
- d = Time.zone.local(d.year, d.month + 1)
+ d = Time.local(d.year, d.month + 1)
end
terms
when 'year'
d = date_from
while d.year <= date_to.year
terms << term_of(date_to_record(d))
- d = Time.zone.local(d.year + 1)
+ d = Time.local(d.year + 1)
end
terms
when 'wday'
+# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Admin::AuthoritiesController do
describe "POST 'create'" do
it "正常に追加できるパターン" do
- new_id = Authority.maximum(:id) + 1
get 'new'
authority = {:name => "管理者2"}
functions = {"1" => 1, "2" => 2}
post 'create', :authority => authority, :functions => functions
assigns[:authority].should_not be_nil
#assigns[:authority].id.should == new_id
- check = Authority.find_by_id(new_id)
+ check = Authority.find(:last)
check.name.should == "管理者2"
response.should redirect_to(:action => :index)
end
it "authorityが不正なパターン" do
- new_id = Authority.maximum(:id) + 1
get 'new'
authority = {:name => ""}
functions = {"1" => 1, "2" => 2}
end
it "functionsが不正なパターン" do
- new_id = Authority.maximum(:id) + 1
get 'new'
authority = {:name => "管理者2"}
functions = {"test" => 1, "2" => 2}
+# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../../spec_helper'
describe Admin::NewInformationsController do
post 'confirm', :new_information => record
get 'update', :new_information => record
assigns[:new_information].id.should == new_informations(:success_validates_2).id
- assigns[:new_information].date.should == Time.mktime(2008, 01, 01)
+ assigns[:new_information].date.should == DateTime.parse("2008-01-01")
#assigns[:status].should == "confirm"
response.should redirect_to("admin/new_informations")
end
post 'confirm', :new_information => record
get 'update', :new_information => record
assigns[:new_information].id.should == id
- assigns[:new_information].date.should == Time.mktime(2008, 01, 01)
+ p assigns[:new_information].date.class
+ assigns[:new_information].date.should == DateTime.parse("2008-01-01")
response.should_not be_redirect
end
end
+# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../../spec_helper'
# Date を date_select の形にする
end
it "合計を表示する(検索結果0)" do
- post 'index', :page => 'term', :search => { 'month(1i)'=>1008, 'month(2i)'=>6, 'by_month'=>'x' }
+ post 'index', :page => 'term', :search => { 'month(1i)'=>1978, 'month(2i)'=>6, 'by_month'=>'x' }
assigns[:total].should_not be_nil
assigns[:total]['total'].should == 0
end
+
it "合計を表示する(検索結果複数)" do
post 'index', :page => 'term', :type => 'wday', :search => {
'date_from(1i)'=>2000, 'date_from(2i)'=>1, 'date_from(31)'=>1,
- 'date_to(1i)'=>2100, 'date_to(2i)'=>9, 'date_to(3i)'=>9, 'by_date'=>'x'
+ 'date_to(1i)'=>2030, 'date_to(2i)'=>9, 'date_to(3i)'=>9, 'by_date'=>'x'
}
assigns[:total]['total'].should > 0
end
+# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Questionnaire do
#更新時間について、
#questionnaire_answer.created_atとquestionnaire_answer[created_at]の結果が違うので特別処理
if "created_at" == c
- arr << (qa.created_at.nil? ? "" : qa.created_at.strftime('%Y-%m-%d %H:%M:%S'))
+ arr << (qa.created_at.nil? ? "" : qa.created_at.strftime('%Y-%m-%dT%H:%M:%S+00:00'))
else
arr << (qa[c].nil? ? "" : qa[c].to_s)
end
+# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
class TestForm < SearchForm
set_field_names({"customer_id" => "顧客コード"})
search_form = SearchForm.new({"order_date_to" => "2009-10-01 00:30:45","month(1i)"=>"2009"})
#期待結果:
#1.文字列の時間系をdateへ変換 2.["month(1i)"=>"2009"]が [@month=Thu, 01 Jan 2009 00:00:00]に変換
- search_form.order_date_to.class.should == ActiveSupport::TimeWithZone
+ search_form.order_date_to.class.should == Time
search_form.month.should_not be_nil
- search_form.month.should == Time.zone.parse("2009-01-01 00:00:00")
+ search_form.month.should == Time.parse("2009-01-01 00:00:00")
end
it "その他" do
TestForm.human_attribute_name("customer_id").should == "顧客コード"
TestForm.field_names.should == {"customer_id" => "顧客コード","customer_name" => "顧客名"}
end
end
-end
\ No newline at end of file
+end