mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Minor refactor to use hasNoValue()
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user