@ankimcp/anki-mcp-server
Version:
Model Context Protocol server for Anki - enables AI assistants to interact with your Anki flashcards
25 lines • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toLocalDayKey = toLocalDayKey;
exports.localDayStartMs = localDayStartMs;
exports.addDaysToDayKey = addDaysToDayKey;
const MS_PER_HOUR = 3_600_000;
const MS_PER_DAY = 86_400_000;
function toLocalDayKey(timestampMs, rolloverHour = 0) {
const local = new Date(timestampMs - rolloverHour * MS_PER_HOUR);
const year = local.getFullYear();
const month = String(local.getMonth() + 1).padStart(2, "0");
const day = String(local.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
}
function localDayStartMs(dayKey, rolloverHour = 0) {
const [year, month, day] = dayKey.split("-").map(Number);
return (new Date(year, month - 1, day, 0, 0, 0, 0).getTime() +
rolloverHour * MS_PER_HOUR);
}
function addDaysToDayKey(dayKey, days) {
const [year, month, day] = dayKey.split("-").map(Number);
const shifted = Date.UTC(year, month - 1, day) + days * MS_PER_DAY;
return new Date(shifted).toISOString().slice(0, 10);
}
//# sourceMappingURL=date.utils.js.map