index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = fromUnixTime;
  7. var _index = _interopRequireDefault(require("../toDate/index.js"));
  8. var _index2 = _interopRequireDefault(require("../_lib/toInteger/index.js"));
  9. var _index3 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  10. /**
  11. * @name fromUnixTime
  12. * @category Timestamp Helpers
  13. * @summary Create a date from a Unix timestamp.
  14. *
  15. * @description
  16. * Create a date from a Unix timestamp (in seconds). Decimal values will be discarded.
  17. *
  18. * @param {Number} unixTime - the given Unix timestamp (in seconds)
  19. * @returns {Date} the date
  20. * @throws {TypeError} 1 argument required
  21. *
  22. * @example
  23. * // Create the date 29 February 2012 11:45:05:
  24. * const result = fromUnixTime(1330515905)
  25. * //=> Wed Feb 29 2012 11:45:05
  26. */
  27. function fromUnixTime(dirtyUnixTime) {
  28. (0, _index3.default)(1, arguments);
  29. var unixTime = (0, _index2.default)(dirtyUnixTime);
  30. return (0, _index.default)(unixTime * 1000);
  31. }
  32. module.exports = exports.default;