mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 23:25:26 +00:00
18 lines
388 B
TypeScript
18 lines
388 B
TypeScript
import { dateToW3CString } from "./utils";
|
|
import formatMessage, { ERROR, DEBUG } from "./messages";
|
|
|
|
export function processDate(key: string, date: Date): string | null {
|
|
if (!(date instanceof Date)) {
|
|
return null;
|
|
}
|
|
|
|
const dateParse = dateToW3CString(date);
|
|
|
|
if (!dateParse) {
|
|
console.warn(formatMessage(DEBUG.DATE_FORMAT_UNMATCH, key));
|
|
return null;
|
|
}
|
|
|
|
return dateParse;
|
|
}
|