add utils: date conversion
This commit is contained in:
@@ -68,13 +68,20 @@ export function isEmpty(obj) {
|
|||||||
}
|
}
|
||||||
return true;
|
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
|
* @param {any} obj - The object to test
|
||||||
* @returns `true` or `false`
|
* @returns @type {FormattedError[]}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function formatError(obj) {
|
export function formatError(obj) {
|
||||||
|
/** @type {FormattedError[]} */
|
||||||
const errors = [];
|
const errors = [];
|
||||||
if (typeof obj === "object" && obj !== null) {
|
if (typeof obj === "object" && obj !== null) {
|
||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
@@ -103,3 +110,9 @@ export function formatError(obj) {
|
|||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toRFC3339(dateString) {
|
||||||
|
if (!dateString) return "";
|
||||||
|
const date = new Date(dateString);
|
||||||
|
return date.toISOString();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user