import isUdf from './isUdf';
import getDayStartTime from './getDayStartTime';
import { DAY_TIME_1 } from './consts';

/**
 * 获取一天的结束时间，23点59分59秒时间戳
 * @param {Date|number|string} time
 * @returns {number}
 *
 * getDayEndTime('2021-10-01'); // => 1633103999999
 */
function getDayEndTime(time) {
  if (isUdf(time)) time = new Date();
  var startTime = getDayStartTime(time);
  if (!startTime) return NaN;
  return startTime + DAY_TIME_1;
}

export default getDayEndTime;
