Created
October 23, 2012 11:26
-
-
Save pupca/3938273 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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