@salesforce/apex-node
Version:
Salesforce JS library for Apex
36 lines • 1.27 kB
JavaScript
;
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MILLISECONDS_PER_MINUTE = void 0;
exports.getCurrentTime = getCurrentTime;
exports.formatStartTime = formatStartTime;
exports.msToSecond = msToSecond;
exports.MILLISECONDS_PER_MINUTE = 60000;
function getCurrentTime() {
return new Date().getTime();
}
/**
* Returns the formatted date and time given the milliseconds in numbers or UTC formatted string
* @param startTime start time in millisecond numbers or UTC format string
* @param format either 'ISO' or 'locale'. Defaults to 'locale' to keep backward compatible.
* @returns formatted date and time
*/
function formatStartTime(startTime, format = 'locale') {
if (!startTime) {
return '';
}
const date = new Date(startTime);
if (format === 'ISO') {
return date.toISOString();
}
return `${date.toDateString()} ${date.toLocaleTimeString()}`;
}
function msToSecond(timestamp) {
return (timestamp / 1000).toFixed(2);
}
//# sourceMappingURL=dateUtil.js.map