English 中文(简体)
26:12 时段的“距离”活度回归
原标题:ActiveRecord returns "argument out of range" for Time of 26:12

活跃的Record和Ruby的时标似乎在两度超过24小时的情况下起作用。 然而,我的数据库有许多,因为它们是午夜之后的一段时期,但被认为同一天。 这是我的设计决定:data Provide:

Note: Trips that span multiple dates will have stop times greater than 24:00:00. For example, if a trip begins at 10:30:00 p.m. and ends at 2:15:00 a.m. on the following day, the stop times would be 22:30:00 and 26:15:00. Entering those stop times as 22:30:00 and 02:15:00 would not produce the desired results.

我如何取消我时代目标的这种“有效性”? http://stackoverflow.com/questions/4076248/mysql-time-type-gives-an-argumenterror-argument-out-of-range-in-rails-if-ov>。 我把我的时间写成我的SQL问答题,但我不希望找到一个没有使数据库干预的解决办法。

<><>UPDATE: 关于保持“和”的重要性;24:00格式、查询和订购所有停机——使用该格式停机的时间将回去,例如:23:45、23:54、24:35、24:55、25:15,这是下一辆公共汽车实际开车的顺序。

另一种方式是返回:0:35, 0:55, 1:15, 23:45, 23:54(这是错误的),头3起停止——时间应当分类<><>><>> > > > 之后。 最后3段。

最佳回答

尽管“Tilo”是正确的,它很可能不是最佳的时间形式,但我不得不坚持这些格式,最后用“L”号来将时间栏改为:

sql = "SELECT CONVERT(stop_time, CHAR) as stop_time from stop_times"
stop_times = ActiveRecord::Base.connection.select_all sql
time = stop_times[0][ stop_time ] # => returned as a string
问题回答

贵问题的说明涉及的是时间推论,而不是时间目标。

我认为,你应当把时间推论作为非行的一个精干或浮动领域,其价值相当于第二位数的时差。

请注意,这是如何分管 时间物体:

> t1 = Time.now
 => 2011-11-22 20:54:54 -0800 
> t2 = Time.now.tomorrow
 => 2011-11-23 20:54:59 -0800 
> t2 - t1
 => 86404.928009862    # these are seconds!  just store this in a float or decimal field
> (t2 - t1).class
 => Float              # NOT a Time object

试图在时间标或时间点储存时间差似乎是错误的。

www.un.org/Depts/DGACM/index_spanish.htm 如果你从外部来源获得超量投入价值,如“26:12”,则更能将其转换成二者:

hours,minutes = "26:12".split(/:/).map(&:to_i)
seconds = hours * 3600 + minutes * 60

......然后将时间推移放在第二位


难道,这来自谷歌的预报吗? !

然而,它不存放在时间标上。

您可使用四轮驱动器清理:

 tomorrow,real_hour = hour.divmod(24)

“浏览量”今后储存天数,实际每天24小时有效值。

如何为这些开端和停留时间另设一个等级的“Triptime”? 航空公司的到达时间通常为“03:12+1”,意思是今后加1天。

页: 1





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签