source: imaps-frontend/node_modules/es-abstract/2018/DateFromTime.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 988 bytes
RevLine 
[d565449]1'use strict';
2
3var $EvalError = require('es-errors/eval');
4
5var DayWithinYear = require('./DayWithinYear');
6var InLeapYear = require('./InLeapYear');
7var MonthFromTime = require('./MonthFromTime');
8
9// https://262.ecma-international.org/5.1/#sec-15.9.1.5
10
11module.exports = function DateFromTime(t) {
12 var m = MonthFromTime(t);
13 var d = DayWithinYear(t);
14 if (m === 0) {
15 return d + 1;
16 }
17 if (m === 1) {
18 return d - 30;
19 }
20 var leap = InLeapYear(t);
21 if (m === 2) {
22 return d - 58 - leap;
23 }
24 if (m === 3) {
25 return d - 89 - leap;
26 }
27 if (m === 4) {
28 return d - 119 - leap;
29 }
30 if (m === 5) {
31 return d - 150 - leap;
32 }
33 if (m === 6) {
34 return d - 180 - leap;
35 }
36 if (m === 7) {
37 return d - 211 - leap;
38 }
39 if (m === 8) {
40 return d - 242 - leap;
41 }
42 if (m === 9) {
43 return d - 272 - leap;
44 }
45 if (m === 10) {
46 return d - 303 - leap;
47 }
48 if (m === 11) {
49 return d - 333 - leap;
50 }
51 throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m);
52};
Note: See TracBrowser for help on using the repository browser.