mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 12:04:02 +00:00
fix(bot): correct sleep-aware reminder wording
This commit is contained in:
@@ -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 утра')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
Reference in New Issue
Block a user