@eeplatform/nuxt-layer-common 1.7.9 → 1.7.11
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/CHANGELOG.md +12 -0
- package/composables/useBasicEdu.ts +5 -2
- package/composables/useUtils.ts +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -104,8 +104,11 @@ export default function useBasicEdu() {
|
|
|
104
104
|
},
|
|
105
105
|
];
|
|
106
106
|
|
|
107
|
-
function generateSchoolYears(
|
|
108
|
-
|
|
107
|
+
function generateSchoolYears(
|
|
108
|
+
generation = 0,
|
|
109
|
+
mode = "past",
|
|
110
|
+
currentYear = new Date().getFullYear()
|
|
111
|
+
) {
|
|
109
112
|
const years = [];
|
|
110
113
|
|
|
111
114
|
if (mode === "past") {
|
package/composables/useUtils.ts
CHANGED
|
@@ -262,6 +262,36 @@ export default function useUtils() {
|
|
|
262
262
|
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
// Helper function to convert time string to minutes for comparison
|
|
266
|
+
const convertTimeToMinutes = (timeString: string): number => {
|
|
267
|
+
const [hours, minutes] = timeString.split(":").map(Number);
|
|
268
|
+
return hours * 60 + minutes;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// Helper function to calculate duration in minutes
|
|
272
|
+
const calculateDuration = (startTime: string, endTime: string): number => {
|
|
273
|
+
const startMinutes = convertTimeToMinutes(startTime);
|
|
274
|
+
const endMinutes = convertTimeToMinutes(endTime);
|
|
275
|
+
return endMinutes - startMinutes;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// Helper function to format duration in hours and minutes
|
|
279
|
+
const formatDuration = (totalMinutes: number): string => {
|
|
280
|
+
if (totalMinutes < 60) {
|
|
281
|
+
return `${totalMinutes} mins`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
285
|
+
const remainingMinutes = totalMinutes % 60;
|
|
286
|
+
|
|
287
|
+
if (remainingMinutes === 0) {
|
|
288
|
+
return hours === 1 ? "1 hr" : `${hours} hrs`;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const hourText = hours === 1 ? "1 hr" : `${hours} hrs`;
|
|
292
|
+
return `${hourText} ${remainingMinutes} mins`;
|
|
293
|
+
};
|
|
294
|
+
|
|
265
295
|
return {
|
|
266
296
|
requiredRule,
|
|
267
297
|
emailRule,
|
|
@@ -288,5 +318,8 @@ export default function useUtils() {
|
|
|
288
318
|
replaceMatch,
|
|
289
319
|
setRouteParams,
|
|
290
320
|
toOrdinal,
|
|
321
|
+
convertTimeToMinutes,
|
|
322
|
+
calculateDuration,
|
|
323
|
+
formatDuration,
|
|
291
324
|
};
|
|
292
325
|
}
|