import type { Dayjs } from "dayjs";
import dayjs from "./dayjs";

const TZ = "Europe/Tallinn";

const ISO_8601_DATE = "YYYY-MM-DD";
const ISO_8601_DATE_ZERO_HOURS = `${ISO_8601_DATE}T00:00:00`;
const ISO_8601_DATE_ZERO_MINUTES = `${ISO_8601_DATE}THH:00:00`;

const DateFormat = {
  toDayjs(date?: Date | string, format?: string): Dayjs {
    return dayjs(date, format).tz(TZ);
  },
  toIso8601DateString(date: Date | string, format = ISO_8601_DATE): string {
    return this.toDayjs(date).format(format);
  },
  toIso8601DateWithZeroHours(date: Date): string {
    return this.toDayjs(date).format(ISO_8601_DATE_ZERO_HOURS);
  },
  toIso8601DateWithZeroMinutes(date: Date): string {
    return this.toDayjs(date).format(ISO_8601_DATE_ZERO_MINUTES);
  },
};

export default DateFormat;
