Removed dateToW3Cstring function

This commit is contained in:
Alexander Cerutti
2023-08-09 19:48:09 +02:00
parent 00d9494c5a
commit f81cae181b

View File

@@ -2,40 +2,16 @@ import * as Messages from "./messages";
import type Bundle from "./Bundle";
/**
* Acts as a wrapper for converting date to W3C string
* Converts a date to W3C / UTC string
* @param date
* @returns
*/
export function processDate(date: Date): string | undefined {
if (!(date instanceof Date)) {
if (!(date instanceof Date) || Number.isNaN(Number(date))) {
throw "Invalid date";
}
const dateParse = dateToW3CString(date);
if (!dateParse) {
throw "Invalid date";
}
return dateParse;
}
/**
* Converts a date to W3C Standard format
*
* @function dateToW3Cstring
* @params date - The date to be parsed
* @returns - The parsed string if the parameter is valid,
* undefined otherwise
*/
function dateToW3CString(date: Date) {
// if it is NaN, it is "Invalid Date"
if (isNaN(Number(date))) {
return undefined;
}
/**
* @see https://www.w3.org/TR/NOTE-datetime
*/