I am writing a date adapter for Angular Material, and need a function that returns a boolean if the provided object is a luxon DateTime.
Something like this (from moment):
isDateInstance(obj: any): boolean {
return moment.isMoment(obj);
}
What I have is this so far - is this good enough?:
isDateInstance(obj: any): boolean {
try {
const luxonObject = DateTime.fromObject(obj);
return luxonObject.isValid;
} catch (error) {
return false;
}
}