| 789 | }, |
| 790 | |
| 791 | buildRelativeTimeText (event, eventStartDateMoment, eventEndDateMoment, now) { |
| 792 | if (eventStartDateMoment.isSameOrAfter(now) || (event.fullDayEvent && eventEndDateMoment.diff(now, "days") === 0)) { |
| 793 | let timeText; |
| 794 | |
| 795 | if (!this.config.hideTime && !event.fullDayEvent) { |
| 796 | Log.debug("[calendar] event not hidden and not fullday"); |
| 797 | timeText = `${CalendarUtils.capFirst(eventStartDateMoment.calendar(null, { sameElse: this.config.dateFormat }))}`; |
| 798 | } else { |
| 799 | Log.debug("[calendar] event full day or hidden"); |
| 800 | timeText = `${CalendarUtils.capFirst( |
| 801 | eventStartDateMoment.calendar(null, { |
| 802 | sameDay: this.config.showTimeToday ? "LT" : `[${this.translate("TODAY")}]`, |
| 803 | nextDay: `[${this.translate("TOMORROW")}]`, |
| 804 | nextWeek: "dddd", |
| 805 | sameElse: event.fullDayEvent ? this.config.fullDayEventDateFormat : this.config.dateFormat |
| 806 | }) |
| 807 | )}`; |
| 808 | } |
| 809 | |
| 810 | if (event.fullDayEvent) { |
| 811 | if (event.today || (event.fullDayEvent && eventEndDateMoment.diff(now, "days") === 0)) { |
| 812 | timeText = CalendarUtils.capFirst(this.translate("TODAY")); |
| 813 | } else if (event.dayBeforeYesterday) { |
| 814 | if (this.translate("DAYBEFOREYESTERDAY") !== "DAYBEFOREYESTERDAY") { |
| 815 | timeText = CalendarUtils.capFirst(this.translate("DAYBEFOREYESTERDAY")); |
| 816 | } |
| 817 | } else if (event.yesterday) { |
| 818 | timeText = CalendarUtils.capFirst(this.translate("YESTERDAY")); |
| 819 | } else if (event.tomorrow) { |
| 820 | timeText = CalendarUtils.capFirst(this.translate("TOMORROW")); |
| 821 | } else if (event.dayAfterTomorrow) { |
| 822 | if (this.translate("DAYAFTERTOMORROW") !== "DAYAFTERTOMORROW") { |
| 823 | timeText = CalendarUtils.capFirst(this.translate("DAYAFTERTOMORROW")); |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | if (this.config.showEnd && !this.config.showEndsOnlyWithDuration) { |
| 828 | const adjustedEndMoment = this.getAdjustedFullDayEndMoment(eventEndDateMoment); |
| 829 | if (!eventStartDateMoment.isSame(adjustedEndMoment, "d")) { |
| 830 | timeText += `-${CalendarUtils.capFirst(adjustedEndMoment.format(this.config.fullDayEventDateFormat))}`; |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | Log.info("[calendar] event fullday"); |
| 835 | } else if (eventStartDateMoment.diff(now, "h") < this.config.getRelative) { |
| 836 | Log.info("[calendar] not full day but within getRelative size"); |
| 837 | timeText = `${CalendarUtils.capFirst(eventStartDateMoment.fromNow())}`; |
| 838 | } else if (this.shouldShowRelativeTimedEnd(event)) { |
| 839 | if (this.isSameDay(eventStartDateMoment, eventEndDateMoment)) { |
| 840 | const sameElseFormat = this.dateFormatIncludesTime() ? this.config.dateFormat : `${this.config.dateFormat}, LT`; |
| 841 | timeText = CalendarUtils.capFirst( |
| 842 | eventStartDateMoment.calendar(null, { sameElse: sameElseFormat }) |
| 843 | ); |
| 844 | } |
| 845 | timeText += `-${this.formatTimedEventEnd(eventStartDateMoment, eventEndDateMoment)}`; |
| 846 | } |
| 847 | |
| 848 | return timeText; |