jcinfo-utils 1.0.14 → 1.0.15
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/index.d.ts +4 -0
- package/index.js +15 -0
- package/package.json +5 -2
- package/testar.js +28 -11
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -219,12 +219,27 @@ function formatValor(valor = 0, decimalScale = 2, money = true) {
|
|
|
219
219
|
}).format(valor)
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
function formatData(data = new Date()) {
|
|
223
|
+
return Intl.DateTimeFormat('pt-br', { dateStyle: 'short' }).format(data)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function formatDataHora(data = new Date()) {
|
|
227
|
+
let result = Intl.DateTimeFormat('pt-br', {
|
|
228
|
+
dateStyle: 'short',
|
|
229
|
+
timeStyle: 'short',
|
|
230
|
+
}).format(data)
|
|
231
|
+
result = result.split(', ').join(' ')
|
|
232
|
+
return result
|
|
233
|
+
}
|
|
234
|
+
|
|
222
235
|
export {
|
|
223
236
|
addLog,
|
|
224
237
|
addUserSelectNoneInMobile,
|
|
225
238
|
calcularIdade,
|
|
226
239
|
colorGain,
|
|
227
240
|
formatValor,
|
|
241
|
+
formatData,
|
|
242
|
+
formatDataHora,
|
|
228
243
|
getDateStr,
|
|
229
244
|
getDateTimeStr,
|
|
230
245
|
getFirstDay,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jcinfo-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Pacote de funções utilitárias",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,5 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"keywords": [],
|
|
11
11
|
"author": "JC",
|
|
12
|
-
"license": "ISC"
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"nodemon": "^3.0.1"
|
|
15
|
+
}
|
|
13
16
|
}
|
package/testar.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
import * as jc from './index.js'
|
|
1
|
+
// import * as jc from './index.js'
|
|
2
2
|
|
|
3
|
-
console.log(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
3
|
+
// console.log(
|
|
4
|
+
// jc.formatValor(123, 3, false),
|
|
5
|
+
// jc.formatData(new Date(1973, 8, 19)),
|
|
6
|
+
// jc.calcularIdade('2023-07-24', '1973-09-19'),
|
|
7
|
+
// jc.getDateStr(),
|
|
8
|
+
// jc.getDateTimeStr(),
|
|
9
|
+
// jc.getFirstDay(),
|
|
10
|
+
// jc.getLastDay,
|
|
11
|
+
// jc.getMonthName(new Date().getMonth()),
|
|
12
|
+
// jc.trunc(123.99889889),
|
|
13
|
+
// )
|
|
14
|
+
function formatData(data = new Date()) {
|
|
15
|
+
return Intl.DateTimeFormat('pt-br', { dateStyle: 'short' }).format(data)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function formatDataHora(data = new Date()) {
|
|
19
|
+
let result = Intl.DateTimeFormat('pt-br', {
|
|
20
|
+
dateStyle: 'short',
|
|
21
|
+
timeStyle: 'short',
|
|
22
|
+
}).format(data)
|
|
23
|
+
result = result.split(', ').join(' ')
|
|
24
|
+
return result
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let data = new Date(1973, 8, 19, 2, 15, 45, 123)
|
|
28
|
+
console.log(formatData(data))
|
|
29
|
+
console.log(formatDataHora(data))
|