feat(vocab): add SRS schedule date formatting and update close button text

This commit is contained in:
Torsten Schulz (local)
2026-08-26 09:53:30 +02:00
parent a481a440c8
commit bac915c328
2 changed files with 21 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ import { Op } from 'sequelize';
import { BISAYA_PHASE1_DIDACTICS, BISAYA_DIDACTICS_FRAGMENTS } from '../scripts/bisaya-course-phase1.js';
const DAILY_SRS_LIMIT = 50;
const SRS_SCHEDULE_TIME_ZONE = 'Europe/Berlin';
export default class VocabService {
_stripGermanNumberSeparators(value) {
@@ -317,6 +318,21 @@ export default class VocabService {
return date.toISOString();
}
_getSrsScheduleDateKey(value) {
const date = value instanceof Date ? value : new Date(value);
if (Number.isNaN(date.getTime())) {
return '';
}
const parts = new Intl.DateTimeFormat('en-US', {
timeZone: SRS_SCHEDULE_TIME_ZONE,
year: 'numeric',
month: '2-digit',
day: '2-digit'
}).formatToParts(date);
const byType = new Map(parts.map((part) => [part.type, part.value]));
return `${byType.get('year')}-${byType.get('month')}-${byType.get('day')}`;
}
_clampInteger(value, { min = 0, max = 100000, fallback = 0 } = {}) {
const numeric = Number(value);
if (!Number.isFinite(numeric)) {
@@ -2043,8 +2059,10 @@ export default class VocabService {
&& new Date(item.nextDueAt).getTime() > now.getTime()
))
.forEach((item) => {
const date = new Date(item.nextDueAt).toISOString().slice(0, 10);
upcomingByDate.set(date, (upcomingByDate.get(date) || 0) + 1);
const date = this._getSrsScheduleDateKey(item.nextDueAt);
if (date) {
upcomingByDate.set(date, (upcomingByDate.get(date) || 0) + 1);
}
});
const rows = validDueRows.slice(0, limit);
const totalDueCount = validDueRows.length;