native-pytech 1.0.29 → 1.0.31

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.
@@ -3,8 +3,9 @@ declare const Formats: {
3
3
  numberToText: (value: number) => string;
4
4
  TextToNumber: (value: string) => number;
5
5
  numberToTextCurrency: typeof numberToTextCurrency;
6
- dateToText: (value: string) => string;
7
6
  capitalizeText: (string: string) => string;
8
7
  phoneToText: (phone: number | string) => string;
8
+ dateToText: (value: string) => string;
9
+ dateToTextFormat: (date: Date, format?: string) => string;
9
10
  };
10
11
  export default Formats;
@@ -66,13 +66,29 @@ const phoneToText = (phone) => {
66
66
  }
67
67
  return extra ? `${base}${extra}` : base;
68
68
  };
69
+ const dateToTextFormat = (date, format = "YYYY-MM-DD") => {
70
+ const parts = new Intl.DateTimeFormat('en-CA', {
71
+ timeZone: 'America/Argentina/Buenos_Aires',
72
+ year: 'numeric',
73
+ month: '2-digit',
74
+ day: '2-digit',
75
+ }).formatToParts(date);
76
+ const year = parts.find((part) => part.type === 'year')?.value ?? '';
77
+ const month = parts.find((part) => part.type === 'month')?.value ?? '';
78
+ const day = parts.find((part) => part.type === 'day')?.value ?? '';
79
+ return format
80
+ .replace('YYYY', year)
81
+ .replace('MM', month)
82
+ .replace('DD', day);
83
+ };
69
84
  // ------------------- Export -------------------
70
85
  const Formats = {
71
86
  numberToText,
72
87
  TextToNumber,
73
88
  numberToTextCurrency,
74
- dateToText,
75
89
  capitalizeText,
76
90
  phoneToText,
91
+ dateToText,
92
+ dateToTextFormat,
77
93
  };
78
94
  export default Formats;
@@ -19,7 +19,7 @@ export default memo(({ label, defaultValue, minDate = new Date(new Date().setFul
19
19
  setSelection(value);
20
20
  store.values[index].set({
21
21
  value: value,
22
- hasChanged: value !== defaultValue,
22
+ hasChanged: value.getTime() !== defaultValue?.getTime(),
23
23
  isValid: true,
24
24
  });
25
25
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",