Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error converting due to wrong date type with instanceOf #6

Open
plee61 opened this issue Jul 31, 2023 · 0 comments
Open

Error converting due to wrong date type with instanceOf #6

plee61 opened this issue Jul 31, 2023 · 0 comments

Comments

@plee61
Copy link

plee61 commented Jul 31, 2023

Before checking for instanceof, date needs to be converted to Date object
and need to be checked for valid date just incase date is a null or empty string

function strftime(sFormat, sDate) {
	if (typeof sFormat !== 'string') {
	  return '';
	}
	if (sDate == "") {return sDate;}
	let date = new Date(sDate);
	if (!(date instanceof Date  && !isNaN(date))) {
	  return sDate;
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant