From e815c78c3312ff9c6e9c5ce9ee4c01f426a2a94b Mon Sep 17 00:00:00 2001 From: echarp Date: Fri, 1 Aug 2014 00:40:26 +0200 Subject: [PATCH] Meilleur gestion des DateTime --- app/models/event.rb | 6 +++--- app/views/events/index.html.haml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 530e28e2..b75a72d7 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -12,10 +12,10 @@ class Event < ActiveRecord::Base scope :moderated, -> { where moderated: true } - scope :past, -> { where('end_time < ?', Date.today).order(start_time: :desc) } - scope :future, -> { where('end_time >= ?', Date.today).order(start_time: :asc) } + scope :past, -> { where('end_time < ?', DateTime.now).order(start_time: :desc) } + scope :future, -> { where('end_time >= ?', DateTime.now).order(start_time: :asc) } scope :future_30, -> { - where('start_time >= ? and end_time <= ?', Date.today, Date.today + 30) + where('start_time >= ? and end_time <= ?', DateTime.now, 30.days.from_now) .order :start_time } scope :year, -> year { diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml index 814ff371..deffee6c 100644 --- a/app/views/events/index.html.haml +++ b/app/views/events/index.html.haml @@ -1,7 +1,7 @@ = render '/lugs/search' unless controller.controller_name == 'lugs' -# Seems necessary, for the time being, to ensure calendar is changing days correctly -- config.time_zone = 'Paris' +- Time.zone = 'Paris' %form.region_selector - if params[:start_date]