mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
common: fix ts errors
This commit is contained in:
committed by
Abdullah Atta
parent
843be2a62c
commit
9ef40c01ce
@@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
import Database from "@notesnook/core/dist/api/index";
|
||||
|
||||
export const database = new Database();
|
||||
|
||||
@@ -17,24 +17,29 @@ 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 { formatDate } from "@notesnook/core/dist/utils/date";
|
||||
import {
|
||||
FormatDateOptions,
|
||||
TimeFormat,
|
||||
formatDate
|
||||
} from "@notesnook/core/dist/utils/date";
|
||||
import { database } from "../database";
|
||||
import { formatReminderTime } from "@notesnook/core/dist/collections/reminders";
|
||||
import { Reminder } from "@notesnook/core/dist/types";
|
||||
|
||||
export function getFormattedDate(
|
||||
date: string | number | Date,
|
||||
type: "time" | "date-time" | "date" = "date-time"
|
||||
type: FormatDateOptions["type"]
|
||||
) {
|
||||
return formatDate(date, {
|
||||
dateFormat: database.settings?.getDateFormat() as string,
|
||||
timeFormat: database.settings?.getTimeFormat() as string,
|
||||
type: type
|
||||
});
|
||||
} as FormatDateOptions);
|
||||
}
|
||||
|
||||
export function getFormattedReminderTime(reminder: any, short = false) {
|
||||
export function getFormattedReminderTime(reminder: Reminder, short = false) {
|
||||
return formatReminderTime(reminder, short, {
|
||||
dateFormat: database.settings?.getDateFormat() as string,
|
||||
timeFormat: database.settings?.getTimeFormat() as string
|
||||
timeFormat: database.settings?.getTimeFormat() as TimeFormat
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ GNU General Public License for more details.
|
||||
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 { Item } from "@notesnook/core/dist/types";
|
||||
import { database } from "../database";
|
||||
|
||||
export function getTotalNotes(item?: any) {
|
||||
export function getTotalNotes(item?: Item) {
|
||||
if (!item || (item.type !== "notebook" && item.type !== "topic")) return 0;
|
||||
if (item.type === "topic") {
|
||||
return (
|
||||
|
||||
@@ -64,20 +64,20 @@ export function getTimeFormat(format: TimeFormat) {
|
||||
return format === "12-hour" ? "hh:mm A" : "HH:mm";
|
||||
}
|
||||
|
||||
type TimeOptions = {
|
||||
export type TimeOptions = {
|
||||
type: "time";
|
||||
timeFormat: TimeFormat;
|
||||
};
|
||||
type DateOptions = {
|
||||
export type DateOptions = {
|
||||
type: "date";
|
||||
dateFormat: string;
|
||||
};
|
||||
type DateTimeOptions = {
|
||||
export type DateTimeOptions = {
|
||||
type: "date-time";
|
||||
dateFormat: string;
|
||||
timeFormat: TimeFormat;
|
||||
};
|
||||
type FormatDateOptions = TimeOptions | DateOptions | DateTimeOptions;
|
||||
export type FormatDateOptions = TimeOptions | DateOptions | DateTimeOptions;
|
||||
|
||||
export function formatDate(
|
||||
date: string | number | Date | null | undefined,
|
||||
|
||||
Reference in New Issue
Block a user