excalidraw/src/utils.ts
Gasim Gasimzada 86a1c29eec
Extract scene functions to their respective modules (#208)
- Also, extract utilities into utils module -- capitalizeString, getDateTime, isInputLike
2020-01-06 20:24:54 +04:00

26 lines
705 B
TypeScript

export function getDateTime() {
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hr = date.getHours();
const min = date.getMinutes();
const secs = date.getSeconds();
return `${year}${month}${day}${hr}${min}${secs}`;
}
export function capitalizeString(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
export function isInputLike(
target: Element | EventTarget | null
): target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement {
return (
target instanceof HTMLInputElement ||
target instanceof HTMLTextAreaElement ||
target instanceof HTMLSelectElement
);
}