UNPKG

react-native-kochava-measurement

Version:

A lightweight and easy to integrate SDK, providing first-class integration with Kochava’s installation attribution and analytics platform.

25 lines (24 loc) 1.09 kB
/* Authored by Brett Barinaga on 11/17/21. Copyright (c) Kochava, Inc. All rights reserved. */ import crypto from "../adapters/crypto.rn.js"; export var uuidv4 = function () { return ("".concat(1e7, "-").concat(1e3, "-").concat(4e3, "-").concat(8e3, "-").concat(1e11)).replace(/[018]/g, function (c) { return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16); }); }; // returns the number of milliseconds elapsed since January 1, 1970 export var getCurrTimeMS = function () { return Math.floor(Date.now()); }; // returns the number of seconds elapsed since January 1, 1970 export var getCurrTimeSec = function () { return Math.floor(Date.now() / 1000); }; export var formatTime = function (num) { if (num < 10 && num % 10 <= 9) return "0" + num.toFixed(1).toString(); else return num.toFixed(1).toString(); }; export var getMsTime = function () { var date = new Date(); return "".concat(date.getHours(), ":").concat(date.getMinutes(), ":").concat(date.getSeconds(), ":").concat(date.getMilliseconds()); };