vremel
Version:
JavaScript date utility library for Temporal API
28 lines • 816 B
JavaScript
import { isPlainDate, isZonedDateTime } from "../type-utils.js";
import { endOfTimeForZonedDateTime } from "./_endOfTimeForZonedDateTime.js";
/**
* Returns the end of a month for the given datetime
* @param dt datetime object which includes date info
* @returns Temporal object which represents the end of a month
*/
export function endOfMonth(dt) {
if (isPlainDate(dt)) {
return dt.with({
day: Number.MAX_VALUE,
});
}
const withArg = {
day: Number.MAX_VALUE,
hour: 23,
minute: 59,
second: 59,
millisecond: 999,
microsecond: 999,
nanosecond: 999,
};
if (!isZonedDateTime(dt)) {
return dt.with(withArg);
}
return endOfTimeForZonedDateTime(dt, withArg);
}
//# sourceMappingURL=endOfMonth.js.map