secullum-react-native-ui 4.6.0 → 4.6.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/lib/modules/format.js +16 -0
- package/package.json +1 -1
package/lib/modules/format.js
CHANGED
|
@@ -95,6 +95,22 @@ const fixSpanishLowercase = (formattedDate) => {
|
|
|
95
95
|
return formattedDate;
|
|
96
96
|
};
|
|
97
97
|
const formatDate = (date, format) => {
|
|
98
|
+
if (typeof date === 'string') {
|
|
99
|
+
// case 135870 - Acontecia casos onde a data/horas estavam sendo alteradas pois o react-native assume o fuso sempre como '00:00',
|
|
100
|
+
// para que isso não aconteça, se a data for do tipo string o fuso horario será adicionado na data para que não tenha alteração.
|
|
101
|
+
// A regex busca datas no formato "yyyy-MM-DDTHH:mm:ss", podendo ter ou não milisegundos, mas sem fuso horário informado.
|
|
102
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?$/.test(date)) {
|
|
103
|
+
const timezoneOffset = new Date().getTimezoneOffset();
|
|
104
|
+
const hours = Math.floor(Math.abs(timezoneOffset) / 60);
|
|
105
|
+
const minutes = Math.abs(timezoneOffset) % 60;
|
|
106
|
+
const sign = timezoneOffset > 0 ? '-' : '+';
|
|
107
|
+
const timezone = sign +
|
|
108
|
+
hours.toString().padStart(2, '0') +
|
|
109
|
+
':' +
|
|
110
|
+
minutes.toString().padStart(2, '0');
|
|
111
|
+
date = date + timezone;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
98
114
|
const formattedDate = (0, date_fns_1.format)(typeof date === 'string' ? new Date(date) : date, format, {
|
|
99
115
|
locale: (0, exports.getDateFnsLocale)()
|
|
100
116
|
});
|