UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = endOfSecond;
7
8var _index = _interopRequireDefault(require("../toDate/index.js"));
9
10var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14/**
15 * @name endOfSecond
16 * @category Second Helpers
17 * @summary Return the end of a second for the given date.
18 *
19 * @description
20 * Return the end of a second for the given date.
21 * The result will be in the local timezone.
22 *
23 * ### v2.0.0 breaking changes:
24 *
25 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
26 *
27 * @param {Date|Number} date - the original date
28 * @returns {Date} the end of a second
29 * @throws {TypeError} 1 argument required
30 *
31 * @example
32 * // The end of a second for 1 December 2014 22:15:45.400:
33 * var result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))
34 * //=> Mon Dec 01 2014 22:15:45.999
35 */
36function endOfSecond(dirtyDate) {
37 (0, _index2.default)(1, arguments);
38 var date = (0, _index.default)(dirtyDate);
39 date.setMilliseconds(999);
40 return date;
41}
42
43module.exports = exports.default;
\No newline at end of file