mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 10:24:02 +00:00
fix(bot): correct sleep-aware reminder wording
This commit is contained in:
@@ -576,4 +576,15 @@ describe('formatReminderWhen', () => {
|
||||
})
|
||||
).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 утра')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -170,18 +170,11 @@ function relativeDayLabel(input: {
|
||||
const tomorrow = nowDate.add({ days: 1 })
|
||||
const dayAfterTomorrow = nowDate.add({ days: 2 })
|
||||
|
||||
const sleepAwareCurrentDate = input.now.hour <= 4 ? nowDate.subtract({ days: 1 }) : nowDate
|
||||
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)) {
|
||||
if (input.now.hour <= 4 && targetDate.equals(nowDate) && input.target.hour <= 12) {
|
||||
return input.locale === 'ru' ? 'завтра' : 'tomorrow'
|
||||
}
|
||||
if (targetDate.equals(sleepAwareDayAfterTomorrow)) {
|
||||
return input.locale === 'ru' ? 'послезавтра' : 'the day after tomorrow'
|
||||
if (targetDate.equals(nowDate)) {
|
||||
return input.locale === 'ru' ? 'сегодня' : 'today'
|
||||
}
|
||||
if (targetDate.equals(tomorrow)) {
|
||||
return input.locale === 'ru' ? 'завтра' : 'tomorrow'
|
||||
|
||||
Reference in New Issue
Block a user