Minor refactor to use hasNoValue()

This commit is contained in:
Tim Donohue
2022-10-27 15:12:53 -05:00
parent 81814bf31c
commit 0d2be94cbd

View File

@@ -2,7 +2,7 @@ import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import { formatInTimeZone } from 'date-fns-tz'; import { formatInTimeZone } from 'date-fns-tz';
import { isValid } from 'date-fns'; import { isValid } from 'date-fns';
import isObject from 'lodash/isObject'; import isObject from 'lodash/isObject';
import { isNull, isUndefined } from './empty.util'; import { hasNoValue } from './empty.util';
/** /**
* Returns true if the passed value is a NgbDateStruct. * Returns true if the passed value is a NgbDateStruct.
@@ -66,7 +66,7 @@ export function stringToNgbDateStruct(date: string): NgbDateStruct {
* the NgbDateStruct object * the NgbDateStruct object
*/ */
export function dateToNgbDateStruct(date?: Date): NgbDateStruct { export function dateToNgbDateStruct(date?: Date): NgbDateStruct {
if (isNull(date) || isUndefined(date)) { if (hasNoValue(date)) {
date = new Date(); date = new Date();
} }
@@ -95,7 +95,7 @@ export function dateToString(date: Date | NgbDateStruct): string {
* @param date the string to be checked * @param date the string to be checked
*/ */
export function isValidDate(date: string) { export function isValidDate(date: string) {
return (isNull(date) || isUndefined(date)) ? false : isValid(new Date(date)); return (hasNoValue(date)) ? false : isValid(new Date(date));
} }
/** /**