@stbmoz-onboarding/core 1.0.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/Dates/DateFormater.js +21 -0
- package/Dates/DateValidator.js +12 -0
- package/Dates/index.js +5 -0
- package/index.js +4 -0
- package/package.json +12 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default function DateFormater(date, format) {
|
|
2
|
+
try {
|
|
3
|
+
const months = ['Janeiro', 'Fevereiro', 'Marco', 'Abril', 'Maio', 'Junho',
|
|
4
|
+
'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
|
|
5
|
+
|
|
6
|
+
let dateObj = new Date(date)
|
|
7
|
+
const day = dateObj.getDate()
|
|
8
|
+
const month = dateObj.getMonth()
|
|
9
|
+
const year = dateObj.getFullYear()
|
|
10
|
+
|
|
11
|
+
if (format == 'long') {
|
|
12
|
+
return `${months[month]} ${day}, ${year}`
|
|
13
|
+
}
|
|
14
|
+
if (format == 'short') {
|
|
15
|
+
return `${months[month]} ${day}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return date
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function ValidateDate(values, key, errors, invalidDateMsg) {
|
|
2
|
+
try {
|
|
3
|
+
const date = new Date(values[key])
|
|
4
|
+
if (date == "Invalid Date") {
|
|
5
|
+
errors[key] = invalidDateMsg
|
|
6
|
+
} else {
|
|
7
|
+
values[key] = date
|
|
8
|
+
}
|
|
9
|
+
} catch (error) {
|
|
10
|
+
errors[key] = invalidDateMsg
|
|
11
|
+
}
|
|
12
|
+
}
|
package/Dates/index.js
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stbmoz-onboarding/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "\"core module\"",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"publish": "npm publish --access public"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|