You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timeConversion.js 980B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isoTimeToRippleTime = exports.rippleTimeToISOTime = exports.unixTimeToRippleTime = exports.rippleTimeToUnixTime = void 0;
  4. const RIPPLE_EPOCH_DIFF = 0x386d4380;
  5. function rippleTimeToUnixTime(rpepoch) {
  6. return (rpepoch + RIPPLE_EPOCH_DIFF) * 1000;
  7. }
  8. exports.rippleTimeToUnixTime = rippleTimeToUnixTime;
  9. function unixTimeToRippleTime(timestamp) {
  10. return Math.round(timestamp / 1000) - RIPPLE_EPOCH_DIFF;
  11. }
  12. exports.unixTimeToRippleTime = unixTimeToRippleTime;
  13. function rippleTimeToISOTime(rippleTime) {
  14. return new Date(rippleTimeToUnixTime(rippleTime)).toISOString();
  15. }
  16. exports.rippleTimeToISOTime = rippleTimeToISOTime;
  17. function isoTimeToRippleTime(iso8601) {
  18. const isoDate = typeof iso8601 === 'string' ? new Date(iso8601) : iso8601;
  19. return unixTimeToRippleTime(isoDate.getTime());
  20. }
  21. exports.isoTimeToRippleTime = isoTimeToRippleTime;
  22. //# sourceMappingURL=timeConversion.js.map