Created
June 10, 2019 17:18
-
-
Save roramirez/50c4d0c301efcf321d6ce06c09b5dcf9 to your computer and use it in GitHub Desktop.
This file contains 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 in_range_time_from_db(from, to, value=Time.now) | |
# The `time` types are storage in the database in format HH:MM:SS. | |
# `ActiveRecord` returns into theTime type '2000-01-01 HH:MM:SS' | |
# This function return these times [`from`, `to`] to present date | |
# and checks if the `value` is in this range period | |
from = from.to_time.strftime("%T") | |
to = to.to_time.strftime("%T") | |
from = Time.parse(from) | |
to = Time.parse(to) | |
(from..to).include?(value) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment