added iso/timestamp/local conversion
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { format } from "date-fns";
|
||||||
|
|
||||||
const transitionEndEventName = () => {
|
const transitionEndEventName = () => {
|
||||||
var i,
|
var i,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -345,6 +347,38 @@ export const isUUID = (uuid) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const timestampUtcToLocal = (utc) => {
|
||||||
|
try {
|
||||||
|
let iso = new Date(
|
||||||
|
utc.replace(
|
||||||
|
/([0-9]{4}-[0-9]{2}-[0-9]{2}),? ([0-9]{2}:[0-9]{2}:[0-9]{2})/,
|
||||||
|
"$1T$2.000Z"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return format(iso, "yyyy/MM/dd hh:mm:ss");
|
||||||
|
} catch (error) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const timestampLocalToUtc = (local) => {
|
||||||
|
try {
|
||||||
|
let d = new Date(local);
|
||||||
|
return d
|
||||||
|
.toISOString()
|
||||||
|
.replace(
|
||||||
|
/([0-9]{4}-[0-9]{2}-[0-9]{2})T([0-9]{2}:[0-9]{2}:[0-9]{2}).*/,
|
||||||
|
"$1 $2"
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
transitionEndEventName,
|
transitionEndEventName,
|
||||||
waitForElementRender,
|
waitForElementRender,
|
||||||
|
|||||||
Reference in New Issue
Block a user