@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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eeplatform/nuxt-layer-common
2
2
 
3
+ ## 1.7.11
4
+
5
+ ### Patch Changes
6
+
7
+ - ed0029f: Add school year generator
8
+
9
+ ## 1.7.10
10
+
11
+ ### Patch Changes
12
+
13
+ - a03a4d5: Add time formatter
14
+
3
15
  ## 1.7.9
4
16
 
5
17
  ### Patch Changes
@@ -104,8 +104,11 @@ export default function useBasicEdu() {
104
104
  },
105
105
  ];
106
106
 
107
- function generateSchoolYears(generation = 0, mode = "past") {
108
- const currentYear = new Date().getFullYear();
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") {
@@ -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
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@eeplatform/nuxt-layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.7.9",
5
+ "version": "1.7.11",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"