UNPKG

timezonecomplete

Version:

DateTime, TimeZone, Duration and Period library aimed at providing a consistent and complete date-time interface, away from the original JavaScript Date class.

45 lines 1.72 kB
/** * Copyright(c) 2014 ABB Switzerland Ltd. * * Global functions depending on DateTime/Duration etc */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.abs = exports.max = exports.min = void 0; var assert_1 = require("./assert"); /** * Returns the minimum of two DateTimes or Durations * @throws timezonecomplete.Argument.D1 if d1 is undefined/null * @throws timezonecomplete.Argument.D2 if d1 is undefined/null, or if d1 and d2 are not both datetimes */ function min(d1, d2) { (0, assert_1.default)(d1, "Argument.D1", "first argument is falsy"); (0, assert_1.default)(d2, "Argument.D2", "second argument is falsy"); /* istanbul ignore next */ (0, assert_1.default)(d1.kind === d2.kind, "Argument.D2", "expected either two datetimes or two durations"); return d1.min(d2); } exports.min = min; /** * Returns the maximum of two DateTimes or Durations * @throws timezonecomplete.Argument.D1 if d1 is undefined/null * @throws timezonecomplete.Argument.D2 if d1 is undefined/null, or if d1 and d2 are not both datetimes */ function max(d1, d2) { (0, assert_1.default)(d1, "Argument.D1", "first argument is falsy"); (0, assert_1.default)(d2, "Argument.D2", "second argument is falsy"); /* istanbul ignore next */ (0, assert_1.default)(d1.kind === d2.kind, "Argument.D2", "expected either two datetimes or two durations"); return d1.max(d2); } exports.max = max; /** * Returns the absolute value of a Duration * @throws timezonecomplete.Argument.D if d is undefined/null */ function abs(d) { (0, assert_1.default)(d, "Argument.D", "first argument is falsy"); return d.abs(); } exports.abs = abs; //# sourceMappingURL=globals.js.map