Fix data format bug.

This commit is contained in:
BoHung Chiu 2022-08-29 17:51:31 +08:00
parent 56dad2a1b4
commit 14881759b7
2 changed files with 3 additions and 3 deletions

View File

@ -58,7 +58,7 @@ module Admin::PropertyHiresHelper
stime = [stime,recurring_end_date].max stime = [stime,recurring_end_date].max
end end
can_hire_date = stime - (property.can_hire_before_months).month can_hire_date = stime - (property.can_hire_before_months).month
msg += ("<br>" + I18n.t("property_hire.please_hire_after_date",{:date=>"{#{can_hire_date.utc.to_json.gsub('"','')}}"})) msg += ("<br>" + I18n.t("property_hire.please_hire_after_date",{:date=>"{#{can_hire_date.new_offset(0).to_json.gsub('"','')}}"}))
elsif available_flag == 3 ## need hire before elsif available_flag == 3 ## need hire before
default_msg = "This property must be reserved #{property.need_hire_before} #{property.need_hire_before_unit}s in advance." default_msg = "This property must be reserved #{property.need_hire_before} #{property.need_hire_before_unit}s in advance."
msg += I18n.t("property_hire.unavailable_hint3",{:month=>property.need_hire_before,:unit=>I18n.t("property_hire._#{property.need_hire_before_unit}",:default=>property.need_hire_before_unit),:default=>default_msg}) msg += I18n.t("property_hire.unavailable_hint3",{:month=>property.need_hire_before,:unit=>I18n.t("property_hire._#{property.need_hire_before_unit}",:default=>property.need_hire_before_unit),:default=>default_msg})

View File

@ -119,7 +119,7 @@ class PHire
if date_only if date_only
@recurring_events = @recurring_events.where(:date.ne=>nil) @recurring_events = @recurring_events.where(:date.ne=>nil)
end end
start_date_utc_mjd = start_date.to_datetime.utc.mjd start_date_utc_mjd = start_date.to_datetime.new_offset(0).mjd
@recurring_events.each do |re| @recurring_events.each do |re|
datet = re.date datet = re.date
interval = 1.send(re.recurring_interval) rescue 0 interval = 1.send(re.recurring_interval) rescue 0
@ -134,7 +134,7 @@ class PHire
period_str = nil period_str = nil
if re.recurring_interval == "week" if re.recurring_interval == "week"
period_str = 'week' period_str = 'week'
add_interval = (start_date_utc_mjd - @start_date.utc.mjd) add_interval = (start_date_utc_mjd - @start_date.new_offset(0).mjd)
days = 7.day days = 7.day
if add_interval < 0 if add_interval < 0
add_interval = -(-add_interval / days) add_interval = -(-add_interval / days)