// WCS 任务与库位排查常按秒定位新增/流转记录，前端展示和查询统一保留秒级精度。
export const CREATED_TIME_DISPLAY_FORMAT = '{y}-{m}-{d} {h}:{i}:{s}';
export const CREATED_TIME_PICKER_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const CREATED_TIME_VALUE_FORMAT = 'YYYY-MM-DD HH:mm:ss';

const formatDateTime = (date: Date) => {
  const pad = (value: number) => `${value}`.padStart(2, '0');
  return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
};

export const getTodayCreatedTimeRange = (): [string, string] => {
  const now = new Date();
  const startTime = new Date(now);
  const endTime = new Date(now);
  startTime.setHours(0, 0, 0, 0);
  endTime.setHours(23, 59, 59, 999);
  // 默认筛今天完整区间，避免页面打开后新增的数据因为超过旧结束时间而查不到。
  return [formatDateTime(startTime), formatDateTime(endTime)];
};
