native-pytech 1.0.217 → 1.0.218
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,6 +3,7 @@ declare const Formats: {
|
|
|
3
3
|
numberToText: (value: number) => string;
|
|
4
4
|
TextToNumber: (value: string) => number;
|
|
5
5
|
textToDate: (value?: string) => Date | undefined;
|
|
6
|
+
textHourToDate: (value?: string) => Date | undefined;
|
|
6
7
|
numberToTextCurrency: typeof numberToTextCurrency;
|
|
7
8
|
capitalizeText: (string: string) => string;
|
|
8
9
|
phoneToText: (phone: number | string) => string;
|
|
@@ -24,6 +24,28 @@ const textToDate = (value) => {
|
|
|
24
24
|
: new Date(value);
|
|
25
25
|
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
26
26
|
};
|
|
27
|
+
const textHourToDate = (value) => {
|
|
28
|
+
if (!value)
|
|
29
|
+
return undefined;
|
|
30
|
+
const match = value.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);
|
|
31
|
+
if (!match)
|
|
32
|
+
return undefined;
|
|
33
|
+
const hours = Number(match[1]);
|
|
34
|
+
const minutes = Number(match[2]);
|
|
35
|
+
const seconds = Number(match[3] ?? 0);
|
|
36
|
+
if (hours > 23 || minutes > 59 || seconds > 59)
|
|
37
|
+
return undefined;
|
|
38
|
+
const today = new Intl.DateTimeFormat('en-CA', {
|
|
39
|
+
timeZone: 'America/Argentina/Buenos_Aires',
|
|
40
|
+
}).format(new Date());
|
|
41
|
+
const time = [
|
|
42
|
+
String(hours).padStart(2, '0'),
|
|
43
|
+
String(minutes).padStart(2, '0'),
|
|
44
|
+
String(seconds).padStart(2, '0'),
|
|
45
|
+
].join(':');
|
|
46
|
+
const date = new Date(`${today}T${time}-03:00`);
|
|
47
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
48
|
+
};
|
|
27
49
|
function numberToTextCurrency(value) {
|
|
28
50
|
return new Intl.NumberFormat('es-AR', {
|
|
29
51
|
style: 'currency',
|
|
@@ -81,6 +103,7 @@ const Formats = {
|
|
|
81
103
|
numberToText,
|
|
82
104
|
TextToNumber,
|
|
83
105
|
textToDate,
|
|
106
|
+
textHourToDate,
|
|
84
107
|
numberToTextCurrency,
|
|
85
108
|
capitalizeText,
|
|
86
109
|
phoneToText,
|