@eeplatform/nuxt-layer-common 1.7.8 → 1.7.10

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.10
4
+
5
+ ### Patch Changes
6
+
7
+ - a03a4d5: Add time formatter
8
+
9
+ ## 1.7.9
10
+
11
+ ### Patch Changes
12
+
13
+ - eb1a1ec: useBasicEdu - remove kindergarten education level
14
+
3
15
  ## 1.7.8
4
16
 
5
17
  ### Patch Changes
@@ -1,9 +1,5 @@
1
1
  export default function useBasicEdu() {
2
2
  const educationLevels = [
3
- {
4
- title: "Kindergarten",
5
- value: "kindergarten",
6
- },
7
3
  {
8
4
  title: "Elementary",
9
5
  value: "elementary",
@@ -21,10 +17,9 @@ export default function useBasicEdu() {
21
17
  // K-12 only
22
18
  function getGradeLevels(educationLevel: string) {
23
19
  switch (educationLevel) {
24
- case "kindergarten":
25
- return ["K1", "K2"];
26
20
  case "elementary":
27
21
  return [
22
+ "Kindergarten",
28
23
  "Grade 1",
29
24
  "Grade 2",
30
25
  "Grade 3",
@@ -43,14 +38,9 @@ export default function useBasicEdu() {
43
38
 
44
39
  const gradeLevels = [
45
40
  {
46
- title: "K1",
47
- value: "K1",
48
- level: "kindergarten",
49
- },
50
- {
51
- title: "K2",
52
- value: "K2",
53
- level: "kindergarten",
41
+ title: "Kindergarten",
42
+ value: "kindergarten",
43
+ level: "elementary",
54
44
  },
55
45
  {
56
46
  title: "Grade 1",
@@ -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.8",
5
+ "version": "1.7.10",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"