chuvsu-js 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tt/schedule.js +7 -7
- package/dist/tt/utils.d.ts +1 -0
- package/dist/tt/utils.js +78 -15
- package/package.json +1 -1
package/dist/tt/schedule.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentPeriod, isSessionPeriod, getWeekdayName, getMonday, getSemesterStart, getSemesterWeeks, getWeekNumber, getAdjacentSemester, filterSlots, slotsToLessons, } from "./utils.js";
|
|
1
|
+
import { getCurrentPeriod, isSessionPeriod, getWeekdayName, getMonday, getSemesterStart, getSemesterWeeks, getWeekNumber, getAdjacentSemester, filterSlots, slotsToLessons, sortLessons, } from "./utils.js";
|
|
2
2
|
export class Schedule {
|
|
3
3
|
groupId;
|
|
4
4
|
scheduleMap;
|
|
@@ -70,7 +70,7 @@ export class Schedule {
|
|
|
70
70
|
lessons.push(...slotsToLessons(d.slots, d.date));
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
return lessons;
|
|
73
|
+
return lessons.sort(sortLessons);
|
|
74
74
|
}
|
|
75
75
|
const slots = this.getSlotsForWeekday(weekday, days, opts);
|
|
76
76
|
const date = this.getDateForWeekday(weekday, period, opts?.week);
|
|
@@ -103,7 +103,7 @@ export class Schedule {
|
|
|
103
103
|
lessons.push(...slotsToLessons(slots, date));
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
return lessons;
|
|
106
|
+
return lessons.sort(sortLessons);
|
|
107
107
|
}
|
|
108
108
|
forWeek(week, opts) {
|
|
109
109
|
const period = this.period;
|
|
@@ -127,18 +127,18 @@ export class Schedule {
|
|
|
127
127
|
date.setHours(0, 0, 0, 0);
|
|
128
128
|
lessons.push(...this.forDate(date, opts));
|
|
129
129
|
}
|
|
130
|
-
return lessons;
|
|
130
|
+
return lessons.sort(sortLessons);
|
|
131
131
|
}
|
|
132
132
|
today(opts) {
|
|
133
|
-
return this.forDate(new Date(), opts);
|
|
133
|
+
return this.forDate(new Date(), opts).sort(sortLessons);
|
|
134
134
|
}
|
|
135
135
|
tomorrow(opts) {
|
|
136
136
|
const date = new Date();
|
|
137
137
|
date.setDate(date.getDate() + 1);
|
|
138
|
-
return this.forDate(date, opts);
|
|
138
|
+
return this.forDate(date, opts).sort(sortLessons);
|
|
139
139
|
}
|
|
140
140
|
thisWeek(opts) {
|
|
141
|
-
return this.forWeek(undefined, opts);
|
|
141
|
+
return this.forWeek(undefined, opts).sort(sortLessons);
|
|
142
142
|
}
|
|
143
143
|
currentLesson(opts) {
|
|
144
144
|
const now = new Date();
|
package/dist/tt/utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function getCurrentPeriod(opts?: {
|
|
|
5
5
|
date?: Date;
|
|
6
6
|
}): Period;
|
|
7
7
|
export declare function isSessionPeriod(period: Period): boolean;
|
|
8
|
+
export declare function sortLessons(a: Lesson, b: Lesson): number;
|
|
8
9
|
export declare function getWeekdayName(weekday: number): string;
|
|
9
10
|
export declare function getMonday(date: Date): Date;
|
|
10
11
|
/**
|
package/dist/tt/utils.js
CHANGED
|
@@ -17,6 +17,9 @@ export function getCurrentPeriod(opts) {
|
|
|
17
17
|
export function isSessionPeriod(period) {
|
|
18
18
|
return period === 2 /* Period.WinterSession */ || period === 4 /* Period.SummerSession */;
|
|
19
19
|
}
|
|
20
|
+
export function sortLessons(a, b) {
|
|
21
|
+
return a.start.date.getTime() - b.start.date.getTime();
|
|
22
|
+
}
|
|
20
23
|
const WEEKDAY_NAMES = [
|
|
21
24
|
"Воскресенье",
|
|
22
25
|
"Понедельник",
|
|
@@ -143,23 +146,83 @@ export function slotsToLessons(slots, date) {
|
|
|
143
146
|
}
|
|
144
147
|
// --- Lesson time slots ---
|
|
145
148
|
const VO_TIME_SLOTS = [
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
{
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
{
|
|
150
|
+
number: 1,
|
|
151
|
+
start: { hours: 8, minutes: 20 },
|
|
152
|
+
end: { hours: 9, minutes: 40 },
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
number: 2,
|
|
156
|
+
start: { hours: 9, minutes: 50 },
|
|
157
|
+
end: { hours: 11, minutes: 10 },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
number: 3,
|
|
161
|
+
start: { hours: 11, minutes: 40 },
|
|
162
|
+
end: { hours: 13, minutes: 0 },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
number: 4,
|
|
166
|
+
start: { hours: 13, minutes: 30 },
|
|
167
|
+
end: { hours: 14, minutes: 50 },
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
number: 5,
|
|
171
|
+
start: { hours: 15, minutes: 0 },
|
|
172
|
+
end: { hours: 16, minutes: 20 },
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
number: 6,
|
|
176
|
+
start: { hours: 16, minutes: 40 },
|
|
177
|
+
end: { hours: 18, minutes: 0 },
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
number: 7,
|
|
181
|
+
start: { hours: 18, minutes: 10 },
|
|
182
|
+
end: { hours: 19, minutes: 30 },
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
number: 8,
|
|
186
|
+
start: { hours: 19, minutes: 40 },
|
|
187
|
+
end: { hours: 21, minutes: 0 },
|
|
188
|
+
},
|
|
154
189
|
];
|
|
155
190
|
const SPO_TIME_SLOTS = [
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
|
|
191
|
+
{
|
|
192
|
+
number: 1,
|
|
193
|
+
start: { hours: 8, minutes: 10 },
|
|
194
|
+
end: { hours: 9, minutes: 40 },
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
number: 2,
|
|
198
|
+
start: { hours: 9, minutes: 55 },
|
|
199
|
+
end: { hours: 11, minutes: 25 },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
number: 3,
|
|
203
|
+
start: { hours: 11, minutes: 55 },
|
|
204
|
+
end: { hours: 13, minutes: 25 },
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
number: 4,
|
|
208
|
+
start: { hours: 13, minutes: 40 },
|
|
209
|
+
end: { hours: 15, minutes: 10 },
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
number: 5,
|
|
213
|
+
start: { hours: 15, minutes: 25 },
|
|
214
|
+
end: { hours: 16, minutes: 55 },
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
number: 6,
|
|
218
|
+
start: { hours: 17, minutes: 10 },
|
|
219
|
+
end: { hours: 18, minutes: 40 },
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
number: 7,
|
|
223
|
+
start: { hours: 18, minutes: 55 },
|
|
224
|
+
end: { hours: 20, minutes: 25 },
|
|
225
|
+
},
|
|
163
226
|
];
|
|
164
227
|
export function getTimeSlots(educationType) {
|
|
165
228
|
return educationType === 2 /* EducationType.VocationalEducation */
|