Skip to content

Instantly share code, notes, and snippets.

@joshuaadickerson
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save joshuaadickerson/9202010 to your computer and use it in GitHub Desktop.

Select an option

Save joshuaadickerson/9202010 to your computer and use it in GitHub Desktop.
Date and Time Query
// This checks for US President's elections
// With a hypothetical reporting of election results every other hour between 8 AM and 8 PM
{'check': {
'value': 'now',
'date': [
{'year': {$gt: 1775}},
{'year': 'leapyear'},
{'month': 'november'},
{'dayofweek': 'tuesday'},
{'count': [
{'month': {'dayofweek': 'tuesday'}},
1
]},
{count': [
{'month': {'dayofweek': 'monday'}},
1
]},
],
'time': [
{
'hour': {
'$between': [8, 20]
}
},
{
'hour': {'step': 2}
}
]
}}
{iterator: {
'by': 'date',
'format': 'Y/m/d',
'when': {
'date': [
{'$dayofweek': 'tuesday'},
{
'$year': {
'between': [2012, 2014]
}
},
{
'$or': [
{'$year': 2012},
{'$year': 2013},
{'$year': 2014}
]
}
]
}
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment