Projekt

Obecné

Profil

Stáhnout (1019 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
'use strict';
2
3
var DayWithinYear = require('./DayWithinYear');
4
var InLeapYear = require('./InLeapYear');
5
6
// https://ecma-international.org/ecma-262/5.1/#sec-15.9.1.4
7
8
module.exports = function MonthFromTime(t) {
9
	var day = DayWithinYear(t);
10
	if (0 <= day && day < 31) {
11
		return 0;
12
	}
13
	var leap = InLeapYear(t);
14
	if (31 <= day && day < (59 + leap)) {
15
		return 1;
16
	}
17
	if ((59 + leap) <= day && day < (90 + leap)) {
18
		return 2;
19
	}
20
	if ((90 + leap) <= day && day < (120 + leap)) {
21
		return 3;
22
	}
23
	if ((120 + leap) <= day && day < (151 + leap)) {
24
		return 4;
25
	}
26
	if ((151 + leap) <= day && day < (181 + leap)) {
27
		return 5;
28
	}
29
	if ((181 + leap) <= day && day < (212 + leap)) {
30
		return 6;
31
	}
32
	if ((212 + leap) <= day && day < (243 + leap)) {
33
		return 7;
34
	}
35
	if ((243 + leap) <= day && day < (273 + leap)) {
36
		return 8;
37
	}
38
	if ((273 + leap) <= day && day < (304 + leap)) {
39
		return 9;
40
	}
41
	if ((304 + leap) <= day && day < (334 + leap)) {
42
		return 10;
43
	}
44
	if ((334 + leap) <= day && day < (365 + leap)) {
45
		return 11;
46
	}
47
};