Update datetimeformat
This commit is contained in:
@@ -904,6 +904,11 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
}
|
||||
return out
|
||||
}
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'datetimeformat':{
|
||||
return dateTimeFormat(arra[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
if(p1.startsWith('random')){
|
||||
@@ -957,8 +962,17 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
return (Math.floor(Math.random() * maxRoll) + 1).toString()
|
||||
}
|
||||
if(p1.startsWith('datetimeformat')){
|
||||
const date = new Date()
|
||||
let main = p1.substring("datetimeformat".length + 1)
|
||||
return dateTimeFormat(main)
|
||||
}
|
||||
return null
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const dateTimeFormat = (main:string) => {
|
||||
const date = new Date()
|
||||
if(!main){
|
||||
return ''
|
||||
}
|
||||
@@ -975,13 +989,11 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
.replace(/hh?/g, (date.getHours() % 12).toString().padStart(2, '0'))
|
||||
.replace(/mm?/g, date.getMinutes().toString().padStart(2, '0'))
|
||||
.replace(/ss?/g, date.getSeconds().toString().padStart(2, '0'))
|
||||
.replace(/X?/g, (Date.now() / 1000).toFixed(2))
|
||||
.replace(/x?/g, Date.now().toFixed())
|
||||
.replace(/A/g, date.getHours() >= 12 ? 'PM' : 'AM')
|
||||
.replace(/MMMM?/g, Intl.DateTimeFormat('en', { month: 'long' }).format(date))
|
||||
}
|
||||
return null
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const smMatcher = (p1:string,matcherArg:matcherArg) => {
|
||||
|
||||
Reference in New Issue
Block a user