@quesmed/types 1.4.24 → 1.4.25
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/models/User.js +10 -1
- package/models/User.mjs +10 -1
- package/package.json +1 -1
package/models/User.js
CHANGED
|
@@ -27,6 +27,9 @@ exports.classYearGroup = {
|
|
|
27
27
|
'Beta Tester': EClassYearGroup.CLINICAL,
|
|
28
28
|
};
|
|
29
29
|
function currentClassYear(createdAtUnix, classYear) {
|
|
30
|
+
if (createdAtUnix === 0) {
|
|
31
|
+
throw new Error('createdAt not given in Unix');
|
|
32
|
+
}
|
|
30
33
|
if (!createdAtUnix) {
|
|
31
34
|
return classYear;
|
|
32
35
|
}
|
|
@@ -38,6 +41,9 @@ function currentClassYear(createdAtUnix, classYear) {
|
|
|
38
41
|
const now = new Date();
|
|
39
42
|
const currentYear = now.getFullYear();
|
|
40
43
|
const createdAt = new Date(createdAtUnix * 1000);
|
|
44
|
+
if (createdAt.getFullYear() > now.getFullYear()) {
|
|
45
|
+
throw new Error('createdAt not given in Unix');
|
|
46
|
+
}
|
|
41
47
|
const createdYear = createdAt.getFullYear();
|
|
42
48
|
let yearsAdded = currentYear - createdYear;
|
|
43
49
|
const createdAcademicYear = new Date(createdYear, 7, 1);
|
|
@@ -56,6 +62,9 @@ function currentClassYear(createdAtUnix, classYear) {
|
|
|
56
62
|
exports.currentClassYear = currentClassYear;
|
|
57
63
|
function currentClassGroup(createdAtUnix, classYear) {
|
|
58
64
|
const currentClass = currentClassYear(createdAtUnix, classYear);
|
|
59
|
-
|
|
65
|
+
if (!exports.classYearGroup.hasOwnProperty(currentClass)) {
|
|
66
|
+
return EClassYearGroup.CLINICAL;
|
|
67
|
+
}
|
|
68
|
+
return exports.classYearGroup[currentClass];
|
|
60
69
|
}
|
|
61
70
|
exports.currentClassGroup = currentClassGroup;
|
package/models/User.mjs
CHANGED
|
@@ -24,6 +24,9 @@ export const classYearGroup = {
|
|
|
24
24
|
'Beta Tester': EClassYearGroup.CLINICAL,
|
|
25
25
|
};
|
|
26
26
|
export function currentClassYear(createdAtUnix, classYear) {
|
|
27
|
+
if (createdAtUnix === 0) {
|
|
28
|
+
throw new Error('createdAt not given in Unix');
|
|
29
|
+
}
|
|
27
30
|
if (!createdAtUnix) {
|
|
28
31
|
return classYear;
|
|
29
32
|
}
|
|
@@ -35,6 +38,9 @@ export function currentClassYear(createdAtUnix, classYear) {
|
|
|
35
38
|
const now = new Date();
|
|
36
39
|
const currentYear = now.getFullYear();
|
|
37
40
|
const createdAt = new Date(createdAtUnix * 1000);
|
|
41
|
+
if (createdAt.getFullYear() > now.getFullYear()) {
|
|
42
|
+
throw new Error('createdAt not given in Unix');
|
|
43
|
+
}
|
|
38
44
|
const createdYear = createdAt.getFullYear();
|
|
39
45
|
let yearsAdded = currentYear - createdYear;
|
|
40
46
|
const createdAcademicYear = new Date(createdYear, 7, 1);
|
|
@@ -52,5 +58,8 @@ export function currentClassYear(createdAtUnix, classYear) {
|
|
|
52
58
|
}
|
|
53
59
|
export function currentClassGroup(createdAtUnix, classYear) {
|
|
54
60
|
const currentClass = currentClassYear(createdAtUnix, classYear);
|
|
55
|
-
|
|
61
|
+
if (!classYearGroup.hasOwnProperty(currentClass)) {
|
|
62
|
+
return EClassYearGroup.CLINICAL;
|
|
63
|
+
}
|
|
64
|
+
return classYearGroup[currentClass];
|
|
56
65
|
}
|