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
108
109
110
111
112
113
114
import { Calendar } from '../calendar';
const pad = function (num, size) {
const s = `000000000${num}`;
return s.substr(s.length - size);
};
const masaNames = {
[0]: { saka: 'Caitra ', saura: 'Mesa ', enMalayalam: 'Chingam ', mlMalayalam: 'ചിങ്ങം' },
[1]: { saka: 'Vaisakha ', saura: 'Vrsa ', enMalayalam: 'Kanni ', mlMalayalam: 'കന്നി' },
[2]: { saka: 'Jyaistha ', saura: 'Mithuna ', enMalayalam: 'Thulam ', mlMalayalam: 'തുലാം' },
[3]: { saka: 'Asadha ', saura: 'Karkata ', enMalayalam: 'Vrischikam', mlMalayalam: 'വൃശ്ചികം' },
[4]: { saka: 'Sravana ', saura: 'Simha ', enMalayalam: 'Dhanu ', mlMalayalam: 'ധനു' },
[5]: { saka: 'Bhadrapada', saura: 'Kanya ', enMalayalam: 'Makaram ', mlMalayalam: 'മകരം' },
[6]: { saka: 'Asvina ', saura: 'Tula ', enMalayalam: 'Kumbham ', mlMalayalam: 'കുംഭം' },
[7]: { saka: 'Karttika ', saura: 'Vrscika ', enMalayalam: 'Meenam ', mlMalayalam: 'മീനം' },
[8]: { saka: 'Margasirsa', saura: 'Dhanus ', enMalayalam: 'Medam ', mlMalayalam: 'മേടം' },
[9]: { saka: 'Pausa ', saura: 'Makara ', enMalayalam: 'Idavam ', mlMalayalam: 'ഇടവം' },
[10]: { saka: 'Magha ', saura: 'Kumbha ', enMalayalam: 'Mithunam ', mlMalayalam: 'മിഥുനം' },
[11]: { saka: 'Phalguna ', saura: 'Mina ', enMalayalam: 'Karkitakam', mlMalayalam: 'കർക്കടകം' }
};
export class BaseDate {
constructor(year = 0, month = 0, date = 0) {
this._naksatra = Calendar.naksatras[-1];
this.year = year;
this.month = month;
this.date = date;
this.gregorianDate = new Date();
this.julianDay = -1;
this.ahargana = -1;
this.sauraMasa = -1;
this.sauraDivasa = -1;
}
get naksatra() {
return this._naksatra;
}
set naksatra(val) {
this._naksatra = val;
}
get sauraMasaName() {
return BaseDate.getMasaName(this.sauraMasa).saura;
}
get weekdayName() {
return Calendar.julianDayToWeekday(this.julianDay).en;
}
get mlWeekdayName() {
return Calendar.julianDayToWeekday(this.julianDay).ml;
}
toString() {
return `${pad(this.year, 4)} ${pad(this.month, 2)} ${pad(this.date, 2)}`;
}
static getMasaName(masaNumber) {
return masaNames[masaNumber];
}
}