MakeTime.js 698 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var $isFinite = require('../helpers/isFinite');
  3. var timeConstants = require('../helpers/timeConstants');
  4. var msPerSecond = timeConstants.msPerSecond;
  5. var msPerMinute = timeConstants.msPerMinute;
  6. var msPerHour = timeConstants.msPerHour;
  7. var ToInteger = require('./ToInteger');
  8. // https://262.ecma-international.org/5.1/#sec-15.9.1.11
  9. module.exports = function MakeTime(hour, min, sec, ms) {
  10. if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) {
  11. return NaN;
  12. }
  13. var h = ToInteger(hour);
  14. var m = ToInteger(min);
  15. var s = ToInteger(sec);
  16. var milli = ToInteger(ms);
  17. var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli;
  18. return t;
  19. };