File size: 472 Bytes
cf86710
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import { toGregorianDate, toHebrewDate } from "../utils/dateConversion.js";
import { monthIndexToHebrewDate, monthsSinceEpoch } from "../utils/serial.js";

export function setMonth(date: Date, month: number): Date {
  const hebrew = toHebrewDate(date);
  const baseIndex = monthsSinceEpoch({ year: hebrew.year, monthIndex: 0 });
  const targetIndex = baseIndex + month;
  const target = monthIndexToHebrewDate(targetIndex, hebrew.day);
  return toGregorianDate(target);
}