add isToday function

This commit is contained in:
Dan Percic 2023-02-10 19:07:05 +02:00
parent b8c3b76e56
commit 9891c2bf67
2 changed files with 7 additions and 4 deletions

View File

@ -16,5 +16,4 @@ const components = [ChevronButtonComponent, CircleButtonComponent, IconButtonCom
imports: [CommonModule, IqserIconsModule, TranslateModule, ...matModules],
exports: [...components],
})
export class IqserButtonsModule {
}
export class IqserButtonsModule {}

View File

@ -1,7 +1,7 @@
import { Id, ITrackable } from '../listing';
import type { Id, ITrackable } from '../listing';
import { UntypedFormGroup } from '@angular/forms';
import { forOwn, has, isEqual, isPlainObject, transform } from 'lodash-es';
import dayjs, { Dayjs } from 'dayjs';
import dayjs, { type Dayjs } from 'dayjs';
import { inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@ -81,6 +81,10 @@ export function isJustOne<T>(list: T[]): list is [T] {
return list.length === 1;
}
export function isToday(date: string | Date | Dayjs) {
return dayjs(date).isSame(new Date(), 'day');
}
export function trackByFactory<T extends ITrackable<PrimaryKey>, PrimaryKey extends Id = T['id']>() {
return (_index: number, item: T): Id => item.id;
}