@finema/core 2.42.3 → 2.43.1

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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.42.3",
3
+ "version": "2.43.1",
4
4
  "configKey": "core",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import * as lodash from 'lodash-es';
4
4
  import * as theme from '../dist/runtime/theme/index.js';
5
5
 
6
6
  const name = "@finema/core";
7
- const version = "2.42.3";
7
+ const version = "2.43.1";
8
8
 
9
9
  const nuxtAppOptions = {
10
10
  head: {
@@ -54,9 +54,9 @@ const core = {
54
54
  time_format: "HH:mm",
55
55
  date_format: "dd-MMM-yyyy",
56
56
  month_format: "MMM-yyyy",
57
- date_time_format: "dd-MMM-yyyy HH:mm",
57
+ date_time_format: "dd-MMM-yyyy HH:mm:ss",
58
58
  date_format_system: "yyyy-MM-dd",
59
- date_time_format_system: "yyyy-MM-dd HH:mm",
59
+ date_time_format_system: "yyyy-MM-dd HH:mm:ss",
60
60
  is_thai_year: false,
61
61
  is_thai_month: false,
62
62
  site_name: "",
@@ -1,20 +1,21 @@
1
1
  export declare class TimeHelper {
2
2
  static thaiFormat: (dateStr: Date, formatStr: string, forceThai?: boolean) => string;
3
- static displayDate: (time: string | Date) => string;
4
- static displayDateTime: (time: string | Date) => string;
5
- static displayDateThai: (time: string | Date) => string;
6
- static displayDateTimeThai: (time: string | Date) => string;
7
- static displayDateRange: (startDate: Date | string, endDate: Date | string) => {
8
- startDate: Date | string;
9
- endDate: Date | string;
3
+ static displayDate: (time: string | Date | null | undefined) => string | null;
4
+ static displayDateTime: (time: string | Date | null | undefined) => string | null;
5
+ static displayDateThai: (time: string | Date | null | undefined) => string | null;
6
+ static displayDateTimeThai: (time: string | Date | null | undefined) => string | null;
7
+ static displayDateRange: (startDate: Date | string | null | undefined, endDate: Date | string | null | undefined) => {
8
+ startDate: Date | string | null;
9
+ endDate: Date | string | null;
10
10
  };
11
- static toUTC: (time: string | Date) => string;
12
- static toLocal: (time: string | Date) => string;
11
+ static toUTC: (time: string | Date | null | undefined) => string | null;
12
+ static toLocal: (time: string | Date | null | undefined) => string | null;
13
13
  static getCurrentDate: (customFormat?: string) => string;
14
- static getDateFormTime: (time: string | Date, customFormat?: string) => string;
15
- static getDateFormTimeWithLocal: (time: string | Date, customFormat?: string) => string;
16
- static getISODateTimeFormTime: (time: string | Date) => string;
17
- static getDateTimeFormTime: (time: string | Date) => string;
18
- static getTimeFormTime: (time: string | Date) => string;
14
+ static getDateFormTime: (time: string | Date | null | undefined, customFormat?: string) => string | null;
15
+ static getDateFormTimeWithLocal: (time: string | Date | null | undefined, customFormat?: string) => string | null;
16
+ static getISODateTimeFormTime: (time: string | Date | null | undefined) => string | null;
17
+ static getDateTimeFormTime: (time: string | Date | null | undefined) => string | null;
18
+ static getTimeFormTime: (time: string | Date | null | undefined) => string | null;
19
19
  static getCurrentDateTime: () => string;
20
+ static toDate: (str: string | Date | null | undefined) => Date | null;
20
21
  }
@@ -1,4 +1,4 @@
1
- import { addYears, format, formatISO, isDate, isValid, parse } from "date-fns";
1
+ import { addYears, format, formatISO, isDate, isValid } from "date-fns";
2
2
  import * as locales from "date-fns/locale";
3
3
  import { formatInTimeZone } from "date-fns-tz";
4
4
  import { useCoreConfig } from "#core/composables/useConfig";
@@ -27,7 +27,7 @@ export class TimeHelper {
27
27
  };
28
28
  static displayDate = (time) => {
29
29
  if (!time) {
30
- return time;
30
+ return null;
31
31
  }
32
32
  const parsedTime = getTime(time);
33
33
  const newTime = TimeHelper.thaiFormat(parsedTime, dateFormatDisplay);
@@ -35,7 +35,7 @@ export class TimeHelper {
35
35
  };
36
36
  static displayDateTime = (time) => {
37
37
  if (!time) {
38
- return time;
38
+ return null;
39
39
  }
40
40
  const parsedTime = getTime(time);
41
41
  const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormatDisplay);
@@ -43,7 +43,7 @@ export class TimeHelper {
43
43
  };
44
44
  static displayDateThai = (time) => {
45
45
  if (!time) {
46
- return time;
46
+ return null;
47
47
  }
48
48
  const parsedTime = getTime(time);
49
49
  const newTime = TimeHelper.thaiFormat(parsedTime, dateFormat, true);
@@ -51,7 +51,7 @@ export class TimeHelper {
51
51
  };
52
52
  static displayDateTimeThai = (time) => {
53
53
  if (!time) {
54
- return time;
54
+ return null;
55
55
  }
56
56
  const parsedTime = getTime(time);
57
57
  const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormat, true);
@@ -60,8 +60,8 @@ export class TimeHelper {
60
60
  static displayDateRange = (startDate, endDate) => {
61
61
  if (!startDate || !endDate) {
62
62
  return {
63
- startDate,
64
- endDate
63
+ startDate: startDate || null,
64
+ endDate: endDate || null
65
65
  };
66
66
  }
67
67
  const parsedStartDate = getTime(startDate);
@@ -75,11 +75,11 @@ export class TimeHelper {
75
75
  };
76
76
  static toUTC = (time) => {
77
77
  if (!time) {
78
- return time;
78
+ return null;
79
79
  }
80
80
  try {
81
81
  const parsedTime = getTime(time);
82
- const newTime = formatInTimeZone(parsedTime, "Zulu", dateTimeFormat);
82
+ const newTime = formatInTimeZone(parsedTime, "UTC", dateTimeFormat);
83
83
  return isValid(parsedTime) ? newTime : time;
84
84
  } catch (e) {
85
85
  return time.toString();
@@ -87,7 +87,7 @@ export class TimeHelper {
87
87
  };
88
88
  static toLocal = (time) => {
89
89
  if (!time) {
90
- return time;
90
+ return null;
91
91
  }
92
92
  try {
93
93
  const parsedTime = getTime(time);
@@ -102,27 +102,30 @@ export class TimeHelper {
102
102
  };
103
103
  static getDateFormTime = (time, customFormat = dateFormat) => {
104
104
  if (!time) {
105
- return time;
105
+ return null;
106
106
  }
107
- const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
107
+ const parsedTime = isDate(time) ? time : getTime(time);
108
108
  const newTime = format(parsedTime, customFormat);
109
109
  return isValid(parsedTime) ? newTime : time;
110
110
  };
111
111
  static getDateFormTimeWithLocal = (time, customFormat = dateFormat) => {
112
112
  if (!time) {
113
- return time;
113
+ return null;
114
114
  }
115
115
  const localTime = TimeHelper.toLocal(time);
116
- const parsedTime = isDate(localTime) ? localTime : parse(localTime, dateTimeFormat, /* @__PURE__ */ new Date());
116
+ if (!localTime) {
117
+ return null;
118
+ }
119
+ const parsedTime = isDate(localTime) ? localTime : getTime(time);
117
120
  const newTime = format(parsedTime, customFormat);
118
121
  return isValid(parsedTime) ? newTime : time;
119
122
  };
120
123
  static getISODateTimeFormTime = (time) => {
121
124
  if (!time) {
122
- return time;
125
+ return null;
123
126
  }
124
127
  try {
125
- const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
128
+ const parsedTime = isDate(time) ? time : new Date(time);
126
129
  const testTime = format(parsedTime, dateTimeFormat);
127
130
  if (!isValid(parsedTime) || testTime === "Invalid Date") {
128
131
  return time;
@@ -134,21 +137,31 @@ export class TimeHelper {
134
137
  };
135
138
  static getDateTimeFormTime = (time) => {
136
139
  if (!time) {
137
- return time;
140
+ return null;
138
141
  }
139
- const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
142
+ const parsedTime = isDate(time) ? time : getTime(time);
140
143
  const newTime = format(parsedTime, dateTimeFormat);
141
144
  return isValid(parsedTime) ? newTime : time;
142
145
  };
143
146
  static getTimeFormTime = (time) => {
144
147
  if (!time) {
145
- return time;
148
+ return null;
146
149
  }
147
- const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
150
+ const parsedTime = isDate(time) ? time : getTime(time);
148
151
  const newTime = format(parsedTime, timeFormat);
149
152
  return isValid(parsedTime) ? newTime : time;
150
153
  };
151
154
  static getCurrentDateTime = () => {
152
155
  return format(/* @__PURE__ */ new Date(), dateTimeFormat);
153
156
  };
157
+ static toDate = (str) => {
158
+ if (!str) {
159
+ return null;
160
+ }
161
+ if (isDate(str)) {
162
+ return str;
163
+ }
164
+ const parsedTime = new Date(str);
165
+ return isValid(parsedTime) ? parsedTime : null;
166
+ };
154
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.42.3",
3
+ "version": "2.43.1",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",