add utils: date conversion
This commit is contained in:
@@ -68,13 +68,20 @@ export function isEmpty(obj) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether or not an object is empty.
|
||||
* @typedef {Object} FormattedError
|
||||
* @property {string} error - The error message
|
||||
* @property {number} id - A unique identifier for the error
|
||||
*/
|
||||
/**
|
||||
* Format Error object(s)
|
||||
* @param {any} obj - The object to test
|
||||
* @returns `true` or `false`
|
||||
* @returns @type {FormattedError[]}
|
||||
*/
|
||||
|
||||
export function formatError(obj) {
|
||||
/** @type {FormattedError[]} */
|
||||
const errors = [];
|
||||
if (typeof obj === "object" && obj !== null) {
|
||||
if (Array.isArray(obj)) {
|
||||
@@ -103,3 +110,9 @@ export function formatError(obj) {
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
export function toRFC3339(dateString) {
|
||||
if (!dateString) return "";
|
||||
const date = new Date(dateString);
|
||||
return date.toISOString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user