budibase/packages/common/node_modules/date-fns/is_yesterday/index.js

25 lines
652 B
JavaScript
Raw Normal View History

2020-04-07 16:12:08 +02:00
var startOfDay = require('../start_of_day/index.js')
/**
* @category Day Helpers
* @summary Is the given date yesterday?
*
* @description
* Is the given date yesterday?
*
* @param {Date|String|Number} date - the date to check
* @returns {Boolean} the date is yesterday
*
* @example
* // If today is 6 October 2014, is 5 October 14:00:00 yesterday?
* var result = isYesterday(new Date(2014, 9, 5, 14, 0))
* //=> true
*/
function isYesterday (dirtyDate) {
var yesterday = new Date()
yesterday.setDate(yesterday.getDate() - 1)
return startOfDay(dirtyDate).getTime() === startOfDay(yesterday).getTime()
}
module.exports = isYesterday