chuvsu-js 4.1.4 → 4.1.5

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/README.md CHANGED
@@ -18,6 +18,18 @@ npm install chuvsu-js
18
18
 
19
19
  ## Быстрый старт
20
20
 
21
+ ### Проверка расписаний на живых данных
22
+
23
+ Укажите `TT_EMAIL` и `TT_PASSWORD` в `.env`, затем запустите:
24
+
25
+ ```bash
26
+ pnpm test:live:schedules
27
+ ```
28
+
29
+ По умолчанию проверяются 50 групп. Доступны `--limit=100`, `--all` и
30
+ `--group=КТ-41-24` (аргументы передаются после `--`). Значения авторизации
31
+ скрипт не выводит.
32
+
21
33
  ### Расписание (TtClient)
22
34
 
23
35
  ```ts
@@ -135,7 +135,7 @@ export class Schedule {
135
135
  year: this.getSemesterYear(semesterPeriod),
136
136
  date,
137
137
  });
138
- if (week >= 0 && week <= 17) {
138
+ if (week >= 1 && week <= 17) {
139
139
  const weekday = date.getDay();
140
140
  const slots = this.getSlotsForWeekday(weekday, semesterDays, {
141
141
  subgroup: opts?.subgroup,
@@ -14,7 +14,7 @@ export declare function getSemesterStart(opts: {
14
14
  }): Date;
15
15
  /**
16
16
  * All weeks in a semester with their start/end dates.
17
- * Week 0 starts from the semester start date.
17
+ * Week 1 is the calendar week containing the semester start date.
18
18
  */
19
19
  export declare function getSemesterWeeks(opts: {
20
20
  period: Period;
@@ -36,16 +36,16 @@ export function getSemesterStart(opts) {
36
36
  }
37
37
  /**
38
38
  * All weeks in a semester with their start/end dates.
39
- * Week 0 starts from the semester start date.
39
+ * Week 1 is the calendar week containing the semester start date.
40
40
  */
41
41
  export function getSemesterWeeks(opts) {
42
42
  const weekCount = opts.weekCount ?? 17;
43
43
  const semesterStart = getSemesterStart(opts);
44
44
  const startMonday = getMonday(semesterStart);
45
45
  const weeks = [];
46
- for (let i = 0; i <= weekCount; i++) {
46
+ for (let i = 1; i <= weekCount; i++) {
47
47
  const start = new Date(startMonday);
48
- start.setDate(startMonday.getDate() + i * 7);
48
+ start.setDate(startMonday.getDate() + (i - 1) * 7);
49
49
  const end = new Date(start);
50
50
  end.setDate(start.getDate() + 6);
51
51
  end.setHours(23, 59, 59, 999);
@@ -60,5 +60,5 @@ export function getWeekNumber(opts) {
60
60
  const startMonday = getMonday(semesterStart);
61
61
  const targetMonday = getMonday(date);
62
62
  const diff = targetMonday.getTime() - startMonday.getTime();
63
- return Math.floor(diff / (7 * 24 * 60 * 60 * 1000));
63
+ return Math.floor(diff / (7 * 24 * 60 * 60 * 1000)) + 1;
64
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chuvsu-js",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "description": "Node.js library for ChuvSU student portal (lk.chuvsu.ru) and schedule (tt.chuvsu.ru)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,6 +43,7 @@
43
43
  "scripts": {
44
44
  "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
45
45
  "build": "pnpm clean && tsc",
46
- "test": "pnpm build && node --test"
46
+ "test": "pnpm build && node --test",
47
+ "test:live:schedules": "pnpm build && node --env-file=.env examples/testSchedules.mjs"
47
48
  }
48
49
  }