validator.js 461 Bytes
Newer Older
陈浩玮's avatar
陈浩玮 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// import CronParser from 'cron-parser'
export const WEEK_MAP_EN = {
    'sun': '0',
    'mon': '1',
    'tue': '2',
    'wed': '3',
    'thu': '4',
    'fri': '5',
    'sat': '6',
    
  }
  
export const replaceWeekName = (c) => {
    if (c) {
        c = c.toLowerCase()
        Object.keys(WEEK_MAP_EN).forEach(k => {
        c = c.replace(new RegExp(k, 'g'), WEEK_MAP_EN[k])
        })
        c = c.replace(new RegExp('7', 'g'), '0')
    }
    return c
}