added iso/timestamp/local conversion
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { format } from "date-fns";
|
||||
|
||||
const transitionEndEventName = () => {
|
||||
var i,
|
||||
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 {
|
||||
transitionEndEventName,
|
||||
waitForElementRender,
|
||||
|
||||
Reference in New Issue
Block a user