// The app's user base is in Germany. Entry dates are stored as the user's
// calendar date pinned to UTC midnight, so "today" must be resolved in this
// timezone — the server's UTC date lags behind German local time between
// 00:00 and 02:00, which would hide entries logged just after midnight.
export const APP_TIMEZONE = "Europe/Berlin";

// End of the current APP_TIMEZONE calendar day, expressed in UTC date-space
// (where the stored UTC-midnight dates live). Used as the upper bound of
// graph/history date ranges.
export function endOfCurrentDayUtc(): Date {
  const [y, m, d] = new Date()
    .toLocaleDateString("en-CA", { timeZone: APP_TIMEZONE })
    .split("-")
    .map(Number);
  return new Date(Date.UTC(y, m - 1, d, 23, 59, 59, 999));
}
