'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var isUdf = _interopDefault(require('./isUdf'));
var formatToDate = _interopDefault(require('./formatToDate'));

/**
 * 获取一天的开始时间，00点00分00秒时间戳
 * @param {Date|number|string} time
 * @returns {number}
 *
 * getDayStartTime('2021-10-01'); // => 1633017600000
 */
function getDayStartTime(time) {
  if (isUdf(time)) time = new Date();
  var date = formatToDate(time);
  if (!date) return NaN;
  return date.setHours(0, 0, 0, 0);
}

module.exports = getDayStartTime;
