@finema/core 2.38.0 → 2.39.0

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.38.0",
3
+ "version": "2.39.0",
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.38.0";
7
+ const version = "2.39.0";
8
8
 
9
9
  const nuxtAppOptions = {
10
10
  head: {
@@ -1,7 +1,9 @@
1
1
  export declare class TimeHelper {
2
- static thaiFormat: (dateStr: Date, formatStr: string) => string;
2
+ static thaiFormat: (dateStr: Date, formatStr: string, forceThai?: boolean) => string;
3
3
  static displayDate: (time: string | Date) => string;
4
4
  static displayDateTime: (time: string | Date) => string;
5
+ static displayDateThai: (time: string | Date) => string;
6
+ static displayDateTimeThai: (time: string | Date) => string;
5
7
  static displayDateRange: (startDate: Date | string, endDate: Date | string) => {
6
8
  startDate: Date | string;
7
9
  endDate: Date | string;
@@ -14,13 +14,13 @@ const getTime = (time) => {
14
14
  return isDate(time) ? time : new Date(time);
15
15
  };
16
16
  export class TimeHelper {
17
- static thaiFormat = (dateStr, formatStr) => {
17
+ static thaiFormat = (dateStr, formatStr, forceThai = false) => {
18
18
  let newDateStr = dateStr;
19
19
  const options = {};
20
- if (isThaiYear) {
20
+ if (isThaiYear || forceThai) {
21
21
  newDateStr = addYears(dateStr, 543);
22
22
  }
23
- if (isThaiMonth) {
23
+ if (isThaiMonth || forceThai) {
24
24
  options.locale = locales.th;
25
25
  }
26
26
  return formatInTimeZone(newDateStr, timeZone, formatStr, options);
@@ -41,6 +41,22 @@ export class TimeHelper {
41
41
  const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormatDisplay);
42
42
  return isValid(parsedTime) ? newTime : time;
43
43
  };
44
+ static displayDateThai = (time) => {
45
+ if (!time) {
46
+ return time;
47
+ }
48
+ const parsedTime = getTime(time);
49
+ const newTime = TimeHelper.thaiFormat(parsedTime, dateFormat, true);
50
+ return isValid(parsedTime) ? newTime : time;
51
+ };
52
+ static displayDateTimeThai = (time) => {
53
+ if (!time) {
54
+ return time;
55
+ }
56
+ const parsedTime = getTime(time);
57
+ const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormat, true);
58
+ return isValid(parsedTime) ? newTime : time;
59
+ };
44
60
  static displayDateRange = (startDate, endDate) => {
45
61
  if (!startDate || !endDate) {
46
62
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.38.0",
3
+ "version": "2.39.0",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",