This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/lib/bookmark.js
Martin Brennan d7f744490a
FEATURE: Decorate topic-level bookmark button with reminder time (#9426)
* Show the correct bookmark with clock icon when topic-level bookmark reminder time is set and show the time of the reminder in the title on hover.
* Add a new bookmark lib and reminder time formatting function to show time with today/tomorrow shorthand for readability. E.g. tomorrow at 8:00am instead of Apr 16 2020 at 8:00am. This only applies to today + tomorrow, future dates are still treated the same.
2020-04-16 09:20:44 +10:00

32 lines
1.0 KiB
JavaScript

export function formattedReminderTime(reminderAt, timezone) {
let reminderAtDate = moment.tz(reminderAt, timezone);
let formatted = reminderAtDate.format(I18n.t("dates.time"));
let now = moment.tz(timezone);
let tomorrow = moment(now).add(1, "day");
if (reminderAtDate.isSame(tomorrow, "date")) {
return I18n.t("bookmarks.reminders.tomorrow_with_time", {
time: formatted
});
} else if (reminderAtDate.isSame(now, "date")) {
return I18n.t("bookmarks.reminders.today_with_time", { time: formatted });
}
return I18n.t("bookmarks.reminders.at_time", {
date_time: reminderAtDate.format(I18n.t("dates.long_with_year"))
});
}
export const REMINDER_TYPES = {
AT_DESKTOP: "at_desktop",
LATER_TODAY: "later_today",
NEXT_BUSINESS_DAY: "next_business_day",
TOMORROW: "tomorrow",
NEXT_WEEK: "next_week",
NEXT_MONTH: "next_month",
CUSTOM: "custom",
LAST_CUSTOM: "last_custom",
NONE: "none",
START_OF_NEXT_BUSINESS_WEEK: "start_of_next_business_week",
LATER_THIS_WEEK: "later_this_week"
};