Skip to content

Instantly share code, notes, and snippets.

@benbabics
Last active August 29, 2015 13:55
Show Gist options
  • Save benbabics/8702822 to your computer and use it in GitHub Desktop.
Save benbabics/8702822 to your computer and use it in GitHub Desktop.
selected_tags = @collection.filter (model) ->
# get data
is_client = model.get 'int_is_client'
last_posted = model.get 'dtm_last_posted'
# get morning time
morning = new Date()
morning.setHours 0
morning.setMinutes 0
morning.setSeconds 0
morning = morning.getTime()
# get midnight time
midnight = new Date()
midnight.setHours 24
midnight.setMinutes 0
midnight.setSeconds 0
midnight = midnight.getTime()
# get posted_time's time
posted_time = new Date( last_posted ).getTime()
# is this a selected tag?
is_client = is_client is 1 or is_client is true
# has this tag already been sent a message?
is_unsent = last_posted is undefined or last_posted is null
# is the posted_time on the tag less than midnight tonight?
is_unsent = morning <= posted_time <= midnight unless is_unsent
# return if this is a selected tag from today
is_client && is_unsent
@benbabics
Copy link
Author

This now accounts for morning too. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment