summaryrefslogtreecommitdiff
path: root/school/node_modules/pronote-api/src/data/dates.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
committerMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
commit3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch)
tree75be5fba4368472fb11c8015aee026b2b9a71888 /school/node_modules/pronote-api/src/data/dates.js
parent8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff)
downloadpluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'school/node_modules/pronote-api/src/data/dates.js')
-rw-r--r--school/node_modules/pronote-api/src/data/dates.js82
1 files changed, 0 insertions, 82 deletions
diff --git a/school/node_modules/pronote-api/src/data/dates.js b/school/node_modules/pronote-api/src/data/dates.js
deleted file mode 100644
index 52377ba..0000000
--- a/school/node_modules/pronote-api/src/data/dates.js
+++ /dev/null
@@ -1,82 +0,0 @@
-function toPronoteWeek(session, date)
-{
- const firstWeek = toUTCWeek(session.params.firstDay);
- const week = toUTCWeek(date);
-
- if (week >= firstWeek) {
- return week - firstWeek + 1;
- }
-
- return 52 - (firstWeek - week) + 1; // Trust me this works
-}
-
-function toUTCWeek(date)
-{
- const firstDay = new Date((new Date()).getFullYear(), 0, 1);
- return Math.ceil((((date - firstDay) / 86400000) + firstDay.getDay() + 1) / 7);
-}
-
-function toPronoteDay(session, date)
-{
- return Math.ceil((date - session.params.firstDay) / 86400000);
-}
-
-function fromPronoteDay(session, day)
-{
- const date = new Date(session.params.firstDay.getTime());
- date.setDate(date.getDate() + day - 1);
-
- return date;
-}
-
-function toPronoteDate(date)
-{
- return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()} ` +
- `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
-}
-
-function fromPronoteHours(hours)
-{
- return ~~hours[0] + ~~hours.substring(2) / 60;
-}
-
-function parseDate(string)
-{
- const date = new Date();
- const split = string.split(' ');
-
- const day = split[0].split('/');
-
- date.setFullYear(~~day[2], (~~day[1]) - 1, ~~day[0]);
- date.setMilliseconds(0);
-
- if (split.length > 1)
- {
- const time = split[1].split(':');
-
- date.setHours(~~time[0]);
- date.setMinutes(~~time[1]);
- date.setSeconds(~~time[2]);
- }
- else
- {
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- }
-
- return date;
-}
-
-module.exports = {
- toPronoteWeek,
- toUTCWeek,
-
- toPronoteDay,
- fromPronoteDay,
-
- toPronoteDate,
- parseDate,
-
- fromPronoteHours
-};