Tag: 日历

RAILS:使用calendar_for预订一段时间后资源的可用性

我正在为Rails中的可数资源租赁编写预订系统。 资源所有者希望看到随时间预订的总资源量百分比。 calendar_for gem似乎是不错的选择,除了我找不到在一段时间内显示这个百分比的方法。 假设,总资源为100: 客户 – 2013年1月12日至2013年2月20日的书籍20个单位。 客户-B书从2013年1月15日至2013年3月1日30个单位。 我想看看预订的容量 从2013年12月12日到2013年1月14日= 20%(仅限客户A预订) 2013年1月15日至2013年2月20日= 50%(20 + 30)(从客户A和客户B预订) 2013年2月21日至2013年3月1日= 30%(仅限客户B预订) 渐渐地,我收集了这些gem gem’事件日历’ gem’table_builder’ gem’watu_table_builder’ gem’calendar_date_select’ 下面的代码是着名的RailsCast#213课程的复制品。 index_calendar.html.erb @date.year, :month => @date.prev_month.month) do |calendar| %> :from_date) do |date, bookings| %> 替代是: 这个我试过结合booking.rb两种方法: 这显示了from_date(即开始时)预订单位的百分比 def capacity @a=Resource.find_by_id(self.resource_id).units [(self.units/@a*100).to_s + “%”].join end 这只显示from_date的预订总数 def total_capacity(day) @wall=Booking.joins(:resource). where(“#{day}#{day}”).sum(:units) end 预订模型包含以下字段: :从日期, […]

event_calendar时区

嗨,我可能会遗漏一些东西但是event_calendar rails gem如何确定时区? 在本地,它尊重我的时区,但不在服务器上。 我在heroku上运行它所以它使用UTC来确定它在哪一天等。在Application.rb我设置 config.time_zone = “Pacific Time (US & Canada)” 。 我发现的只是这个较旧的讨论并不是决定性的。 这改变了吗? https://github.com/elevation/event_calendar/issues/4 如何设置event_calendar gem的时区? 预先感谢您的帮助。

用于复原事件的gem ice_cube

我有简单的事件模型(标题,日期,用户)我创建了几个月的事件日历(gem’watu_table_builder’)。 我需要该function来创建重复事件。 我发现我可能会使用gem ice_cube。 但我不清楚。 我添加到模型: class Event true, :length => { :minimum => 5 } validates :shedule, :presence => true def self.events_and_repeats(date) @events = Event.where(shedule:date.beginning_of_month..date.end_of_month) # Here I need to figure out what is events repeats at this month (from date param) # how I may combine it with Events array @events_repeats = @events […]

使用Rails将日历转换为表单?

问题 :如何将日历转换为呈现日期选择以匹配日历日而不是当前日期的表单? 我正在尝试做什么:我想创建一个显示骑车者锻炼的日历。 在每个日历日内创建锻炼,自动渲染与表单中给定日期匹配的锻炼日期 每次锻炼都有很多间隔。 每个日历日都有一次锻炼。 插件:从https://github.com/p8/table_builder中提取table_builder.rb和calendar_helper.rb(gem和插件都不使用rails 3.1进行部署) class WorkoutsController.rb def new @workout = Workout.new @date = params[:month] ? Date.parse(params[:month].gsub(‘-‘, ‘/’)) : Date.today 3.times do @workout.intervals.build end end Workout.rb attr_accessible :workoutdate, :intervals_attributes has_many :intervals, :dependent => :destroy accepts_nested_attributes_for :intervals, :reject_if => lambda { |a| a[:interval_name].blank? }, :allow_destroy => true Interval.rb attr_accessible :interval_name, :workout_id belongs_to :workout […]

如何根据每天打印月份的日子(例如:苏莫图我们……等)?

我有一个数字1-31的大字符串。 我怎么能把这个月的名字集中在一起? 我的代码: class Month attr_reader :month, :year def initialize( month, year) @month = month @year = year end def month_names names_of_months = {1 => ‘January’, 2 => ‘February’, 3 => ‘March’, 4 => ‘April’, 5 => ‘May’, 6 => ‘June’, 7 => ‘July’, 8 => ‘August’, 9 => ‘September’, 10 => ‘October’, 11 => […]

如何查找范围数组中是否包含范围?

例 business_hours[‘monday’] = [800..1200, 1300..1700] business_hours[‘tuesday’] = [900..1100, 1300..1700] … 然后我有一堆事件占据了这些间隔中的一些,例如 event = { start_at: somedatetime, end_at: somedatetime } 迭代从某个日期到某个日期的事件,我创建了另一个数组 busy_hours[‘monday’] = [800..830, 1400..1415] … 现在我的挑战是 创建包含business_hours减去busy_hours的available_hours数组 available_hours = business_hours – busy_hours 如果持续时间为30分钟,请在available_hours中找到可用的时间段。 在上面的例子中,这种方法将返回 available_slots[‘monday’] = [830..900, 845..915, 900..930, and so on] 并非它为指定持续时间的插槽以15分钟为增量检查available_hours。 谢谢您的帮助!