All files / src/utils date.ts

66.66% Statements 6/9
100% Branches 0/0
66.66% Functions 2/3
66.66% Lines 6/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24              3x 3x 3x                   3x 3x 3x    
// import pino from "pino"
import { Temporal } from "@js-temporal/polyfill"
 
import { env } from "../config"
 
// const logger = pino()
export function getStartOfCurrentMonth(): string {
  const now = Temporal.Now.zonedDateTimeISO(env.timezone)
  const start = now.with({ day: 1 }).startOfDay()
  return start.toPlainDate().toString()
}
 
export function getTodayDate(): string {
  const now = Temporal.Now.zonedDateTimeISO(env.timezone)
  const today = now.startOfDay()
  return today.toPlainDate().toString()
}
 
export function getEndOfCurrentMonth(): string {
  const now = Temporal.Now.zonedDateTimeISO(env.timezone)
  const end = now.with({ day: now.daysInMonth }).with({ hour: 23, minute: 59, second: 59, millisecond: 999 })
  return end.toPlainDate().toString()
}