80 lines
1.8 KiB
TypeScript
80 lines
1.8 KiB
TypeScript
import { UserStore } from '@store'
|
|
import { date } from 'quasar'
|
|
|
|
export const toolsext = {
|
|
getLocale(vero?: boolean) {
|
|
if (UserStore) {
|
|
if (UserStore.state) {
|
|
return UserStore.state.lang
|
|
}
|
|
}
|
|
return process.env.LANG_DEFAULT
|
|
},
|
|
isLang(whichlang) {
|
|
const loc = func_tools.getLocale()
|
|
return (loc === whichlang)
|
|
}
|
|
}
|
|
|
|
export const func_tools = {
|
|
getLocale(vero?: boolean) {
|
|
if (UserStore) {
|
|
if (UserStore.state) {
|
|
return UserStore.state.lang
|
|
}
|
|
}
|
|
return ''
|
|
},
|
|
|
|
getDateStr(mydate) {
|
|
const DateFormatter = new Intl.DateTimeFormat(func_tools.getLocale() || void 0, {
|
|
weekday: 'short',
|
|
day: 'numeric',
|
|
month: 'long',
|
|
year: 'numeric'
|
|
// timeZone: 'UTC'
|
|
})
|
|
if (DateFormatter) {
|
|
const date1 = new Date(mydate)
|
|
return DateFormatter.format(date1)
|
|
}
|
|
return mydate
|
|
},
|
|
|
|
hasManyDays(mydatestart, mydateend) {
|
|
if (mydateend)
|
|
return this.getDateStr(mydatestart) !== this.getDateStr(mydateend)
|
|
else
|
|
return false
|
|
},
|
|
|
|
getMinutesDuration(mydatestart, mydateend) {
|
|
return date.getDateDiff(mydateend, mydatestart, 'minutes')
|
|
},
|
|
|
|
getDateTimeShortStr(mydate) {
|
|
const DateFormatter = new Intl.DateTimeFormat(func_tools.getLocale() || void 0, {
|
|
hour: 'numeric',
|
|
minute: 'numeric',
|
|
day: 'numeric',
|
|
month: 'short'
|
|
// timeZone: 'UTC'
|
|
})
|
|
if (DateFormatter) {
|
|
const date = new Date(mydate)
|
|
return DateFormatter.format(date)
|
|
}
|
|
return mydate
|
|
}
|
|
}
|
|
|
|
// export const costanti_tools = {
|
|
// DateFormatter: new Intl.DateTimeFormat(func_tools.getLocale() || void 0, {
|
|
// weekday: 'long',
|
|
// day: 'numeric',
|
|
// month: 'long',
|
|
// year: 'numeric'
|
|
// // timeZone: 'UTC'
|
|
// })
|
|
// }
|