var B = require('sanctuary').B

exports.today = env =>
  env === 'heroku-test' ? "'2017-08-15'" : "curdate()"

exports.due_dates = start => end => compare => {
  var wrap =
    month_and_day(start) < month_and_day(end) ? x => x : x => `not(${x})`

  return wrap(`${set_2000(compare)}
    between ${set_2000(`'${new Date(start).toISOString()}'`)}
    and ${set_2000(`'${new Date(end).toISOString()}'`)}`)
}

var set_year = year => date => `date_format(${date}, '${year}-%m-%d')`

var set_2000 = set_year('2000')

var current_year = env =>
  process.env.NODE_ENV === 'heroku-test'
  ? '2017'
  : JSON.stringify((new Date).getFullYear())

exports.set_current = B(set_year, current_year)

var month_and_day = date_string => date_string.split('-').slice(1).join()


var B = require('sanctuary').B

exports.today = env =>
  env === 'heroku-test' ? "'2017-08-15'" : "curdate()"

exports.due_dates = start => end => compare => {
  var wrap =
    month_and_day(start) < month_and_day(end) ? x => x : x => `not(${x})`

  return wrap(`${set_2000(compare)}
    between ${set_2000(`'${start}'`)}
    and ${set_2000(`'${end}'`)}`)
}

var set_year = year => date => `date_format(${date}, '${year}-%m-%d')`

var set_2000 = set_year('2000')

var current_year = env =>
  env === 'heroku-test'
  ? '2017'
  : JSON.stringify((new Date()).getFullYear())

exports.set_current = B(set_year, current_year)

var month_and_day = date_string => date_string.split('-').slice(1).join()

Fix subscription due query.