feat: add cron desc #59
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import cronstrue from 'cronstrue'
|
||||
import 'cronstrue/locales/zh_CN'
|
||||
|
||||
export function getCronDescription(cron: string, lang?: string) {
|
||||
if (!cron || cron.trim() === '') return ''
|
||||
try {
|
||||
const locale = lang?.startsWith('en') ? 'en' : 'zh_CN'
|
||||
return cronstrue.toString(cron, {
|
||||
locale,
|
||||
use24HourTimeFormat: true,
|
||||
throwExceptionOnParseError: true,
|
||||
})
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user