mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-07-21 03:01:51 +00:00
Minor refactorings and function extractions
This commit is contained in:
@@ -32,6 +32,8 @@ export const parseDate = (date: string, theFormat: string) => parse(date, theFor
|
||||
|
||||
export const parseISO = (date: DateOrString): Date => (isDateObject(date) ? date : stdParseISO(date));
|
||||
|
||||
export const dateOrNull = (date?: string): Date | null => (date ? parseISO(date) : null);
|
||||
|
||||
export const isBetween = (date: DateOrString, start?: DateOrString, end?: DateOrString): boolean => {
|
||||
try {
|
||||
return isWithinInterval(parseISO(date), { start: parseISO(start ?? date), end: parseISO(end ?? date) });
|
||||
|
||||
@@ -36,6 +36,6 @@ export const orderToString = <T>(order: Order<T>): string | undefined => (
|
||||
);
|
||||
|
||||
export const stringToOrder = <T>(order: string): Order<T> => {
|
||||
const [field, dir] = order.split('-') as [ T | undefined, OrderDir | undefined ];
|
||||
const [field, dir] = order.split('-') as [T | undefined, OrderDir | undefined];
|
||||
return { field, dir };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user