爱意满满的作品展示区。
ikesnowy

一个生成 cron 中文描述的 JS 库

  •  1
     
  •   ikesnowy ·
    ikesnowy · Oct 16, 2022 · 2927 views
    This topic created in 1331 days ago, the information mentioned may be changed or developed.

    好像没有找到特别合适的库,只能自己随便撸一个了,下面是一些例子:

    humanizeCronInChinese('* * * * *'); // 每分钟
    humanizeCronInChinese('0 0 * * *'); // 每日 00:00
    humanizeCronInChinese('0 0 1 * *'); // 每月 1 日 00:00
    humanizeCronInChinese('*/2 * * * *'); // 每隔 2 分钟
    humanizeCronInChinese('45 4 1,10,20 * *') // 每月 1,10,20 日 04:45
    humanizeCronInChinese('0 0 * * 1-5') // 每周一~周五 00:00
    

    https://github.com/ikesnowy/cron-chinese

    征集一些奇怪的 cron 测试用例 hhhh

    8 replies    2022-10-17 23:12:14 +08:00
    panlatent
        1
    panlatent  
       Oct 16, 2022 via iPhone
    有个 C# 库是做这个的,支持国际化。我移植过它的 PHP 版本。
    steins2628
        2
    steins2628  
       Oct 16, 2022
    cronstrue 其实支持类似的国际化,不过楼主这个也不错
    pigmen
        3
    pigmen  
       Oct 16, 2022
    kkeep
        4
    kkeep  
       Oct 17, 2022 via Android
    crintab.guru
    flashBee233
        5
    flashBee233  
       Oct 17, 2022
    测试了 3 楼的,确实可以实现楼主的需求
    ikesnowy
        6
    ikesnowy  
    OP
       Oct 17, 2022
    @flashBee233

    这个我看过,当时试了试他们的 demo ,然后就看到了这个……

    https://v2ex.com/i/zF877V73.png

    然后就决定还是自己写了,语序还能好一点。
    alanhe421
        7
    alanhe421  
       Oct 17, 2022   ❤️ 1
    @kkeep typo
    正确网址是: https://crontab.guru/,不错,👍
    kkeep
        8
    kkeep  
       Oct 17, 2022 via Android
    @18519017871 对。手机打的没注意
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1187 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 17:50 · PVG 01:50 · LAX 10:50 · JFK 13:50
    ♥ Do have faith in what you're doing.