vremel
Version:
JavaScript date utility library for Temporal API
26 lines • 770 B
JavaScript
import { isPlainDate, isZonedDateTime } from "../type-utils.js";
import { startOfTimeForZonedDateTime } from "./_startOfTimeForZonedDateTime.js";
/**
* Returns the start of a month for the given datetime
* @param dt datetime object which includes date info
* @returns Temporal object which represents the start of a month
*/
export function startOfMonth(dt) {
if (isPlainDate(dt)) {
return dt.with({ day: 1 });
}
const withArg = {
day: 1,
hour: 0,
minute: 0,
second: 0,
millisecond: 0,
microsecond: 0,
nanosecond: 0,
};
if (!isZonedDateTime(dt)) {
return dt.with(withArg);
}
return startOfTimeForZonedDateTime(dt, withArg);
}
//# sourceMappingURL=startOfMonth.js.map