forked from LitoMore/mzsi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·107 lines (94 loc) · 1.9 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
module.exports = (month, day, languageCode) => {
'use strict';
const monthTypeOf = typeof month;
if (monthTypeOf !== 'number') {
throw new TypeError('The month should be a number');
}
const dayTypeOf = typeof day;
if (dayTypeOf !== 'number') {
throw new TypeError('The day should be a number');
}
const possibilities = [
{
id: 1,
begin: [20, 1],
end: [18, 2]
},
{
id: 2,
begin: [19, 2],
end: [20, 3]
},
{
id: 3,
begin: [21, 3],
end: [19, 4]
},
{
id: 4,
begin: [20, 4],
end: [20, 5]
},
{
id: 5,
begin: [21, 5],
end: [20, 6]
},
{
id: 6,
begin: [21, 6],
end: [21, 7]
},
{
id: 7,
begin: [22, 7],
end: [22, 8]
},
{
id: 8,
begin: [23, 8],
end: [22, 9]
},
{
id: 9,
begin: [23, 9],
end: [22, 10]
},
{
id: 10,
begin: [23, 10],
end: [21, 11]
},
{
id: 11,
begin: [22, 11],
end: [21, 12]
},
{
id: 12,
begin: [22, 12],
end: [19, 1]
}
];
const sign = possibilities.filter(sign => {
const itIsAmongTheBeginning = (day >= sign.begin[0] && month === sign.begin[1]);
const itIsAmongTheEnd = (day <= sign.end[0] && month === sign.end[1]);
return (itIsAmongTheBeginning || itIsAmongTheEnd);
});
const translatedLanguages = ['en-us', 'pt-br', 'zh-cn'];
let languageToDisplay = 'en-us';
if (translatedLanguages.indexOf(languageCode) > -1) {
languageToDisplay = languageCode;
}
const aboutSign = JSON.parse(
require('fs').readFileSync(
require('path').resolve(__dirname, `i18n/${languageToDisplay}-about.json`),
'utf8'
)
)[sign[0].id];
return {
name: aboutSign.name,
symbol: require('./get-symbol')(sign[0].id),
about: aboutSign
};
};