fix(bot): correct sleep-aware reminder wording

This commit is contained in:
2026-03-24 04:16:07 +04:00
parent 83ffd7df72
commit 782a8325ba
2 changed files with 14 additions and 10 deletions

View File

@@ -576,4 +576,15 @@ describe('formatReminderWhen', () => {
}) })
).toBe('завтра в 9 утра') ).toBe('завтра в 9 утра')
}) })
test('keeps actual next-day reminders as tomorrow before 5am', () => {
expect(
formatReminderWhen({
locale: 'ru',
scheduledForIso: '2026-03-25T05:00:00Z',
timezone: 'Asia/Tbilisi',
now: Temporal.Instant.from('2026-03-24T00:14:00Z')
})
).toBe('завтра в 9 утра')
})
}) })

View File

@@ -170,18 +170,11 @@ function relativeDayLabel(input: {
const tomorrow = nowDate.add({ days: 1 }) const tomorrow = nowDate.add({ days: 1 })
const dayAfterTomorrow = nowDate.add({ days: 2 }) const dayAfterTomorrow = nowDate.add({ days: 2 })
const sleepAwareCurrentDate = input.now.hour <= 4 ? nowDate.subtract({ days: 1 }) : nowDate if (input.now.hour <= 4 && targetDate.equals(nowDate) && input.target.hour <= 12) {
const sleepAwareTomorrow = sleepAwareCurrentDate.add({ days: 1 })
const sleepAwareDayAfterTomorrow = sleepAwareCurrentDate.add({ days: 2 })
if (targetDate.equals(sleepAwareCurrentDate)) {
return input.locale === 'ru' ? 'сегодня' : 'today'
}
if (targetDate.equals(sleepAwareTomorrow)) {
return input.locale === 'ru' ? 'завтра' : 'tomorrow' return input.locale === 'ru' ? 'завтра' : 'tomorrow'
} }
if (targetDate.equals(sleepAwareDayAfterTomorrow)) { if (targetDate.equals(nowDate)) {
return input.locale === 'ru' ? 'послезавтра' : 'the day after tomorrow' return input.locale === 'ru' ? 'сегодня' : 'today'
} }
if (targetDate.equals(tomorrow)) { if (targetDate.equals(tomorrow)) {
return input.locale === 'ru' ? 'завтра' : 'tomorrow' return input.locale === 'ru' ? 'завтра' : 'tomorrow'