-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add grouping & combining schedules
- Loading branch information
Showing
24 changed files
with
726 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* This example shows how lesson schedules can be retrieved and combined. | ||
*/ | ||
|
||
import { LoginStatus, UntisClient } from "../mod.ts"; | ||
|
||
let client = new UntisClient("nessa.webuntis.com", "School name"); | ||
|
||
let status = await client.login("username", "password"); | ||
if (status !== LoginStatus.Ok) { | ||
throw new Error(`Login failed: ${LoginStatus[status]}`); | ||
} | ||
|
||
let timetable = await client.getOwnTimetable("2022-01-01", "2022-12-31"); | ||
await client.logout(); | ||
|
||
let collection = timetable.getScheduleCollection(); | ||
|
||
collection = collection.combineSequentialSchedules(); | ||
|
||
console.log(collection.schedules); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** The number of milliseconds in each unit of time. */ | ||
export enum TimeUnits { | ||
Millisecond = 1, | ||
Second = 1000 * TimeUnits.Millisecond, | ||
Minute = 60 * TimeUnits.Second, | ||
Hour = 60 * TimeUnits.Minute, | ||
Day = 24 * TimeUnits.Hour, | ||
Week = 7 * TimeUnits.Day, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { assert } from "std/testing/asserts.ts"; | ||
import { Time, TimeUnits } from "./mod.ts"; | ||
|
||
Deno.test("Time.selectEarlier() - should work with different hours", () => { | ||
let a = new Time(9, 25); | ||
let b = new Time(10, 0); | ||
|
||
assert(a.selectEarlier(b).equals(a)); | ||
}); | ||
|
||
Deno.test("Time.selectEarlier() - should work with the same hour", () => { | ||
let a = new Time(9, 25); | ||
let b = new Time(9, 30); | ||
|
||
assert(a.selectEarlier(b).equals(a)); | ||
}); | ||
|
||
Deno.test("Time.selectLater() - should work with different hours", () => { | ||
let a = new Time(9, 25); | ||
let b = new Time(10, 0); | ||
|
||
assert(a.selectLater(b).equals(b)); | ||
}); | ||
|
||
Deno.test("Time.selectLater() - should work with the same hour", () => { | ||
let a = new Time(9, 25); | ||
let b = new Time(9, 30); | ||
|
||
assert(a.selectLater(b).equals(b)); | ||
}); | ||
|
||
Deno.test("Time.diffTo() - should be +1 hour", () => { | ||
let a = new Time(10, 30); | ||
let b = new Time(11, 30); | ||
|
||
assert(a.diffTo(b) === TimeUnits.Hour * 1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./Time.ts"; | ||
export * from "./untis.ts"; | ||
export * from "./TimeUnits.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.