index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = fromUnixTime;
  6. var _index = _interopRequireDefault(require("../toDate/index.js"));
  7. var _index2 = _interopRequireDefault(require("../_lib/toInteger/index.js"));
  8. var _index3 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  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.
  17. *
  18. * ### v2.0.0 breaking changes:
  19. *
  20. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  21. *
  22. * @param {Number} unixTime - the given Unix timestamp
  23. * @returns {Date} the date
  24. * @throws {TypeError} 1 argument required
  25. *
  26. * @example
  27. * // Create the date 29 February 2012 11:45:05:
  28. * var result = fromUnixTime(1330515905)
  29. * //=> Wed Feb 29 2012 11:45:05
  30. */
  31. function fromUnixTime(dirtyUnixTime) {
  32. (0, _index3.default)(1, arguments);
  33. var unixTime = (0, _index2.default)(dirtyUnixTime);
  34. return (0, _index.default)(unixTime * 1000);
  35. }
  36. module.exports = exports.default;