main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
[79a0317] | 3 | var $RangeError = require('es-errors/range');
|
---|
| 4 |
|
---|
[d565449] | 5 | var DayWithinYear = require('./DayWithinYear');
|
---|
| 6 | var InLeapYear = require('./InLeapYear');
|
---|
| 7 |
|
---|
| 8 | // https://262.ecma-international.org/5.1/#sec-15.9.1.4
|
---|
| 9 |
|
---|
| 10 | module.exports = function MonthFromTime(t) {
|
---|
| 11 | var day = DayWithinYear(t);
|
---|
| 12 | if (0 <= day && day < 31) {
|
---|
| 13 | return 0;
|
---|
| 14 | }
|
---|
| 15 | var leap = InLeapYear(t);
|
---|
| 16 | if (31 <= day && day < (59 + leap)) {
|
---|
| 17 | return 1;
|
---|
| 18 | }
|
---|
| 19 | if ((59 + leap) <= day && day < (90 + leap)) {
|
---|
| 20 | return 2;
|
---|
| 21 | }
|
---|
| 22 | if ((90 + leap) <= day && day < (120 + leap)) {
|
---|
| 23 | return 3;
|
---|
| 24 | }
|
---|
| 25 | if ((120 + leap) <= day && day < (151 + leap)) {
|
---|
| 26 | return 4;
|
---|
| 27 | }
|
---|
| 28 | if ((151 + leap) <= day && day < (181 + leap)) {
|
---|
| 29 | return 5;
|
---|
| 30 | }
|
---|
| 31 | if ((181 + leap) <= day && day < (212 + leap)) {
|
---|
| 32 | return 6;
|
---|
| 33 | }
|
---|
| 34 | if ((212 + leap) <= day && day < (243 + leap)) {
|
---|
| 35 | return 7;
|
---|
| 36 | }
|
---|
| 37 | if ((243 + leap) <= day && day < (273 + leap)) {
|
---|
| 38 | return 8;
|
---|
| 39 | }
|
---|
| 40 | if ((273 + leap) <= day && day < (304 + leap)) {
|
---|
| 41 | return 9;
|
---|
| 42 | }
|
---|
| 43 | if ((304 + leap) <= day && day < (334 + leap)) {
|
---|
| 44 | return 10;
|
---|
| 45 | }
|
---|
| 46 | if ((334 + leap) <= day && day < (365 + leap)) {
|
---|
| 47 | return 11;
|
---|
| 48 | }
|
---|
[79a0317] | 49 |
|
---|
| 50 | throw new $RangeError('Assertion failed: `day` is out of range');
|
---|
[d565449] | 51 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.