core: fix incorrect snooze time format

This commit is contained in:
ammarahm-ed
2023-06-16 10:21:58 +05:00
parent 5041e47902
commit d0899c563e
2 changed files with 12 additions and 7 deletions

View File

@@ -17,14 +17,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { getId } from "../utils/id";
import Collection from "./collection";
import dayjs from "dayjs";
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
import isToday from "dayjs/plugin/isToday";
import isTomorrow from "dayjs/plugin/isTomorrow";
import isYesterday from "dayjs/plugin/isYesterday";
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
import { formatDate } from "../utils/date";
import { getId } from "../utils/id";
import Collection from "./collection";
dayjs.extend(isTomorrow);
dayjs.extend(isSameOrBefore);
@@ -141,9 +141,10 @@ export function formatReminderTime(
if (reminder.mode === "permanent") return `Ongoing`;
if (reminder.snoozeUntil && reminder.snoozeUntil > Date.now()) {
return `Snoozed until ${dayjs(reminder.snoozeUntil).format(
options.timeFormat
)}`;
return `Snoozed until ${formatDate(reminder.snoozeUntil, {
timeFormat: options.timeFormat,
type: "time"
})}`;
}
if (reminder.mode === "repeat") {

View File

@@ -63,6 +63,10 @@ function getWeek(date) {
return { start, end };
}
export function getTimeFormat(format) {
return format === "12-hour" ? "hh:mm A" : "HH:mm";
}
/**
*
* @param {string | number | Date | null | undefined} date
@@ -77,7 +81,7 @@ export function formatDate(
type: "date-time"
}
) {
const timeFormat = options.timeFormat === "12-hour" ? "hh:mm A" : "HH:mm";
const timeFormat = getTimeFormat(options.timeFormat);
switch (options.type) {
case "date-time":
return dayjs(date).format(`${options.dateFormat} ${timeFormat}`);