Skip to content

Commit

Permalink
feat: add getCurrentSchoolyear() (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkilders committed Feb 16, 2024
1 parent 2c51a44 commit c9fa544
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,24 @@ export class Base {
return await this._request('getStatusData', {}, validateSession);
}

/**
* Get the current school year
* @param [validateSession=true]
* @returns {Promise.<SchoolYear>}
*/
async getCurrentSchoolyear(validateSession = true): Promise<SchoolYear> {
const data = await this._request<InternalSchoolYear>('getCurrentSchoolyear', {}, validateSession);

if (!data) throw new Error('Failed to retrieve current school year');

return {
name: data.name,
id: data.id,
startDate: Base.convertUntisDate(data.startDate),
endDate: Base.convertUntisDate(data.endDate),
};
}

/**
* Convert a JS Date Object to a WebUntis date string
* @param {Date} date
Expand Down

0 comments on commit c9fa544

Please sign in to comment.