-
Notifications
You must be signed in to change notification settings - Fork 1
/
format.js
212 lines (199 loc) · 6.26 KB
/
format.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
Copyright (c) 2018 Y Paritcher
*/
(function () {
'use strict'
zmanJS.formatnum = function (num) {
/*
* Based on https://github.com/Scimonster/js-gematriya
* Copyright (c) 2014 Eyal Schachter
* Licensed MIT.
*/
let letters = {
0: "",
1: "א",
2: "ב",
3: "ג",
4: "ד",
5: "ה",
6: "ו",
7: "ז",
8: "ח",
9: "ט",
10: "י",
20: "כ",
30: "ל",
40: "מ",
50: "נ",
60: "ס",
70: "ע",
80: "פ",
90: "צ",
100: "ק",
200: "ר",
300: "ש",
400: "ת",
500: "תק",
600: "תר",
700: "תש",
800: "תת",
900: "תתק",
1000: "תתר"
};
num = num.toString().split('').reverse();
num = num.slice(0, 3);
num = num.map(function g(n,i){
if (parseInt(n, 10) * Math.pow(10, i) > 1000) {
return g(n, i-3);
}
return letters[parseInt(n, 10) * Math.pow(10, i)];
});
num = num.reverse().join('').replace(/יה/g,'טו').replace(/יו/g,'טז').split('');
/* if (num.length === 1) {
num.push('׳');
} else */
if (num.length > 1) {
num.splice(-1, 0, '״');
}
return num.join('');
}
zmanJS.formattime = function (date)
{
let str= "";
let hour = date.hour%12;
if(!hour){hour = 12;}
let minutes = ("0" + date.min).slice(-2);
str += hour + ":" + minutes;
return str;
}
zmanJS.formatwday = function (date, shabbos)
{
const hwday =[ "שבת", "ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שביעי"];
if (shabbos && (date.wday == 7)) {return hwday[0];}
return hwday[date.wday];
}
zmanJS.formatmonth = function (date)
{
const hmonth = [ "אדר א׳", "ניסן", "אייר", "סיון", "תמוז", "אב", "אלול", "תשרי", "חשון", "כסלו", "טבת", "שבט", "אדר", "אדר ב׳"];
if (date.leap)
{
if (date.month == 12){ return hmonth[0];}
if (date.month == 13){ return hmonth[date.month];}
}
if (date.month > 0 && date.month < 13){ return hmonth[date.month];}
return "";
}
zmanJS.meridian = function (date)
{
return (date.hour < 11) ? "AM" : "PM";
}
zmanJS.parshahformat = function (current)
{
const parshahchar = ["", "בראשית", "נח", "לך לך", "וירא", "חיי שרה", "תולדות", "ויצא", "וישלח", "וישב", "מקץ", "ויגש", "ויחי", "שמות", "וארא", "בא", "בשלח", "יתרו", "משפטים", "תרומה", "תצוה", "כי תשא", "ויקהל", "פקודי", "ויקרא", "צו", "שמיני", "תזריע", "מצורע", "אחרי מות", "קדושים", "אמור", "בהר", "בחוקותי", "במדבר", "נשא", "בהעלותך", "שלח", "קרח", "חקת", "בלק", "פנחס", "מטות", "מסעי", "דברים", "ואתחנן", "עקב", "ראה", "שופטים", "כי תצא", "כי תבוא", "נצבים", "וילך", "האזינו", "וזאת הברכה", "ויקהל - פקודי", "תזריע - מצורע", "אחרי מות - קדושים", "בהר - בחוקותי", "חקת - בלק", "מטות - מסעי", "נצבים - וילך"];
return parshahchar[current];
}
zmanJS.yomtovformat = function (current)
{
switch(current)
{
case zmanJS.yomtov.CHOL:
break;
case zmanJS.yomtov.PESACH_DAY1:
case zmanJS.yomtov.PESACH_DAY2:
return "פסח";
case zmanJS.yomtov.SHVEI_SHEL_PESACH:
return "שביעי של פסח";
case zmanJS.yomtov.ACHRON_SHEL_PESACH:
return "אחרון של פסח";
case zmanJS.yomtov.SHAVOUS_DAY1:
case zmanJS.yomtov.SHAVOUS_DAY2:
return "שבועות";
case zmanJS.yomtov.ROSH_HASHANAH_DAY1:
case zmanJS.yomtov.ROSH_HASHANAH_DAY2:
return "ראש השנה";
case zmanJS.yomtov.YOM_KIPPUR:
return "יום כיפור";
case zmanJS.yomtov.SUKKOS_DAY1:
case zmanJS.yomtov.SUKKOS_DAY2:
return "סוכות";
case zmanJS.yomtov.SHMEINI_ATZERES:
return "שמיני עצרת";
case zmanJS.yomtov.SIMCHAS_TORAH:
return "שמחת תורה";
case zmanJS.yomtov.CHOL_HAMOED_PESACH_DAY1:
case zmanJS.yomtov.CHOL_HAMOED_PESACH_DAY2:
case zmanJS.yomtov.CHOL_HAMOED_PESACH_DAY3:
case zmanJS.yomtov.CHOL_HAMOED_PESACH_DAY4:
case zmanJS.yomtov.CHOL_HAMOED_PESACH_DAY5:
return "חול המועד פסח";
case zmanJS.yomtov.CHOL_HAMOED_SUKKOS_DAY1:
case zmanJS.yomtov.CHOL_HAMOED_SUKKOS_DAY2:
case zmanJS.yomtov.CHOL_HAMOED_SUKKOS_DAY3:
case zmanJS.yomtov.CHOL_HAMOED_SUKKOS_DAY4:
case zmanJS.yomtov.CHOL_HAMOED_SUKKOS_DAY5:
return "חול המועד סוכות";
case zmanJS.yomtov.HOSHANA_RABBAH:
return "הושענא רבה";
case zmanJS.yomtov.PESACH_SHEINI:
return "פסח שני";
case zmanJS.yomtov.LAG_BAOMER:
return "ל״ג בעומר";
case zmanJS.yomtov.TU_BAV:
return "ט״ו באב";
case zmanJS.yomtov.CHANUKAH_DAY1:
case zmanJS.yomtov.CHANUKAH_DAY2:
case zmanJS.yomtov.CHANUKAH_DAY3:
case zmanJS.yomtov.CHANUKAH_DAY4:
case zmanJS.yomtov.CHANUKAH_DAY5:
case zmanJS.yomtov.CHANUKAH_DAY6:
case zmanJS.yomtov.CHANUKAH_DAY7:
case zmanJS.yomtov.CHANUKAH_DAY8:
return "חנוכה";
case zmanJS.yomtov.TU_BISHVAT:
return "ט״ו בשבט";
case zmanJS.yomtov.PURIM_KATAN:
return "פורים קטן";
case zmanJS.yomtov.SHUSHAN_PURIM_KATAN:
return "שושן פורים קטן";
case zmanJS.yomtov.PURIM:
return "פורים";
case zmanJS.yomtov.SHUSHAN_PURIM:
return "שושן פורים";
case zmanJS.yomtov.SHIVA_ASAR_BTAAMUZ:
return "שבעה עשר בתמוז";
case zmanJS.yomtov.TISHA_BAV:
return "ט׳ באב";
case zmanJS.yomtov.TZOM_GEDALIA:
return "צום גדליה";
case zmanJS.yomtov.ASARAH_BTEVES:
return "עשרה בטבת";
case zmanJS.yomtov.TAANIS_ESTER:
return "תענית אסתר";
case zmanJS.yomtov.EREV_PESACH:
return "ערב פסח";
case zmanJS.yomtov.EREV_SHAVOUS:
return "ערב שבועות";
case zmanJS.yomtov.EREV_ROSH_HASHANAH:
return "ערב ראש השנה";
case zmanJS.yomtov.EREV_YOM_KIPPUR:
return "ערב יום כיפור";
case zmanJS.yomtov.EREV_SUKKOS:
return "ערב סוכות";
case zmanJS.yomtov.SHKALIM:
return "שקלים";
case zmanJS.yomtov.ZACHOR:
return "זכור";
case zmanJS.yomtov.PARAH:
return "פרה";
case zmanJS.yomtov.HACHODESH:
return "החודש";
case zmanJS.yomtov.ROSH_CHODESH:
return "ראש חודש";
case zmanJS.yomtov.MACHAR_CHODESH:
return "מחר חודש";
case zmanJS.yomtov.SHABBOS_MEVORCHIM:
return "שבת מברכים";
}
return "";
}
}());