12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import moment from 'moment'
- function date2s (date) {
- return moment(date).format('DD.MM.')
- }
- function time2s (date) {
- return moment(date).format('HH:mm')
- }
- function datetime2s (date) {
- return moment(date).format('DD.MM. HH:mm')
- }
- function sortTable (array, columns) {
- function compare (item1, item2) {
- if (item1 instanceof Date) {
- }
- }
- }
- function normalize (item, type) {
- return item ? String(item).replace(/\s+/g, ' ').trim() : null
- }
- function normalizePhone (item) {
- let phone = String(item).replace(/\s|\+|\/|,|-|'/g, '').replace(/\(0\)/, '').replace(/^0+/, '')
- if (phone.match(/[^\d*]/)) {
- return `FEHLER (nicht-numerische Zeichen): ${phone}`
- }
- if (phone.length === 0) {
- return null
- } else if (phone.length === 9) {
- // Assume swiss number
- phone = `+41${phone}`
- } else if (phone.length === 11) {
- phone = `+${phone}`
- } else {
- return `FEHLER (falsche Länge): ${phone}`
- }
- return phone
- }
- export { date2s, time2s, datetime2s, sortTable, normalize, normalizePhone }
|