400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
# File 'lib/active_scaffold/finder.rb', line 400
def datetime_from_to_for_trend(column, value)
case value['opt']
when 'PAST'
trend_number = [value['number'].to_i, 1].max
now = datetime_now
if datetime_column_date?(column)
from = now.beginning_of_day.ago(trend_number.send(value['unit'].downcase.singularize.to_sym))
to = now.end_of_day
else
from = now.ago(trend_number.send(value['unit'].downcase.singularize.to_sym))
to = now
end
[from, to]
when 'FUTURE'
trend_number = [value['number'].to_i, 1].max
now = datetime_now
if datetime_column_date?(column)
from = now.beginning_of_day
to = now.end_of_day.in(trend_number.send(value['unit'].downcase.singularize.to_sym))
else
from = now
to = now.in(trend_number.send(value['unit'].downcase.singularize.to_sym))
end
[from, to]
end
end
|