#3 ✓resolved
Marcia Almeida

helper de intervalos de horas

Reported by Marcia Almeida | September 22nd, 2008 @ 05:47 PM

Reescrever de forma que o método receba horário de início e fim e o intervalo de minutos, que hoje está fixo em 15. Também o método está no portal, no application controller, quando deveria estar em application helper.

Comments and changes to this ticket

  • Ícaro L. da Motta

    Ícaro L. da Motta November 6th, 2008 @ 11:58 AM

    • Assigned user set to “Ícaro L. da Motta”
    • State changed from “new” to “resolved”

    O intervalo deve ser dado em minutos

    
      # Retorna um array com hora:minuto no intervalo de
      # <begin_time> à <end_time> em incrementos de <min_interval>
      # Exemplo: time_intervals '15:45', '19:30', 20
      def time_intervals(begin_time, end_time, min_interval = 30)
        intervals = []
        curr_time = Time.parse(begin_time)
        finish_time  = Time.parse(end_time)
    
        if finish_time.hour < curr_time.hour
          finish_time += 1.day
        end
    
        while curr_time <= finish_time
          intervals << "#{'%02d' % curr_time.hour}:#{'%02d' % curr_time.min}"
          curr_time += min_interval.minutes
        end
    
        intervals
      end
    

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tarefas relacionaas às atividades desempenhadas pela equipe de desenvolvimento

People watching this ticket

Tags

Pages