Skip to content

Instantly share code, notes, and snippets.

@pupca
Created October 23, 2012 11:26
Show Gist options
  • Save pupca/3938273 to your computer and use it in GitHub Desktop.
Save pupca/3938273 to your computer and use it in GitHub Desktop.
def generate_expire_at(time = Time.now)
#patek od 5 az nedele pulnoc
if time.wday == 0 || time.wday == 6 || (time.wday == 5 && time.hour > 15)
return Chronic.parse('this monday 10:00AM').strftime("%Y-%m-%dT%H:%M")
end
# po 4te hodine
if time.hour > 15
return Chronic.parse('tommorow 10:00AM').strftime("%Y-%m-%dT%H:%M")
end
# pred 8mou
if time.hour < 8
return Chronic.parse('today 10:00AM').strftime("%Y-%m-%dT%H:%M")
end
# jinak vzdy za dve hodiny
return (time + 2.hours).strftime("%Y-%m-%dT%H:%M")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment