index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = getUnixTime;
  6. var _index = _interopRequireDefault(require("../getTime/index.js"));
  7. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @name getUnixTime
  11. * @category Timestamp Helpers
  12. * @summary Get the seconds timestamp of the given date.
  13. *
  14. * @description
  15. * Get the seconds timestamp of the given date.
  16. *
  17. * ### v2.0.0 breaking changes:
  18. *
  19. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  20. *
  21. * @param {Date|Number} date - the given date
  22. * @returns {Number} the timestamp
  23. * @throws {TypeError} 1 argument required
  24. *
  25. * @example
  26. * // Get the timestamp of 29 February 2012 11:45:05 CET:
  27. * const result = getUnixTime(new Date(2012, 1, 29, 11, 45, 5))
  28. * //=> 1330512305
  29. */
  30. function getUnixTime(dirtyDate) {
  31. (0, _index2.default)(1, arguments);
  32. return Math.floor((0, _index.default)(dirtyDate) / 1000);
  33. }
  34. module.exports = exports.default;