├── .editorconfig ├── .github ├── FUNDING.yml ├── semantic.yml └── workflows │ └── ci.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── licenserc.toml ├── rust-toolchain.toml ├── rustfmt.toml ├── src ├── lib.rs ├── parser.rs └── snapshots │ ├── cronexpr__parser__tests__crontab_guru_examples-10.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-11.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-12.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-13.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-14.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-15.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-16.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-17.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-18.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-19.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-2.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-20.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-21.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-22.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-23.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-24.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-25.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-26.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-27.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-28.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-29.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-3.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-30.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-31.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-32.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-33.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-34.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-35.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-36.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-37.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-38.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-39.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-4.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-40.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-5.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-6.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-7.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-8.snap │ ├── cronexpr__parser__tests__crontab_guru_examples-9.snap │ ├── cronexpr__parser__tests__crontab_guru_examples.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-10.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-11.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-12.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-13.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-14.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-15.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-16.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-17.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-18.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-19.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-2.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-20.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-21.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-22.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-23.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-24.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-25.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-3.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-4.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-5.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-6.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-7.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-8.snap │ ├── cronexpr__parser__tests__parse_crontab_failed-9.snap │ ├── cronexpr__parser__tests__parse_crontab_failed.snap │ ├── cronexpr__parser__tests__parse_crontab_success-10.snap │ ├── cronexpr__parser__tests__parse_crontab_success-11.snap │ ├── cronexpr__parser__tests__parse_crontab_success-12.snap │ ├── cronexpr__parser__tests__parse_crontab_success-13.snap │ ├── cronexpr__parser__tests__parse_crontab_success-14.snap │ ├── cronexpr__parser__tests__parse_crontab_success-15.snap │ ├── cronexpr__parser__tests__parse_crontab_success-16.snap │ ├── cronexpr__parser__tests__parse_crontab_success-17.snap │ ├── cronexpr__parser__tests__parse_crontab_success-2.snap │ ├── cronexpr__parser__tests__parse_crontab_success-3.snap │ ├── cronexpr__parser__tests__parse_crontab_success-4.snap │ ├── cronexpr__parser__tests__parse_crontab_success-5.snap │ ├── cronexpr__parser__tests__parse_crontab_success-6.snap │ ├── cronexpr__parser__tests__parse_crontab_success-7.snap │ ├── cronexpr__parser__tests__parse_crontab_success-8.snap │ ├── cronexpr__parser__tests__parse_crontab_success-9.snap │ └── cronexpr__parser__tests__parse_crontab_success.snap ├── taplo.toml └── typos.toml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | indent_style = space 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | 9 | [*.toml] 10 | indent_size = tab 11 | tab_width = 2 12 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | github: tisonkun 16 | -------------------------------------------------------------------------------- /.github/semantic.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # The pull request's title should be fulfilled the following pattern: 16 | # 17 | # [optional scope]: 18 | # 19 | # ... where valid types and scopes can be found below; for example: 20 | # 21 | # build(maven): One level down for native profile 22 | # 23 | # More about configurations on https://github.com/Ezard/semantic-prs#configuration 24 | 25 | enabled: true 26 | 27 | titleOnly: true 28 | 29 | types: 30 | - feat 31 | - fix 32 | - docs 33 | - style 34 | - refactor 35 | - perf 36 | - test 37 | - build 38 | - ci 39 | - chore 40 | - revert 41 | 42 | targetUrl: https://github.com/cratesland/cronexpr/blob/main/.github/semantic.yml 43 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: CI 16 | on: 17 | pull_request: 18 | branches: [ main ] 19 | push: 20 | branches: [ main ] 21 | 22 | # Concurrency strategy: 23 | # github.workflow: distinguish this workflow from others 24 | # github.event_name: distinguish `push` event from `pull_request` event 25 | # github.event.number: set to the number of the pull request if `pull_request` event 26 | # github.run_id: otherwise, it's a `push` event, only cancel if we rerun the workflow 27 | # 28 | # Reference: 29 | # https://docs.github.com/en/actions/using-jobs/using-concurrency 30 | # https://docs.github.com/en/actions/learn-github-actions/contexts#github-context 31 | concurrency: 32 | group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }} 33 | cancel-in-progress: true 34 | 35 | jobs: 36 | check: 37 | name: Check 38 | runs-on: ubuntu-latest 39 | steps: 40 | - uses: actions/checkout@v4 41 | - name: Install toolchain 42 | uses: dtolnay/rust-toolchain@nightly 43 | with: 44 | components: rustfmt,clippy 45 | - uses: Swatinem/rust-cache@v2 46 | - uses: taiki-e/install-action@v2 47 | with: 48 | tool: typos-cli,taplo-cli,hawkeye 49 | - name: Check all 50 | run: | 51 | hawkeye check 52 | taplo format --check 53 | typos 54 | cargo +nightly fmt --all 55 | cargo +nightly clippy --all-targets --all-features -- -D warnings 56 | 57 | test: 58 | name: Run tests 59 | runs-on: ubuntu-latest 60 | strategy: 61 | matrix: 62 | rust-version: [ "1.80.0", "stable" ] 63 | steps: 64 | - uses: actions/checkout@v4 65 | - uses: Swatinem/rust-cache@v2 66 | - name: Delete rust-toolchain.toml 67 | run: rm rust-toolchain.toml 68 | - name: Install toolchain 69 | uses: dtolnay/rust-toolchain@master 70 | with: 71 | toolchain: ${{ matrix.rust-version }} 72 | - name: Run unit tests 73 | run: cargo test --all-features -- --nocapture 74 | 75 | required: 76 | name: Required 77 | runs-on: ubuntu-latest 78 | if: ${{ always() }} 79 | needs: 80 | - check 81 | - test 82 | steps: 83 | - name: Guardian 84 | run: | 85 | if [[ ! ( \ 86 | "${{ needs.check.result }}" == "success" \ 87 | && "${{ needs.test.result }}" == "success" \ 88 | ) ]]; then 89 | echo "Required jobs haven't been completed successfully." 90 | exit -1 91 | fi 92 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "console" 16 | version = "0.15.10" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" 19 | dependencies = [ 20 | "encode_unicode", 21 | "libc", 22 | "once_cell", 23 | "windows-sys", 24 | ] 25 | 26 | [[package]] 27 | name = "cronexpr" 28 | version = "1.2.0" 29 | dependencies = [ 30 | "insta", 31 | "jiff", 32 | "thiserror", 33 | "winnow", 34 | ] 35 | 36 | [[package]] 37 | name = "encode_unicode" 38 | version = "1.0.0" 39 | source = "registry+https://github.com/rust-lang/crates.io-index" 40 | checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" 41 | 42 | [[package]] 43 | name = "insta" 44 | version = "1.42.1" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "71c1b125e30d93896b365e156c33dadfffab45ee8400afcbba4752f59de08a86" 47 | dependencies = [ 48 | "console", 49 | "linked-hash-map", 50 | "once_cell", 51 | "pin-project", 52 | "regex", 53 | "similar", 54 | ] 55 | 56 | [[package]] 57 | name = "jiff" 58 | version = "0.2.0" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "ba926fdd8e5b5e7f9700355b0831d8c416afe94b014b1023424037a187c9c582" 61 | dependencies = [ 62 | "jiff-tzdb-platform", 63 | "log", 64 | "portable-atomic", 65 | "portable-atomic-util", 66 | "serde", 67 | "windows-sys", 68 | ] 69 | 70 | [[package]] 71 | name = "jiff-tzdb" 72 | version = "0.1.2" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "cf2cec2f5d266af45a071ece48b1fb89f3b00b2421ac3a5fe10285a6caaa60d3" 75 | 76 | [[package]] 77 | name = "jiff-tzdb-platform" 78 | version = "0.1.2" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "a63c62e404e7b92979d2792352d885a7f8f83fd1d0d31eea582d77b2ceca697e" 81 | dependencies = [ 82 | "jiff-tzdb", 83 | ] 84 | 85 | [[package]] 86 | name = "libc" 87 | version = "0.2.169" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" 90 | 91 | [[package]] 92 | name = "linked-hash-map" 93 | version = "0.5.6" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" 96 | 97 | [[package]] 98 | name = "log" 99 | version = "0.4.25" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" 102 | 103 | [[package]] 104 | name = "memchr" 105 | version = "2.7.4" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 108 | 109 | [[package]] 110 | name = "once_cell" 111 | version = "1.20.2" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" 114 | 115 | [[package]] 116 | name = "pin-project" 117 | version = "1.1.8" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" 120 | dependencies = [ 121 | "pin-project-internal", 122 | ] 123 | 124 | [[package]] 125 | name = "pin-project-internal" 126 | version = "1.1.8" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" 129 | dependencies = [ 130 | "proc-macro2", 131 | "quote", 132 | "syn", 133 | ] 134 | 135 | [[package]] 136 | name = "portable-atomic" 137 | version = "1.10.0" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" 140 | 141 | [[package]] 142 | name = "portable-atomic-util" 143 | version = "0.2.4" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" 146 | dependencies = [ 147 | "portable-atomic", 148 | ] 149 | 150 | [[package]] 151 | name = "proc-macro2" 152 | version = "1.0.93" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" 155 | dependencies = [ 156 | "unicode-ident", 157 | ] 158 | 159 | [[package]] 160 | name = "quote" 161 | version = "1.0.38" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" 164 | dependencies = [ 165 | "proc-macro2", 166 | ] 167 | 168 | [[package]] 169 | name = "regex" 170 | version = "1.11.1" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" 173 | dependencies = [ 174 | "aho-corasick", 175 | "memchr", 176 | "regex-automata", 177 | "regex-syntax", 178 | ] 179 | 180 | [[package]] 181 | name = "regex-automata" 182 | version = "0.4.9" 183 | source = "registry+https://github.com/rust-lang/crates.io-index" 184 | checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" 185 | dependencies = [ 186 | "aho-corasick", 187 | "memchr", 188 | "regex-syntax", 189 | ] 190 | 191 | [[package]] 192 | name = "regex-syntax" 193 | version = "0.8.5" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 196 | 197 | [[package]] 198 | name = "serde" 199 | version = "1.0.217" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" 202 | dependencies = [ 203 | "serde_derive", 204 | ] 205 | 206 | [[package]] 207 | name = "serde_derive" 208 | version = "1.0.217" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" 211 | dependencies = [ 212 | "proc-macro2", 213 | "quote", 214 | "syn", 215 | ] 216 | 217 | [[package]] 218 | name = "similar" 219 | version = "2.7.0" 220 | source = "registry+https://github.com/rust-lang/crates.io-index" 221 | checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" 222 | 223 | [[package]] 224 | name = "syn" 225 | version = "2.0.96" 226 | source = "registry+https://github.com/rust-lang/crates.io-index" 227 | checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" 228 | dependencies = [ 229 | "proc-macro2", 230 | "quote", 231 | "unicode-ident", 232 | ] 233 | 234 | [[package]] 235 | name = "thiserror" 236 | version = "2.0.11" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" 239 | dependencies = [ 240 | "thiserror-impl", 241 | ] 242 | 243 | [[package]] 244 | name = "thiserror-impl" 245 | version = "2.0.11" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" 248 | dependencies = [ 249 | "proc-macro2", 250 | "quote", 251 | "syn", 252 | ] 253 | 254 | [[package]] 255 | name = "unicode-ident" 256 | version = "1.0.16" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" 259 | 260 | [[package]] 261 | name = "windows-sys" 262 | version = "0.59.0" 263 | source = "registry+https://github.com/rust-lang/crates.io-index" 264 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 265 | dependencies = [ 266 | "windows-targets", 267 | ] 268 | 269 | [[package]] 270 | name = "windows-targets" 271 | version = "0.52.6" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 274 | dependencies = [ 275 | "windows_aarch64_gnullvm", 276 | "windows_aarch64_msvc", 277 | "windows_i686_gnu", 278 | "windows_i686_gnullvm", 279 | "windows_i686_msvc", 280 | "windows_x86_64_gnu", 281 | "windows_x86_64_gnullvm", 282 | "windows_x86_64_msvc", 283 | ] 284 | 285 | [[package]] 286 | name = "windows_aarch64_gnullvm" 287 | version = "0.52.6" 288 | source = "registry+https://github.com/rust-lang/crates.io-index" 289 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 290 | 291 | [[package]] 292 | name = "windows_aarch64_msvc" 293 | version = "0.52.6" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 296 | 297 | [[package]] 298 | name = "windows_i686_gnu" 299 | version = "0.52.6" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 302 | 303 | [[package]] 304 | name = "windows_i686_gnullvm" 305 | version = "0.52.6" 306 | source = "registry+https://github.com/rust-lang/crates.io-index" 307 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 308 | 309 | [[package]] 310 | name = "windows_i686_msvc" 311 | version = "0.52.6" 312 | source = "registry+https://github.com/rust-lang/crates.io-index" 313 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 314 | 315 | [[package]] 316 | name = "windows_x86_64_gnu" 317 | version = "0.52.6" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 320 | 321 | [[package]] 322 | name = "windows_x86_64_gnullvm" 323 | version = "0.52.6" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 326 | 327 | [[package]] 328 | name = "windows_x86_64_msvc" 329 | version = "0.52.6" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 332 | 333 | [[package]] 334 | name = "winnow" 335 | version = "0.7.0" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" 338 | dependencies = [ 339 | "memchr", 340 | ] 341 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | [package] 16 | name = "cronexpr" 17 | version = "1.2.0" 18 | 19 | description = "A library to parse and drive the crontab expression." 20 | edition = "2021" 21 | homepage = "https://github.com/cratesland/cronexpr" 22 | license = "Apache-2.0" 23 | readme = "README.md" 24 | repository = "https://github.com/cratesland/cronexpr" 25 | rust-version = "1.80.0" 26 | 27 | [package.metadata.docs.rs] 28 | all-features = true 29 | rustdoc-args = ["--cfg", "docsrs"] 30 | 31 | [dependencies] 32 | jiff = { version = "0.2.0" } 33 | thiserror = { version = "2.0.11" } 34 | winnow = { version = "0.7.0" } 35 | 36 | [dev-dependencies] 37 | insta = { version = "1.41", features = ["filters"] } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Crontab Expression Parser and Driver 2 | 3 | [![Crates.io][crates-badge]][crates-url] 4 | [![Documentation][docs-badge]][docs-url] 5 | [![MSRV 1.80][msrv-badge]](https://www.whatrustisit.com) 6 | [![Apache 2.0 licensed][license-badge]][license-url] 7 | [![Build Status][actions-badge]][actions-url] 8 | 9 | [crates-badge]: https://img.shields.io/crates/v/cronexpr.svg 10 | [crates-url]: https://crates.io/crates/cronexpr 11 | [docs-badge]: https://docs.rs/cronexpr/badge.svg 12 | [msrv-badge]: https://img.shields.io/badge/MSRV-1.80-green?logo=rust 13 | [docs-url]: https://docs.rs/cronexpr 14 | [license-badge]: https://img.shields.io/crates/l/cronexpr 15 | [license-url]: LICENSE 16 | [actions-badge]: https://github.com/cratesland/cronexpr/workflows/CI/badge.svg 17 | [actions-url]:https://github.com/cratesland/cronexpr/actions?query=workflow%3ACI 18 | 19 | ## Overview 20 | 21 | A library to parse and drive the crontab expression. 22 | 23 | ## Documentation 24 | 25 | * [API documentation on docs.rs](https://docs.rs/cronexpr) 26 | 27 | ## Example 28 | 29 | Here is a quick example that shows how to parse a cron expression and drive it with a timestamp: 30 | 31 | ```rust 32 | use std::str::FromStr; 33 | use cronexpr::MakeTimestamp; 34 | 35 | fn main() { 36 | let crontab = cronexpr::parse_crontab("2 4 * * * Asia/Shanghai").unwrap(); 37 | 38 | // case 0. match timestamp 39 | assert!(crontab.matches("2024-09-24T04:02:00+08:00").unwrap()); 40 | assert!(!crontab.matches("2024-09-24T04:01:00+08:00").unwrap()); 41 | 42 | // case 1. find next timestamp with timezone 43 | assert_eq!( 44 | crontab 45 | .find_next("2024-09-24T10:06:52+08:00") 46 | .unwrap() 47 | .to_string(), 48 | "2024-09-25T04:02:00+08:00[Asia/Shanghai]" 49 | ); 50 | 51 | // case 2. iter over next timestamps without upper bound 52 | let iter = crontab.iter_after("2024-09-24T10:06:52+08:00").unwrap(); 53 | assert_eq!( 54 | iter 55 | .take(5) 56 | .map(|ts| ts.map(|ts| ts.to_string())) 57 | .collect::, cronexpr::Error>>() 58 | .unwrap(), 59 | vec![ 60 | "2024-09-25T04:02:00+08:00[Asia/Shanghai]", 61 | "2024-09-26T04:02:00+08:00[Asia/Shanghai]", 62 | "2024-09-27T04:02:00+08:00[Asia/Shanghai]", 63 | "2024-09-28T04:02:00+08:00[Asia/Shanghai]", 64 | "2024-09-29T04:02:00+08:00[Asia/Shanghai]", 65 | ] 66 | ); 67 | 68 | // case 3. iter over next timestamps with upper bound 69 | let iter = crontab.iter_after("2024-09-24T10:06:52+08:00").unwrap(); 70 | let end = MakeTimestamp::from_str("2024-10-01T00:00:00+08:00").unwrap(); 71 | assert_eq!( 72 | iter 73 | .take_while(|ts| ts.as_ref().map(|ts| ts.timestamp() < end.0).unwrap_or(true)) 74 | .map(|ts| ts.map(|ts| ts.to_string())) 75 | .collect::, cronexpr::Error>>() 76 | .unwrap(), 77 | vec![ 78 | "2024-09-25T04:02:00+08:00[Asia/Shanghai]", 79 | "2024-09-26T04:02:00+08:00[Asia/Shanghai]", 80 | "2024-09-27T04:02:00+08:00[Asia/Shanghai]", 81 | "2024-09-28T04:02:00+08:00[Asia/Shanghai]", 82 | "2024-09-29T04:02:00+08:00[Asia/Shanghai]", 83 | "2024-09-30T04:02:00+08:00[Asia/Shanghai]", 84 | ] 85 | ); 86 | } 87 | ``` 88 | 89 | ## Usage 90 | 91 | `cronexpr` is [on crates.io](https://crates.io/crates/cronexpr) and can be used by adding `cronexpr` to your dependencies in your project's `Cargo.toml`. Or more simply, just run `cargo add cronexpr`. 92 | 93 | ## Who is using `cronexpr`? 94 | 95 | The original purpose of this library is to be used in [supporting `CREATE JOB` in ScopeDB](https://docs.scopedb.io/reference/stmt-ddl/#create-job). 96 | 97 | If you are using `cronexpr` in your project, please feel free to open a PR to add your project to this list. 98 | 99 | ## Dependencies 100 | 101 | `cronexpr` depends on: 102 | 103 | * [jiff](https://docs.rs/jiff/) for all the datetime things. This is almost internal, except: 104 | * The timestamp returned is a `jiff::Zoned`, although you can treat it as something defined by `cronexpr`. 105 | * The input type `MakeTimestamp` is a wrapper of `jiff::Timestamp`, but it's defined by `cronexpr` and enables you create a Timestamp from a string, milliseconds, nanoseconds, and more, without directly depend on `jiff::Timestamp` (you can still depend on it if you'd like). 106 | * [thiserror](https://docs.rs/thiserror/) to define our `Error` type. This is a proc-macro that won't affect the lib's APIs. 107 | * [winnow](https://docs.rs/winnow/) for parsing the crontab expression. This is fully internal: you don't need to understand it. 108 | 109 | ## Minimum Rust version policy 110 | 111 | This crate is built against the latest stable release, and its minimum supported rustc version is 1.80.0. 112 | 113 | The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if cronexpr 1.0 requires Rust 1.20.0, then cronexpr 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, cronexpr 1.y for y > 0 may require a newer minimum version of Rust. 114 | 115 | ## License 116 | 117 | This project is licensed under [Apache License, Version 2.0](LICENSE). 118 | -------------------------------------------------------------------------------- /licenserc.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | headerPath = "Apache-2.0.txt" 16 | 17 | includes = ['**/*.proto', '**/*.rs', '**/*.yml', '**/*.yaml', '**/*.toml'] 18 | 19 | [properties] 20 | copyrightOwner = "tison " 21 | inceptionYear = 2024 22 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | [toolchain] 16 | channel = "stable" 17 | components = ["cargo", "rustfmt", "clippy", "rust-analyzer"] 18 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | comment_width = 120 16 | format_code_in_doc_comments = true 17 | group_imports = "StdExternalCrate" 18 | imports_granularity = "Item" 19 | wrap_comments = true 20 | -------------------------------------------------------------------------------- /src/parser.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2024 tison 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | use std::collections::BTreeSet; 16 | use std::collections::HashSet; 17 | use std::ops::RangeInclusive; 18 | 19 | use jiff::civil::Weekday; 20 | use winnow::ascii::dec_uint; 21 | use winnow::combinator::alt; 22 | use winnow::combinator::eof; 23 | use winnow::combinator::fail; 24 | use winnow::combinator::separated; 25 | use winnow::error::ContextError; 26 | use winnow::error::ErrMode; 27 | use winnow::error::FromExternalError; 28 | use winnow::stream::Stream; 29 | use winnow::token::take_while; 30 | use winnow::ModalParser; 31 | use winnow::ModalResult; 32 | use winnow::Parser; 33 | 34 | use crate::Crontab; 35 | use crate::Error; 36 | use crate::ParsedDaysOfMonth; 37 | use crate::ParsedDaysOfWeek; 38 | use crate::PossibleLiterals; 39 | use crate::PossibleValue; 40 | 41 | /// Determine the timezone to fallback when the timezone part is missing. 42 | /// 43 | /// See also examples in the [`parse_crontab_with`] documentation. 44 | #[non_exhaustive] 45 | #[derive(Debug, Copy, Clone)] 46 | pub enum FallbackTimezoneOption { 47 | /// Do not fall back to any timezone. This means the timezone part is required. 48 | None, 49 | /// Fall back to [the system timezone](jiff::tz::TimeZone::system). 50 | System, 51 | /// Fall back to [`UTC`](jiff::tz::TimeZone::UTC). 52 | UTC, 53 | } 54 | 55 | /// Options to manipulate the parsing manner. 56 | /// 57 | /// See also examples in the [`parse_crontab_with`] documentation. 58 | #[non_exhaustive] 59 | #[derive(Debug, Copy, Clone)] 60 | pub struct ParseOptions { 61 | /// Whether fallback to a certain timezone when the timezone part is missing. 62 | /// 63 | /// Default to [`FallbackTimezoneOption::None`]. 64 | pub fallback_timezone_option: FallbackTimezoneOption, 65 | 66 | /// The hashed value to replace `H` in the crontab expression. If [`None`], `H` is not allowed. 67 | /// 68 | /// Default to [`None`]. 69 | pub hashed_value: Option, 70 | } 71 | 72 | impl Default for ParseOptions { 73 | fn default() -> Self { 74 | ParseOptions { 75 | fallback_timezone_option: FallbackTimezoneOption::None, 76 | hashed_value: None, 77 | } 78 | } 79 | } 80 | 81 | #[derive(Debug, Copy, Clone)] 82 | struct ParseContext { 83 | range_fn: fn() -> RangeInclusive, 84 | hashed_value: Option, 85 | } 86 | 87 | /// Normalize a crontab expression to compact form. 88 | /// 89 | /// ```rust 90 | /// use cronexpr::normalize_crontab; 91 | /// 92 | /// assert_eq!( 93 | /// normalize_crontab(" * * * * * Asia/Shanghai "), 94 | /// "* * * * * Asia/Shanghai" 95 | /// ); 96 | /// assert_eq!( 97 | /// normalize_crontab(" 2\t4 * * *\nAsia/Shanghai "), 98 | /// "2 4 * * * Asia/Shanghai" 99 | /// ); 100 | /// ``` 101 | pub fn normalize_crontab(input: &str) -> String { 102 | input 103 | .split_ascii_whitespace() 104 | .filter(|part| !part.is_empty()) 105 | .collect::>() 106 | .join(" ") 107 | } 108 | 109 | /// Parse a crontab expression to [`Crontab`]. See [the top-level documentation][crate] for the full 110 | /// syntax definitions. 111 | /// 112 | /// ```rust 113 | /// use cronexpr::parse_crontab_with; 114 | /// use cronexpr::FallbackTimezoneOption; 115 | /// use cronexpr::ParseOptions; 116 | /// 117 | /// let mut options = ParseOptions::default(); 118 | /// parse_crontab_with("* * * * * Asia/Shanghai", options).unwrap(); 119 | /// parse_crontab_with("2 4 * * * Asia/Shanghai", options).unwrap(); 120 | /// parse_crontab_with("2 4 * * 0-6 Asia/Shanghai", options).unwrap(); 121 | /// parse_crontab_with("2 4 */3 * 0-6 Asia/Shanghai", options).unwrap(); 122 | /// 123 | /// parse_crontab_with("* * * * *", options).unwrap_err(); 124 | /// options.fallback_timezone_option = FallbackTimezoneOption::UTC; 125 | /// parse_crontab_with("* * * * *", options).unwrap(); 126 | /// options.fallback_timezone_option = FallbackTimezoneOption::System; 127 | /// parse_crontab_with("* * * * *", options).unwrap(); 128 | /// 129 | /// options.fallback_timezone_option = FallbackTimezoneOption::None; 130 | /// parse_crontab_with("H * * * * UTC", options).unwrap_err(); 131 | /// options.hashed_value = Some(42); 132 | /// parse_crontab_with("H * * * * UTC", options).unwrap(); 133 | /// ``` 134 | pub fn parse_crontab_with(input: &str, options: ParseOptions) -> Result { 135 | let normalized = normalize_crontab(input); 136 | if normalized.is_empty() { 137 | return Err(format_error(&normalized, "", "cannot be empty")); 138 | } 139 | 140 | fn find_next_part(input: &str, start: usize, next_part: &str) -> Result { 141 | if start < input.len() { 142 | Ok(input[start..] 143 | .find(' ') 144 | .map(|end| start + end) 145 | .unwrap_or(input.len())) 146 | } else { 147 | Err(format_incomplete_error(input, next_part)) 148 | } 149 | } 150 | 151 | let minutes_start = 0; 152 | let minutes_end = normalized.find(' ').unwrap_or(normalized.len()); 153 | let minutes = parse_minutes(options) 154 | .parse(&normalized[..minutes_end]) 155 | .map_err(|err| format_parse_error(&normalized, minutes_start, err))?; 156 | 157 | let hours_start = minutes_end + 1; 158 | let hours_end = find_next_part(&normalized, hours_start, "hours")?; 159 | let hours = parse_hours(options) 160 | .parse(&normalized[hours_start..hours_end]) 161 | .map_err(|err| format_parse_error(&normalized, hours_start, err))?; 162 | 163 | let days_of_month_start = hours_end + 1; 164 | let days_of_month_end = find_next_part(&normalized, days_of_month_start, "days of month")?; 165 | let days_of_month = parse_days_of_month(options) 166 | .parse(&normalized[days_of_month_start..days_of_month_end]) 167 | .map_err(|err| format_parse_error(&normalized, days_of_month_start, err))?; 168 | 169 | let months_start = days_of_month_end + 1; 170 | let months_end = find_next_part(&normalized, months_start, "months")?; 171 | let months_part = &normalized[months_start..months_end]; 172 | let months = parse_months(options) 173 | .parse(months_part) 174 | .map_err(|err| format_parse_error(&normalized, months_start, err))?; 175 | 176 | let days_of_week_start = months_end + 1; 177 | let days_of_week_end = find_next_part(&normalized, days_of_week_start, "days of week")?; 178 | let days_of_week = parse_days_of_week(options) 179 | .parse(&normalized[days_of_week_start..days_of_week_end]) 180 | .map_err(|err| format_parse_error(&normalized, days_of_week_start, err))?; 181 | 182 | let timezone_start = days_of_week_end + 1; 183 | let timezone = if timezone_start < normalized.len() { 184 | let timezone_end = normalized.len(); 185 | let timezone_part = &normalized[timezone_start..timezone_end]; 186 | parse_timezone 187 | .parse(timezone_part) 188 | .map_err(|err| format_parse_error(&normalized, timezone_start, err))? 189 | } else { 190 | match options.fallback_timezone_option { 191 | FallbackTimezoneOption::System => jiff::tz::TimeZone::system(), 192 | FallbackTimezoneOption::UTC => jiff::tz::TimeZone::UTC, 193 | FallbackTimezoneOption::None => { 194 | return Err(format_incomplete_error(&normalized, "timezone")); 195 | } 196 | } 197 | }; 198 | 199 | Ok(Crontab { 200 | minutes, 201 | hours, 202 | days_of_month, 203 | months, 204 | days_of_week, 205 | timezone, 206 | }) 207 | } 208 | 209 | /// Parse a crontab expression to [`Crontab`] with the default [`ParseOptions`]. See 210 | /// [the top-level documentation][crate] for the full syntax definitions. 211 | /// 212 | /// ```rust 213 | /// use cronexpr::parse_crontab; 214 | /// 215 | /// parse_crontab("* * * * * Asia/Shanghai").unwrap(); 216 | /// parse_crontab("2 4 * * * Asia/Shanghai").unwrap(); 217 | /// parse_crontab("2 4 * * 0-6 Asia/Shanghai").unwrap(); 218 | /// parse_crontab("2 4 */3 * 0-6 Asia/Shanghai").unwrap(); 219 | /// ``` 220 | pub fn parse_crontab(input: &str) -> Result { 221 | parse_crontab_with(input, ParseOptions::default()) 222 | } 223 | 224 | fn format_error(input: &str, indent: &str, reason: &str) -> Error { 225 | let context = "failed to parse crontab expression"; 226 | Error(format!("{context}:\n{input}\n{indent}^ {reason}")) 227 | } 228 | 229 | fn format_incomplete_error(input: &str, next_part: &str) -> Error { 230 | let indent = " ".repeat(input.len()); 231 | format_error(input, &indent, &format!("missing {next_part}")) 232 | } 233 | 234 | fn format_parse_error( 235 | input: &str, 236 | start: usize, 237 | parse_error: winnow::error::ParseError<&str, ContextError>, 238 | ) -> Error { 239 | let offset = start + parse_error.offset(); 240 | let indent = " ".repeat(offset); 241 | 242 | let error = parse_error.into_inner().to_string(); 243 | let error = if error.is_empty() { 244 | "malformed expression" 245 | } else { 246 | &error 247 | }; 248 | 249 | format_error(input, &indent, error) 250 | } 251 | 252 | fn parse_minutes<'a>( 253 | options: ParseOptions, 254 | ) -> impl ModalParser<&'a str, PossibleLiterals, ContextError> { 255 | let context = ParseContext { 256 | range_fn: || 0..=59, 257 | hashed_value: options.hashed_value, 258 | }; 259 | move |input: &mut &str| do_parse_number_only(context, input) 260 | } 261 | 262 | fn parse_hours<'a>( 263 | options: ParseOptions, 264 | ) -> impl ModalParser<&'a str, PossibleLiterals, ContextError> { 265 | let context = ParseContext { 266 | range_fn: || 0..=23, 267 | hashed_value: options.hashed_value, 268 | }; 269 | move |input: &mut &str| do_parse_number_only(context, input) 270 | } 271 | 272 | fn parse_months<'a>( 273 | options: ParseOptions, 274 | ) -> impl ModalParser<&'a str, PossibleLiterals, ContextError> { 275 | let context = ParseContext { 276 | range_fn: || 1..=12, 277 | hashed_value: options.hashed_value, 278 | }; 279 | 280 | fn parse_single_month<'a>( 281 | context: ParseContext, 282 | ) -> impl ModalParser<&'a str, u8, ContextError> { 283 | alt(( 284 | "JAN".map(|_| 1), 285 | "FEB".map(|_| 2), 286 | "MAR".map(|_| 3), 287 | "APR".map(|_| 4), 288 | "MAY".map(|_| 5), 289 | "JUN".map(|_| 6), 290 | "JUL".map(|_| 7), 291 | "AUG".map(|_| 8), 292 | "SEP".map(|_| 9), 293 | "OCT".map(|_| 10), 294 | "NOV".map(|_| 11), 295 | "DEC".map(|_| 12), 296 | parse_single_number(context), 297 | )) 298 | } 299 | 300 | move |input: &mut &str| { 301 | let values = parse_list(alt(( 302 | parse_step(context, parse_single_month).map(|r| { 303 | r.into_iter() 304 | .map(PossibleValue::Literal) 305 | .collect::>() 306 | }), 307 | parse_range(context, parse_single_month).map(|r| { 308 | r.into_iter() 309 | .map(PossibleValue::Literal) 310 | .collect::>() 311 | }), 312 | parse_single_month(context).map(|n| vec![PossibleValue::Literal(n)]), 313 | parse_hashed_value(context).map(|n| vec![PossibleValue::Literal(n)]), 314 | parse_asterisk(context).map(|r| { 315 | r.into_iter() 316 | .map(PossibleValue::Literal) 317 | .collect::>() 318 | }), 319 | ))) 320 | .parse_next(input)?; 321 | 322 | let mut literals = BTreeSet::new(); 323 | for value in values { 324 | match value { 325 | PossibleValue::Literal(value) => { 326 | literals.insert(value); 327 | } 328 | _ => unreachable!("unexpected value: {value:?}"), 329 | } 330 | } 331 | Ok(PossibleLiterals { values: literals }) 332 | } 333 | } 334 | 335 | fn parse_days_of_week<'a>( 336 | options: ParseOptions, 337 | ) -> impl ModalParser<&'a str, ParsedDaysOfWeek, ContextError> { 338 | let context = ParseContext { 339 | range_fn: || 0..=7, 340 | hashed_value: options.hashed_value, 341 | }; 342 | 343 | fn norm_sunday(n: u8) -> u8 { 344 | if n != 0 { 345 | n 346 | } else { 347 | 7 348 | } 349 | } 350 | 351 | fn make_weekday(n: u8) -> Weekday { 352 | let weekday = norm_sunday(n) as i8; 353 | Weekday::from_monday_one_offset(weekday) 354 | .unwrap_or_else(|err| panic!("{weekday} must be in range 1..=7: {err:?}")) 355 | } 356 | 357 | fn parse_single_day_of_week<'a>( 358 | context: ParseContext, 359 | ) -> impl ModalParser<&'a str, u8, ContextError> { 360 | alt(( 361 | "SUN".map(|_| 0), 362 | "MON".map(|_| 1), 363 | "TUE".map(|_| 2), 364 | "WED".map(|_| 3), 365 | "THU".map(|_| 4), 366 | "FRI".map(|_| 5), 367 | "SAT".map(|_| 6), 368 | parse_single_number(context), 369 | )) 370 | } 371 | 372 | fn parse_single_day_of_week_ext<'a>( 373 | context: ParseContext, 374 | ) -> impl ModalParser<&'a str, PossibleValue, ContextError> { 375 | alt(( 376 | (parse_single_day_of_week(context), "L") 377 | .map(|(n, _)| PossibleValue::LastDayOfWeek(make_weekday(n))), 378 | ( 379 | parse_single_day_of_week(context), 380 | "#", 381 | parse_single_number(ParseContext { 382 | range_fn: || 1..=5, 383 | hashed_value: None, 384 | }), 385 | ) 386 | .map(|(n, _, nth)| PossibleValue::NthDayOfWeek(nth, make_weekday(n))), 387 | parse_single_day_of_week(context).map(|n| PossibleValue::Literal(norm_sunday(n))), 388 | parse_hashed_value(context).map(|n| PossibleValue::Literal(norm_sunday(n))), 389 | )) 390 | } 391 | 392 | move |input: &mut &str| { 393 | let start_with_asterisk = input.starts_with('*'); 394 | 395 | let values = parse_list(alt(( 396 | parse_step(context, parse_single_day_of_week).map(|r| { 397 | r.into_iter() 398 | .map(norm_sunday) 399 | .map(PossibleValue::Literal) 400 | .collect::>() 401 | }), 402 | parse_range(context, parse_single_day_of_week).map(|r| { 403 | r.into_iter() 404 | .map(norm_sunday) 405 | .map(PossibleValue::Literal) 406 | .collect::>() 407 | }), 408 | parse_single_day_of_week_ext(context).map(|n| vec![n]), 409 | parse_asterisk(context).map(|r| { 410 | r.into_iter() 411 | .map(norm_sunday) 412 | .map(PossibleValue::Literal) 413 | .collect::>() 414 | }), 415 | ))) 416 | .parse_next(input)?; 417 | 418 | let mut literals = BTreeSet::new(); 419 | let mut last_days_of_week = HashSet::new(); 420 | let mut nth_days_of_week = HashSet::new(); 421 | for value in values { 422 | match value { 423 | PossibleValue::Literal(value) => { 424 | literals.insert(value); 425 | } 426 | PossibleValue::LastDayOfWeek(weekday) => { 427 | last_days_of_week.insert(weekday); 428 | } 429 | PossibleValue::NthDayOfWeek(nth, weekday) => { 430 | nth_days_of_week.insert((nth, weekday)); 431 | } 432 | _ => unreachable!("unexpected value: {value:?}"), 433 | } 434 | } 435 | Ok(ParsedDaysOfWeek { 436 | literals, 437 | last_days_of_week, 438 | nth_days_of_week, 439 | start_with_asterisk, 440 | }) 441 | } 442 | } 443 | 444 | fn parse_days_of_month<'a>( 445 | options: ParseOptions, 446 | ) -> impl ModalParser<&'a str, ParsedDaysOfMonth, ContextError> { 447 | let context = ParseContext { 448 | range_fn: || 1..=31, 449 | hashed_value: options.hashed_value, 450 | }; 451 | 452 | fn parse_single_day_of_month_ext<'a>( 453 | context: ParseContext, 454 | ) -> impl ModalParser<&'a str, PossibleValue, ContextError> { 455 | alt(( 456 | (parse_single_number(context), "W").map(|(n, _)| PossibleValue::NearestWeekday(n)), 457 | parse_single_number(context).map(PossibleValue::Literal), 458 | "L".map(|_| PossibleValue::LastDayOfMonth), 459 | parse_hashed_value(context).map(PossibleValue::Literal), 460 | )) 461 | } 462 | 463 | move |input: &mut &str| { 464 | let start_with_asterisk = input.starts_with('*'); 465 | 466 | let values = parse_list(alt(( 467 | parse_step(context, parse_single_number).map(|r| { 468 | r.into_iter() 469 | .map(PossibleValue::Literal) 470 | .collect::>() 471 | }), 472 | parse_range(context, parse_single_number).map(|r| { 473 | r.into_iter() 474 | .map(PossibleValue::Literal) 475 | .collect::>() 476 | }), 477 | parse_single_day_of_month_ext(context).map(|n| vec![n]), 478 | parse_asterisk(context).map(|r| { 479 | r.into_iter() 480 | .map(PossibleValue::Literal) 481 | .collect::>() 482 | }), 483 | ))) 484 | .parse_next(input)?; 485 | 486 | let mut literals = BTreeSet::new(); 487 | let mut last_day_of_month = false; 488 | let mut nearest_weekdays = BTreeSet::new(); 489 | for value in values { 490 | match value { 491 | PossibleValue::Literal(value) => { 492 | literals.insert(value); 493 | } 494 | PossibleValue::LastDayOfMonth => { 495 | last_day_of_month = true; 496 | } 497 | PossibleValue::NearestWeekday(day) => { 498 | nearest_weekdays.insert(day); 499 | } 500 | _ => unreachable!("unexpected value: {value:?}"), 501 | } 502 | } 503 | Ok(ParsedDaysOfMonth { 504 | literals, 505 | last_day_of_month, 506 | nearest_weekdays, 507 | start_with_asterisk, 508 | }) 509 | } 510 | } 511 | 512 | fn parse_timezone(input: &mut &str) -> ModalResult { 513 | take_while(0.., |_| true) 514 | .try_map_cut(|timezone| { 515 | jiff::tz::TimeZone::get(timezone).map_err(|_| { 516 | Error(format!( 517 | "failed to find timezone {timezone}; \ 518 | for a list of time zones, see the list of tz database time zones on Wikipedia: \ 519 | https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List" 520 | )) 521 | }) 522 | }) 523 | .parse_next(input) 524 | } 525 | 526 | // number only = minutes, hours, or months 527 | fn do_parse_number_only(context: ParseContext, input: &mut &str) -> ModalResult { 528 | let values = parse_list(alt(( 529 | parse_step(context, parse_single_number).map(|r| { 530 | r.into_iter() 531 | .map(PossibleValue::Literal) 532 | .collect::>() 533 | }), 534 | parse_range(context, parse_single_number).map(|r| { 535 | r.into_iter() 536 | .map(PossibleValue::Literal) 537 | .collect::>() 538 | }), 539 | parse_single_number(context).map(|n| vec![PossibleValue::Literal(n)]), 540 | parse_hashed_value(context).map(|n| vec![PossibleValue::Literal(n)]), 541 | parse_asterisk(context).map(|r| { 542 | r.into_iter() 543 | .map(PossibleValue::Literal) 544 | .collect::>() 545 | }), 546 | ))) 547 | .parse_next(input)?; 548 | 549 | let mut literals = BTreeSet::new(); 550 | for value in values { 551 | match value { 552 | PossibleValue::Literal(value) => { 553 | literals.insert(value); 554 | } 555 | _ => unreachable!("unexpected value: {value:?}"), 556 | } 557 | } 558 | Ok(PossibleLiterals { values: literals }) 559 | } 560 | 561 | fn parse_hashed_value<'a>(context: ParseContext) -> impl ModalParser<&'a str, u8, ContextError> { 562 | move |input: &mut &str| { 563 | if let Some(hashed_value) = context.hashed_value { 564 | let range = (context.range_fn)(); 565 | let hashed_value = map_hash_into_range(hashed_value, range); 566 | "H".map(move |_| hashed_value).parse_next(input) 567 | } else { 568 | fail(input) 569 | } 570 | } 571 | } 572 | 573 | fn parse_asterisk<'a>(context: ParseContext) -> impl ModalParser<&'a str, Vec, ContextError> { 574 | let range = context.range_fn; 575 | "*".map(move |_| range().collect()) 576 | } 577 | 578 | fn parse_single_number<'a>(context: ParseContext) -> impl ModalParser<&'a str, u8, ContextError> { 579 | let range = context.range_fn; 580 | dec_uint.try_map_cut(move |n: u64| { 581 | let range = range(); 582 | 583 | if n > u8::MAX as u64 { 584 | return Err(Error(format!( 585 | "value must be in range {range:?}; found {n}" 586 | ))); 587 | } 588 | 589 | let n = n as u8; 590 | if range.contains(&n) { 591 | Ok(n) 592 | } else { 593 | Err(Error(format!( 594 | "value must be in range {range:?}; found {n}" 595 | ))) 596 | } 597 | }) 598 | } 599 | 600 | fn parse_range<'a, P>( 601 | context: ParseContext, 602 | parse_single_range_bound: fn(context: ParseContext) -> P, 603 | ) -> impl ModalParser<&'a str, Vec, ContextError> 604 | where 605 | P: ModalParser<&'a str, u8, ContextError>, 606 | { 607 | let range = context.range_fn; 608 | ( 609 | parse_single_range_bound(context), 610 | "-", 611 | parse_single_range_bound(context), 612 | ) 613 | .try_map_cut(move |(lo, _, hi): (u8, _, u8)| { 614 | let range = range(); 615 | 616 | if lo > hi { 617 | return Err(Error(format!( 618 | "range must be in ascending order; found {lo}-{hi}" 619 | ))); 620 | } 621 | 622 | if range.contains(&lo) && range.contains(&hi) { 623 | Ok((lo..=hi).collect()) 624 | } else { 625 | Err(Error(format!( 626 | "range must be in range {range:?}; found {lo}-{hi}" 627 | ))) 628 | } 629 | }) 630 | } 631 | 632 | fn parse_step<'a, P>( 633 | context: ParseContext, 634 | parse_single_range_bound: fn(context: ParseContext) -> P, 635 | ) -> impl ModalParser<&'a str, Vec, ContextError> 636 | where 637 | P: ModalParser<&'a str, u8, ContextError>, 638 | { 639 | let range = context.range_fn; 640 | let range_end = *range().end(); 641 | 642 | let possible_values = alt(( 643 | parse_asterisk(context), 644 | parse_range(context, parse_single_range_bound), 645 | parse_single_range_bound(context).map(move |n| (n..=range_end).collect()), 646 | )); 647 | 648 | (possible_values, "/", dec_uint).try_map_cut(move |(candidates, _, step): (Vec, _, u64)| { 649 | let range = range(); 650 | 651 | if step == 0 { 652 | return Err(Error("step must be greater than 0".to_string())); 653 | } 654 | 655 | if step > u8::MAX as u64 { 656 | return Err(Error(format!( 657 | "step must be in range {range:?}; found {step}" 658 | ))); 659 | } 660 | 661 | let step = step as u8; 662 | if !range.contains(&step) { 663 | return Err(Error(format!( 664 | "step must be in range {range:?}; found {step}" 665 | ))); 666 | } 667 | 668 | let mut values = Vec::new(); 669 | for n in candidates.into_iter().step_by(step as usize) { 670 | values.push(n); 671 | } 672 | Ok(values) 673 | }) 674 | } 675 | 676 | fn parse_list<'a, P>( 677 | parse_list_item: P, 678 | ) -> impl ModalParser<&'a str, Vec, ContextError> 679 | where 680 | P: ModalParser<&'a str, Vec, ContextError>, 681 | { 682 | (separated(1.., parse_list_item, ","), eof) 683 | .map(move |(ns, _): (Vec>, _)| ns.into_iter().flatten().collect()) 684 | } 685 | 686 | fn map_hash_into_range(hashed_value: u64, range: RangeInclusive) -> u8 { 687 | let modulo = range.end() - range.start() + 1; 688 | let hashed_value = hashed_value % modulo as u64; 689 | (range.start() + hashed_value as u8).min(*range.end()) 690 | } 691 | 692 | trait ModalParserExt: ModalParser { 693 | #[inline(always)] 694 | fn try_map_cut(self, map: G) -> TryMapCut 695 | where 696 | Self: Sized, 697 | G: FnMut(O) -> Result, 698 | I: Stream, 699 | E: FromExternalError, 700 | { 701 | TryMapCut { 702 | parser: self, 703 | map, 704 | i: Default::default(), 705 | o: Default::default(), 706 | o2: Default::default(), 707 | e: Default::default(), 708 | e2: Default::default(), 709 | } 710 | } 711 | } 712 | 713 | struct TryMapCut 714 | where 715 | F: ModalParser, 716 | G: FnMut(O) -> Result, 717 | I: Stream, 718 | E: FromExternalError, 719 | { 720 | parser: F, 721 | map: G, 722 | i: core::marker::PhantomData, 723 | o: core::marker::PhantomData, 724 | o2: core::marker::PhantomData, 725 | e: core::marker::PhantomData, 726 | e2: core::marker::PhantomData, 727 | } 728 | 729 | impl Parser> for TryMapCut 730 | where 731 | F: ModalParser, 732 | G: FnMut(O) -> Result, 733 | I: Stream, 734 | E: FromExternalError, 735 | { 736 | #[inline] 737 | fn parse_next(&mut self, input: &mut I) -> ModalResult { 738 | let start = input.checkpoint(); 739 | let o = self.parser.parse_next(input)?; 740 | 741 | (self.map)(o).map_err(|err| { 742 | input.reset(&start); 743 | ErrMode::from_external_error(input, err).cut() 744 | }) 745 | } 746 | } 747 | 748 | impl ModalParserExt for P where P: ModalParser {} 749 | 750 | #[cfg(test)] 751 | mod tests { 752 | use insta::assert_debug_snapshot; 753 | use insta::assert_snapshot; 754 | 755 | use super::*; 756 | 757 | #[test] 758 | fn test_parse_crontab_success() { 759 | // snapshot files are ordered; for new cases, please add to the end 760 | assert_debug_snapshot!(parse_crontab("* * * * * Asia/Shanghai").unwrap()); 761 | assert_debug_snapshot!(parse_crontab("2 4 * * * Asia/Shanghai").unwrap()); 762 | assert_debug_snapshot!(parse_crontab("2 4 * * 0-6 Asia/Shanghai").unwrap()); 763 | assert_debug_snapshot!(parse_crontab("2 4 */3 * 0-6 Asia/Shanghai").unwrap()); 764 | assert_debug_snapshot!(parse_crontab("*/2 1 1 1 * Asia/Shanghai").unwrap()); 765 | assert_debug_snapshot!(parse_crontab("1/2 1 1 1 * Asia/Shanghai").unwrap()); 766 | assert_debug_snapshot!(parse_crontab("1-29/2 1 1 1 * Asia/Shanghai").unwrap()); 767 | assert_debug_snapshot!(parse_crontab("1-30/2 1 1 1 * Asia/Shanghai").unwrap()); 768 | assert_debug_snapshot!(parse_crontab("1,2,10 1 1 1 * Asia/Shanghai").unwrap()); 769 | assert_debug_snapshot!(parse_crontab("1-10,2,10,50 1 1 1 * Asia/Shanghai").unwrap()); 770 | assert_debug_snapshot!(parse_crontab("1-10,2,10,50 1 * 1 TUE Asia/Shanghai").unwrap()); 771 | 772 | // optional timezone 773 | let options = ParseOptions { 774 | fallback_timezone_option: FallbackTimezoneOption::UTC, 775 | ..Default::default() 776 | }; 777 | assert_debug_snapshot!(parse_crontab_with("0 0 1 1 5", options).unwrap()); 778 | assert_debug_snapshot!(parse_crontab_with("0 0 1 1 5 ", options).unwrap()); 779 | 780 | let options = ParseOptions { 781 | fallback_timezone_option: FallbackTimezoneOption::System, 782 | ..Default::default() 783 | }; 784 | insta::with_settings!({ 785 | filters => vec![(r"TZif\(\n.*\n.*\)", "[SYSTEM]")] 786 | }, { 787 | assert_debug_snapshot!(parse_crontab_with("0 0 1 1 5", options).unwrap()); 788 | assert_debug_snapshot!(parse_crontab_with("0 0 1 1 5 ", options).unwrap()); 789 | }); 790 | 791 | // hashed value 792 | let options = ParseOptions { 793 | hashed_value: Some(42), 794 | ..Default::default() 795 | }; 796 | assert_debug_snapshot!(parse_crontab_with("H * * * * America/Denver", options).unwrap()); 797 | assert_debug_snapshot!(parse_crontab_with("H H H H H America/Denver", options).unwrap()); 798 | } 799 | 800 | #[test] 801 | fn test_parse_crontab_failed() { 802 | // snapshot files are ordered; for new cases, please add to the end 803 | assert_snapshot!(parse_crontab("invalid 4 * * * Asia/Shanghai").unwrap_err()); 804 | assert_snapshot!(parse_crontab("* * * * * Unknown/Timezone").unwrap_err()); 805 | assert_snapshot!(parse_crontab("* 5-4 * * * Asia/Shanghai").unwrap_err()); 806 | assert_snapshot!(parse_crontab("10086 * * * * Asia/Shanghai").unwrap_err()); 807 | assert_snapshot!(parse_crontab("* 0-24 * * * Asia/Shanghai").unwrap_err()); 808 | assert_snapshot!(parse_crontab("* * * 25 * Asia/Shanghai").unwrap_err()); 809 | assert_snapshot!(parse_crontab("32-300 * * * * Asia/Shanghai").unwrap_err()); 810 | assert_snapshot!(parse_crontab("129-300 * * * * Asia/Shanghai").unwrap_err()); 811 | assert_snapshot!(parse_crontab("29- * * * * Asia/Shanghai").unwrap_err()); 812 | assert_snapshot!(parse_crontab("29 ** * * * Asia/Shanghai").unwrap_err()); 813 | assert_snapshot!(parse_crontab("29--30 * * * * Asia/Shanghai").unwrap_err()); 814 | assert_snapshot!(parse_crontab("1,2,10,100 1 1 1 * Asia/Shanghai").unwrap_err()); 815 | assert_snapshot!(parse_crontab("104,2,10,100 1 1 1 * Asia/Shanghai").unwrap_err()); 816 | assert_snapshot!(parse_crontab("1,2,10 * * 104,2,10,100 * Asia/Shanghai").unwrap_err()); 817 | assert_snapshot!(parse_crontab("1-10,2,10,50 1 * 1 TTT Asia/Shanghai").unwrap_err()); 818 | 819 | // check incomplete and edge right; all input are first normalized so no need for extra 820 | // spaces 821 | assert_snapshot!(parse_crontab("0").unwrap_err()); 822 | assert_snapshot!(parse_crontab("0 0").unwrap_err()); 823 | assert_snapshot!(parse_crontab("0 0 1").unwrap_err()); 824 | assert_snapshot!(parse_crontab("0 0 1 1").unwrap_err()); 825 | assert_snapshot!(parse_crontab("0 0 1 1 5").unwrap_err()); 826 | assert_snapshot!(parse_crontab("0 0 1 1 5 ").unwrap_err()); 827 | assert_snapshot!(parse_crontab("0 0 1 1 5 Z").unwrap_err()); 828 | assert_snapshot!(parse_crontab("0 0 1 1 5 Z Z").unwrap_err()); 829 | assert_snapshot!(parse_crontab("").unwrap_err()); 830 | 831 | // hashed value 832 | assert_snapshot!(parse_crontab("H * * * * UTC").unwrap_err()); 833 | } 834 | 835 | #[test] 836 | fn test_crontab_guru_examples() { 837 | // crontab.guru examples: https://crontab.guru/examples.html 838 | assert_debug_snapshot!(parse_crontab("* * * * * UTC").unwrap()); 839 | assert_debug_snapshot!(parse_crontab("*/2 * * * * UTC").unwrap()); 840 | assert_debug_snapshot!(parse_crontab("1-59/2 * * * * UTC").unwrap()); 841 | assert_debug_snapshot!(parse_crontab("*/3 * * * * UTC").unwrap()); 842 | assert_debug_snapshot!(parse_crontab("*/4 * * * * UTC").unwrap()); 843 | assert_debug_snapshot!(parse_crontab("*/5 * * * * UTC").unwrap()); 844 | assert_debug_snapshot!(parse_crontab("*/6 * * * * UTC").unwrap()); 845 | assert_debug_snapshot!(parse_crontab("*/10 * * * * UTC").unwrap()); 846 | assert_debug_snapshot!(parse_crontab("*/15 * * * * UTC").unwrap()); 847 | assert_debug_snapshot!(parse_crontab("*/20 * * * * UTC").unwrap()); 848 | assert_debug_snapshot!(parse_crontab("*/30 * * * * UTC").unwrap()); 849 | assert_debug_snapshot!(parse_crontab("30 * * * * UTC").unwrap()); 850 | assert_debug_snapshot!(parse_crontab("0 * * * * UTC").unwrap()); 851 | assert_debug_snapshot!(parse_crontab("0 */2 * * * UTC").unwrap()); 852 | assert_debug_snapshot!(parse_crontab("0 */3 * * * UTC").unwrap()); 853 | assert_debug_snapshot!(parse_crontab("0 */4 * * * UTC").unwrap()); 854 | assert_debug_snapshot!(parse_crontab("0 */6 * * * UTC").unwrap()); 855 | assert_debug_snapshot!(parse_crontab("0 */8 * * * UTC").unwrap()); 856 | assert_debug_snapshot!(parse_crontab("0 */12 * * * UTC").unwrap()); 857 | assert_debug_snapshot!(parse_crontab("0 9-17 * * * UTC").unwrap()); 858 | assert_debug_snapshot!(parse_crontab("0 0 * * * UTC").unwrap()); 859 | assert_debug_snapshot!(parse_crontab("0 1 * * * UTC").unwrap()); 860 | assert_debug_snapshot!(parse_crontab("0 2 * * * UTC").unwrap()); 861 | assert_debug_snapshot!(parse_crontab("0 8 * * * UTC").unwrap()); 862 | assert_debug_snapshot!(parse_crontab("0 9 * * * UTC").unwrap()); 863 | assert_debug_snapshot!(parse_crontab("0 0 * * 0 UTC").unwrap()); 864 | assert_debug_snapshot!(parse_crontab("0 0 * * 1 UTC").unwrap()); 865 | assert_debug_snapshot!(parse_crontab("0 0 * * 2 UTC").unwrap()); 866 | assert_debug_snapshot!(parse_crontab("0 0 * * 3 UTC").unwrap()); 867 | assert_debug_snapshot!(parse_crontab("0 0 * * 4 UTC").unwrap()); 868 | assert_debug_snapshot!(parse_crontab("0 0 * * 5 UTC").unwrap()); 869 | assert_debug_snapshot!(parse_crontab("0 0 * * 6 UTC").unwrap()); 870 | assert_debug_snapshot!(parse_crontab("0 0 * * 1-5 UTC").unwrap()); 871 | assert_debug_snapshot!(parse_crontab("0 0 * * 6,0 UTC").unwrap()); 872 | assert_debug_snapshot!(parse_crontab("0 0 1 * * UTC").unwrap()); 873 | assert_debug_snapshot!(parse_crontab("0 0 1 * * UTC").unwrap()); 874 | assert_debug_snapshot!(parse_crontab("0 0 1 */2 * UTC").unwrap()); 875 | assert_debug_snapshot!(parse_crontab("0 0 1 */3 * UTC").unwrap()); 876 | assert_debug_snapshot!(parse_crontab("0 0 1 */6 * UTC").unwrap()); 877 | assert_debug_snapshot!(parse_crontab("0 0 1 1 * UTC").unwrap()); 878 | } 879 | } 880 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-10.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/20 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 20, 10 | 40, 11 | }, 12 | }, 13 | hours: PossibleLiterals { 14 | values: { 15 | 0, 16 | 1, 17 | 2, 18 | 3, 19 | 4, 20 | 5, 21 | 6, 22 | 7, 23 | 8, 24 | 9, 25 | 10, 26 | 11, 27 | 12, 28 | 13, 29 | 14, 30 | 15, 31 | 16, 32 | 17, 33 | 18, 34 | 19, 35 | 20, 36 | 21, 37 | 22, 38 | 23, 39 | }, 40 | }, 41 | months: PossibleLiterals { 42 | values: { 43 | 1, 44 | 2, 45 | 3, 46 | 4, 47 | 5, 48 | 6, 49 | 7, 50 | 8, 51 | 9, 52 | 10, 53 | 11, 54 | 12, 55 | }, 56 | }, 57 | days_of_month: ParsedDaysOfMonth { 58 | literals: { 59 | 1, 60 | 2, 61 | 3, 62 | 4, 63 | 5, 64 | 6, 65 | 7, 66 | 8, 67 | 9, 68 | 10, 69 | 11, 70 | 12, 71 | 13, 72 | 14, 73 | 15, 74 | 16, 75 | 17, 76 | 18, 77 | 19, 78 | 20, 79 | 21, 80 | 22, 81 | 23, 82 | 24, 83 | 25, 84 | 26, 85 | 27, 86 | 28, 87 | 29, 88 | 30, 89 | 31, 90 | }, 91 | last_day_of_month: false, 92 | nearest_weekdays: {}, 93 | start_with_asterisk: true, 94 | }, 95 | days_of_week: ParsedDaysOfWeek { 96 | literals: { 97 | 1, 98 | 2, 99 | 3, 100 | 4, 101 | 5, 102 | 6, 103 | 7, 104 | }, 105 | last_days_of_week: {}, 106 | nth_days_of_week: {}, 107 | start_with_asterisk: true, 108 | }, 109 | timezone: TimeZone( 110 | "UTC", 111 | ), 112 | } 113 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/30 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 30, 10 | }, 11 | }, 12 | hours: PossibleLiterals { 13 | values: { 14 | 0, 15 | 1, 16 | 2, 17 | 3, 18 | 4, 19 | 5, 20 | 6, 21 | 7, 22 | 8, 23 | 9, 24 | 10, 25 | 11, 26 | 12, 27 | 13, 28 | 14, 29 | 15, 30 | 16, 31 | 17, 32 | 18, 33 | 19, 34 | 20, 35 | 21, 36 | 22, 37 | 23, 38 | }, 39 | }, 40 | months: PossibleLiterals { 41 | values: { 42 | 1, 43 | 2, 44 | 3, 45 | 4, 46 | 5, 47 | 6, 48 | 7, 49 | 8, 50 | 9, 51 | 10, 52 | 11, 53 | 12, 54 | }, 55 | }, 56 | days_of_month: ParsedDaysOfMonth { 57 | literals: { 58 | 1, 59 | 2, 60 | 3, 61 | 4, 62 | 5, 63 | 6, 64 | 7, 65 | 8, 66 | 9, 67 | 10, 68 | 11, 69 | 12, 70 | 13, 71 | 14, 72 | 15, 73 | 16, 74 | 17, 75 | 18, 76 | 19, 77 | 20, 78 | 21, 79 | 22, 80 | 23, 81 | 24, 82 | 25, 83 | 26, 84 | 27, 85 | 28, 86 | 29, 87 | 30, 88 | 31, 89 | }, 90 | last_day_of_month: false, 91 | nearest_weekdays: {}, 92 | start_with_asterisk: true, 93 | }, 94 | days_of_week: ParsedDaysOfWeek { 95 | literals: { 96 | 1, 97 | 2, 98 | 3, 99 | 4, 100 | 5, 101 | 6, 102 | 7, 103 | }, 104 | last_days_of_week: {}, 105 | nth_days_of_week: {}, 106 | start_with_asterisk: true, 107 | }, 108 | timezone: TimeZone( 109 | "UTC", 110 | ), 111 | } 112 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-12.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"30 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 30, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 1, 15 | 2, 16 | 3, 17 | 4, 18 | 5, 19 | 6, 20 | 7, 21 | 8, 22 | 9, 23 | 10, 24 | 11, 25 | 12, 26 | 13, 27 | 14, 28 | 15, 29 | 16, 30 | 17, 31 | 18, 32 | 19, 33 | 20, 34 | 21, 35 | 22, 36 | 23, 37 | }, 38 | }, 39 | months: PossibleLiterals { 40 | values: { 41 | 1, 42 | 2, 43 | 3, 44 | 4, 45 | 5, 46 | 6, 47 | 7, 48 | 8, 49 | 9, 50 | 10, 51 | 11, 52 | 12, 53 | }, 54 | }, 55 | days_of_month: ParsedDaysOfMonth { 56 | literals: { 57 | 1, 58 | 2, 59 | 3, 60 | 4, 61 | 5, 62 | 6, 63 | 7, 64 | 8, 65 | 9, 66 | 10, 67 | 11, 68 | 12, 69 | 13, 70 | 14, 71 | 15, 72 | 16, 73 | 17, 74 | 18, 75 | 19, 76 | 20, 77 | 21, 78 | 22, 79 | 23, 80 | 24, 81 | 25, 82 | 26, 83 | 27, 84 | 28, 85 | 29, 86 | 30, 87 | 31, 88 | }, 89 | last_day_of_month: false, 90 | nearest_weekdays: {}, 91 | start_with_asterisk: true, 92 | }, 93 | days_of_week: ParsedDaysOfWeek { 94 | literals: { 95 | 1, 96 | 2, 97 | 3, 98 | 4, 99 | 5, 100 | 6, 101 | 7, 102 | }, 103 | last_days_of_week: {}, 104 | nth_days_of_week: {}, 105 | start_with_asterisk: true, 106 | }, 107 | timezone: TimeZone( 108 | "UTC", 109 | ), 110 | } 111 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 1, 15 | 2, 16 | 3, 17 | 4, 18 | 5, 19 | 6, 20 | 7, 21 | 8, 22 | 9, 23 | 10, 24 | 11, 25 | 12, 26 | 13, 27 | 14, 28 | 15, 29 | 16, 30 | 17, 31 | 18, 32 | 19, 33 | 20, 34 | 21, 35 | 22, 36 | 23, 37 | }, 38 | }, 39 | months: PossibleLiterals { 40 | values: { 41 | 1, 42 | 2, 43 | 3, 44 | 4, 45 | 5, 46 | 6, 47 | 7, 48 | 8, 49 | 9, 50 | 10, 51 | 11, 52 | 12, 53 | }, 54 | }, 55 | days_of_month: ParsedDaysOfMonth { 56 | literals: { 57 | 1, 58 | 2, 59 | 3, 60 | 4, 61 | 5, 62 | 6, 63 | 7, 64 | 8, 65 | 9, 66 | 10, 67 | 11, 68 | 12, 69 | 13, 70 | 14, 71 | 15, 72 | 16, 73 | 17, 74 | 18, 75 | 19, 76 | 20, 77 | 21, 78 | 22, 79 | 23, 80 | 24, 81 | 25, 82 | 26, 83 | 27, 84 | 28, 85 | 29, 86 | 30, 87 | 31, 88 | }, 89 | last_day_of_month: false, 90 | nearest_weekdays: {}, 91 | start_with_asterisk: true, 92 | }, 93 | days_of_week: ParsedDaysOfWeek { 94 | literals: { 95 | 1, 96 | 2, 97 | 3, 98 | 4, 99 | 5, 100 | 6, 101 | 7, 102 | }, 103 | last_days_of_week: {}, 104 | nth_days_of_week: {}, 105 | start_with_asterisk: true, 106 | }, 107 | timezone: TimeZone( 108 | "UTC", 109 | ), 110 | } 111 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-14.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 */2 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 2, 15 | 4, 16 | 6, 17 | 8, 18 | 10, 19 | 12, 20 | 14, 21 | 16, 22 | 18, 23 | 20, 24 | 22, 25 | }, 26 | }, 27 | months: PossibleLiterals { 28 | values: { 29 | 1, 30 | 2, 31 | 3, 32 | 4, 33 | 5, 34 | 6, 35 | 7, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | }, 42 | }, 43 | days_of_month: ParsedDaysOfMonth { 44 | literals: { 45 | 1, 46 | 2, 47 | 3, 48 | 4, 49 | 5, 50 | 6, 51 | 7, 52 | 8, 53 | 9, 54 | 10, 55 | 11, 56 | 12, 57 | 13, 58 | 14, 59 | 15, 60 | 16, 61 | 17, 62 | 18, 63 | 19, 64 | 20, 65 | 21, 66 | 22, 67 | 23, 68 | 24, 69 | 25, 70 | 26, 71 | 27, 72 | 28, 73 | 29, 74 | 30, 75 | 31, 76 | }, 77 | last_day_of_month: false, 78 | nearest_weekdays: {}, 79 | start_with_asterisk: true, 80 | }, 81 | days_of_week: ParsedDaysOfWeek { 82 | literals: { 83 | 1, 84 | 2, 85 | 3, 86 | 4, 87 | 5, 88 | 6, 89 | 7, 90 | }, 91 | last_days_of_week: {}, 92 | nth_days_of_week: {}, 93 | start_with_asterisk: true, 94 | }, 95 | timezone: TimeZone( 96 | "UTC", 97 | ), 98 | } 99 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-15.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 */3 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 3, 15 | 6, 16 | 9, 17 | 12, 18 | 15, 19 | 18, 20 | 21, 21 | }, 22 | }, 23 | months: PossibleLiterals { 24 | values: { 25 | 1, 26 | 2, 27 | 3, 28 | 4, 29 | 5, 30 | 6, 31 | 7, 32 | 8, 33 | 9, 34 | 10, 35 | 11, 36 | 12, 37 | }, 38 | }, 39 | days_of_month: ParsedDaysOfMonth { 40 | literals: { 41 | 1, 42 | 2, 43 | 3, 44 | 4, 45 | 5, 46 | 6, 47 | 7, 48 | 8, 49 | 9, 50 | 10, 51 | 11, 52 | 12, 53 | 13, 54 | 14, 55 | 15, 56 | 16, 57 | 17, 58 | 18, 59 | 19, 60 | 20, 61 | 21, 62 | 22, 63 | 23, 64 | 24, 65 | 25, 66 | 26, 67 | 27, 68 | 28, 69 | 29, 70 | 30, 71 | 31, 72 | }, 73 | last_day_of_month: false, 74 | nearest_weekdays: {}, 75 | start_with_asterisk: true, 76 | }, 77 | days_of_week: ParsedDaysOfWeek { 78 | literals: { 79 | 1, 80 | 2, 81 | 3, 82 | 4, 83 | 5, 84 | 6, 85 | 7, 86 | }, 87 | last_days_of_week: {}, 88 | nth_days_of_week: {}, 89 | start_with_asterisk: true, 90 | }, 91 | timezone: TimeZone( 92 | "UTC", 93 | ), 94 | } 95 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-16.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 */4 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 4, 15 | 8, 16 | 12, 17 | 16, 18 | 20, 19 | }, 20 | }, 21 | months: PossibleLiterals { 22 | values: { 23 | 1, 24 | 2, 25 | 3, 26 | 4, 27 | 5, 28 | 6, 29 | 7, 30 | 8, 31 | 9, 32 | 10, 33 | 11, 34 | 12, 35 | }, 36 | }, 37 | days_of_month: ParsedDaysOfMonth { 38 | literals: { 39 | 1, 40 | 2, 41 | 3, 42 | 4, 43 | 5, 44 | 6, 45 | 7, 46 | 8, 47 | 9, 48 | 10, 49 | 11, 50 | 12, 51 | 13, 52 | 14, 53 | 15, 54 | 16, 55 | 17, 56 | 18, 57 | 19, 58 | 20, 59 | 21, 60 | 22, 61 | 23, 62 | 24, 63 | 25, 64 | 26, 65 | 27, 66 | 28, 67 | 29, 68 | 30, 69 | 31, 70 | }, 71 | last_day_of_month: false, 72 | nearest_weekdays: {}, 73 | start_with_asterisk: true, 74 | }, 75 | days_of_week: ParsedDaysOfWeek { 76 | literals: { 77 | 1, 78 | 2, 79 | 3, 80 | 4, 81 | 5, 82 | 6, 83 | 7, 84 | }, 85 | last_days_of_week: {}, 86 | nth_days_of_week: {}, 87 | start_with_asterisk: true, 88 | }, 89 | timezone: TimeZone( 90 | "UTC", 91 | ), 92 | } 93 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-17.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 */6 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 6, 15 | 12, 16 | 18, 17 | }, 18 | }, 19 | months: PossibleLiterals { 20 | values: { 21 | 1, 22 | 2, 23 | 3, 24 | 4, 25 | 5, 26 | 6, 27 | 7, 28 | 8, 29 | 9, 30 | 10, 31 | 11, 32 | 12, 33 | }, 34 | }, 35 | days_of_month: ParsedDaysOfMonth { 36 | literals: { 37 | 1, 38 | 2, 39 | 3, 40 | 4, 41 | 5, 42 | 6, 43 | 7, 44 | 8, 45 | 9, 46 | 10, 47 | 11, 48 | 12, 49 | 13, 50 | 14, 51 | 15, 52 | 16, 53 | 17, 54 | 18, 55 | 19, 56 | 20, 57 | 21, 58 | 22, 59 | 23, 60 | 24, 61 | 25, 62 | 26, 63 | 27, 64 | 28, 65 | 29, 66 | 30, 67 | 31, 68 | }, 69 | last_day_of_month: false, 70 | nearest_weekdays: {}, 71 | start_with_asterisk: true, 72 | }, 73 | days_of_week: ParsedDaysOfWeek { 74 | literals: { 75 | 1, 76 | 2, 77 | 3, 78 | 4, 79 | 5, 80 | 6, 81 | 7, 82 | }, 83 | last_days_of_week: {}, 84 | nth_days_of_week: {}, 85 | start_with_asterisk: true, 86 | }, 87 | timezone: TimeZone( 88 | "UTC", 89 | ), 90 | } 91 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-18.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 */8 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 8, 15 | 16, 16 | }, 17 | }, 18 | months: PossibleLiterals { 19 | values: { 20 | 1, 21 | 2, 22 | 3, 23 | 4, 24 | 5, 25 | 6, 26 | 7, 27 | 8, 28 | 9, 29 | 10, 30 | 11, 31 | 12, 32 | }, 33 | }, 34 | days_of_month: ParsedDaysOfMonth { 35 | literals: { 36 | 1, 37 | 2, 38 | 3, 39 | 4, 40 | 5, 41 | 6, 42 | 7, 43 | 8, 44 | 9, 45 | 10, 46 | 11, 47 | 12, 48 | 13, 49 | 14, 50 | 15, 51 | 16, 52 | 17, 53 | 18, 54 | 19, 55 | 20, 56 | 21, 57 | 22, 58 | 23, 59 | 24, 60 | 25, 61 | 26, 62 | 27, 63 | 28, 64 | 29, 65 | 30, 66 | 31, 67 | }, 68 | last_day_of_month: false, 69 | nearest_weekdays: {}, 70 | start_with_asterisk: true, 71 | }, 72 | days_of_week: ParsedDaysOfWeek { 73 | literals: { 74 | 1, 75 | 2, 76 | 3, 77 | 4, 78 | 5, 79 | 6, 80 | 7, 81 | }, 82 | last_days_of_week: {}, 83 | nth_days_of_week: {}, 84 | start_with_asterisk: true, 85 | }, 86 | timezone: TimeZone( 87 | "UTC", 88 | ), 89 | } 90 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-19.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 */12 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 12, 15 | }, 16 | }, 17 | months: PossibleLiterals { 18 | values: { 19 | 1, 20 | 2, 21 | 3, 22 | 4, 23 | 5, 24 | 6, 25 | 7, 26 | 8, 27 | 9, 28 | 10, 29 | 11, 30 | 12, 31 | }, 32 | }, 33 | days_of_month: ParsedDaysOfMonth { 34 | literals: { 35 | 1, 36 | 2, 37 | 3, 38 | 4, 39 | 5, 40 | 6, 41 | 7, 42 | 8, 43 | 9, 44 | 10, 45 | 11, 46 | 12, 47 | 13, 48 | 14, 49 | 15, 50 | 16, 51 | 17, 52 | 18, 53 | 19, 54 | 20, 55 | 21, 56 | 22, 57 | 23, 58 | 24, 59 | 25, 60 | 26, 61 | 27, 62 | 28, 63 | 29, 64 | 30, 65 | 31, 66 | }, 67 | last_day_of_month: false, 68 | nearest_weekdays: {}, 69 | start_with_asterisk: true, 70 | }, 71 | days_of_week: ParsedDaysOfWeek { 72 | literals: { 73 | 1, 74 | 2, 75 | 3, 76 | 4, 77 | 5, 78 | 6, 79 | 7, 80 | }, 81 | last_days_of_week: {}, 82 | nth_days_of_week: {}, 83 | start_with_asterisk: true, 84 | }, 85 | timezone: TimeZone( 86 | "UTC", 87 | ), 88 | } 89 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/2 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 2, 10 | 4, 11 | 6, 12 | 8, 13 | 10, 14 | 12, 15 | 14, 16 | 16, 17 | 18, 18 | 20, 19 | 22, 20 | 24, 21 | 26, 22 | 28, 23 | 30, 24 | 32, 25 | 34, 26 | 36, 27 | 38, 28 | 40, 29 | 42, 30 | 44, 31 | 46, 32 | 48, 33 | 50, 34 | 52, 35 | 54, 36 | 56, 37 | 58, 38 | }, 39 | }, 40 | hours: PossibleLiterals { 41 | values: { 42 | 0, 43 | 1, 44 | 2, 45 | 3, 46 | 4, 47 | 5, 48 | 6, 49 | 7, 50 | 8, 51 | 9, 52 | 10, 53 | 11, 54 | 12, 55 | 13, 56 | 14, 57 | 15, 58 | 16, 59 | 17, 60 | 18, 61 | 19, 62 | 20, 63 | 21, 64 | 22, 65 | 23, 66 | }, 67 | }, 68 | months: PossibleLiterals { 69 | values: { 70 | 1, 71 | 2, 72 | 3, 73 | 4, 74 | 5, 75 | 6, 76 | 7, 77 | 8, 78 | 9, 79 | 10, 80 | 11, 81 | 12, 82 | }, 83 | }, 84 | days_of_month: ParsedDaysOfMonth { 85 | literals: { 86 | 1, 87 | 2, 88 | 3, 89 | 4, 90 | 5, 91 | 6, 92 | 7, 93 | 8, 94 | 9, 95 | 10, 96 | 11, 97 | 12, 98 | 13, 99 | 14, 100 | 15, 101 | 16, 102 | 17, 103 | 18, 104 | 19, 105 | 20, 106 | 21, 107 | 22, 108 | 23, 109 | 24, 110 | 25, 111 | 26, 112 | 27, 113 | 28, 114 | 29, 115 | 30, 116 | 31, 117 | }, 118 | last_day_of_month: false, 119 | nearest_weekdays: {}, 120 | start_with_asterisk: true, 121 | }, 122 | days_of_week: ParsedDaysOfWeek { 123 | literals: { 124 | 1, 125 | 2, 126 | 3, 127 | 4, 128 | 5, 129 | 6, 130 | 7, 131 | }, 132 | last_days_of_week: {}, 133 | nth_days_of_week: {}, 134 | start_with_asterisk: true, 135 | }, 136 | timezone: TimeZone( 137 | "UTC", 138 | ), 139 | } 140 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-20.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 9-17 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 9, 14 | 10, 15 | 11, 16 | 12, 17 | 13, 18 | 14, 19 | 15, 20 | 16, 21 | 17, 22 | }, 23 | }, 24 | months: PossibleLiterals { 25 | values: { 26 | 1, 27 | 2, 28 | 3, 29 | 4, 30 | 5, 31 | 6, 32 | 7, 33 | 8, 34 | 9, 35 | 10, 36 | 11, 37 | 12, 38 | }, 39 | }, 40 | days_of_month: ParsedDaysOfMonth { 41 | literals: { 42 | 1, 43 | 2, 44 | 3, 45 | 4, 46 | 5, 47 | 6, 48 | 7, 49 | 8, 50 | 9, 51 | 10, 52 | 11, 53 | 12, 54 | 13, 55 | 14, 56 | 15, 57 | 16, 58 | 17, 59 | 18, 60 | 19, 61 | 20, 62 | 21, 63 | 22, 64 | 23, 65 | 24, 66 | 25, 67 | 26, 68 | 27, 69 | 28, 70 | 29, 71 | 30, 72 | 31, 73 | }, 74 | last_day_of_month: false, 75 | nearest_weekdays: {}, 76 | start_with_asterisk: true, 77 | }, 78 | days_of_week: ParsedDaysOfWeek { 79 | literals: { 80 | 1, 81 | 2, 82 | 3, 83 | 4, 84 | 5, 85 | 6, 86 | 7, 87 | }, 88 | last_days_of_week: {}, 89 | nth_days_of_week: {}, 90 | start_with_asterisk: true, 91 | }, 92 | timezone: TimeZone( 93 | "UTC", 94 | ), 95 | } 96 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-21.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: true, 83 | }, 84 | timezone: TimeZone( 85 | "UTC", 86 | ), 87 | } 88 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-22.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 1 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 1, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: true, 83 | }, 84 | timezone: TimeZone( 85 | "UTC", 86 | ), 87 | } 88 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-23.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 2 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 2, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: true, 83 | }, 84 | timezone: TimeZone( 85 | "UTC", 86 | ), 87 | } 88 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-24.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 8 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 8, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: true, 83 | }, 84 | timezone: TimeZone( 85 | "UTC", 86 | ), 87 | } 88 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-25.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 9 * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 9, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: true, 83 | }, 84 | timezone: TimeZone( 85 | "UTC", 86 | ), 87 | } 88 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-26.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 0 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 7, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-27.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 1 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-28.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 2 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 2, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-29.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 3 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 3, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1-59/2 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 3, 10 | 5, 11 | 7, 12 | 9, 13 | 11, 14 | 13, 15 | 15, 16 | 17, 17 | 19, 18 | 21, 19 | 23, 20 | 25, 21 | 27, 22 | 29, 23 | 31, 24 | 33, 25 | 35, 26 | 37, 27 | 39, 28 | 41, 29 | 43, 30 | 45, 31 | 47, 32 | 49, 33 | 51, 34 | 53, 35 | 55, 36 | 57, 37 | 59, 38 | }, 39 | }, 40 | hours: PossibleLiterals { 41 | values: { 42 | 0, 43 | 1, 44 | 2, 45 | 3, 46 | 4, 47 | 5, 48 | 6, 49 | 7, 50 | 8, 51 | 9, 52 | 10, 53 | 11, 54 | 12, 55 | 13, 56 | 14, 57 | 15, 58 | 16, 59 | 17, 60 | 18, 61 | 19, 62 | 20, 63 | 21, 64 | 22, 65 | 23, 66 | }, 67 | }, 68 | months: PossibleLiterals { 69 | values: { 70 | 1, 71 | 2, 72 | 3, 73 | 4, 74 | 5, 75 | 6, 76 | 7, 77 | 8, 78 | 9, 79 | 10, 80 | 11, 81 | 12, 82 | }, 83 | }, 84 | days_of_month: ParsedDaysOfMonth { 85 | literals: { 86 | 1, 87 | 2, 88 | 3, 89 | 4, 90 | 5, 91 | 6, 92 | 7, 93 | 8, 94 | 9, 95 | 10, 96 | 11, 97 | 12, 98 | 13, 99 | 14, 100 | 15, 101 | 16, 102 | 17, 103 | 18, 104 | 19, 105 | 20, 106 | 21, 107 | 22, 108 | 23, 109 | 24, 110 | 25, 111 | 26, 112 | 27, 113 | 28, 114 | 29, 115 | 30, 116 | 31, 117 | }, 118 | last_day_of_month: false, 119 | nearest_weekdays: {}, 120 | start_with_asterisk: true, 121 | }, 122 | days_of_week: ParsedDaysOfWeek { 123 | literals: { 124 | 1, 125 | 2, 126 | 3, 127 | 4, 128 | 5, 129 | 6, 130 | 7, 131 | }, 132 | last_days_of_week: {}, 133 | nth_days_of_week: {}, 134 | start_with_asterisk: true, 135 | }, 136 | timezone: TimeZone( 137 | "UTC", 138 | ), 139 | } 140 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-30.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 4 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 4, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-31.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 5 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 5, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-32.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 6 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 6, 73 | }, 74 | last_days_of_week: {}, 75 | nth_days_of_week: {}, 76 | start_with_asterisk: false, 77 | }, 78 | timezone: TimeZone( 79 | "UTC", 80 | ), 81 | } 82 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-33.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 1-5 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | }, 78 | last_days_of_week: {}, 79 | nth_days_of_week: {}, 80 | start_with_asterisk: false, 81 | }, 82 | timezone: TimeZone( 83 | "UTC", 84 | ), 85 | } 86 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-34.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 * * 6,0 UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 6, 73 | 7, 74 | }, 75 | last_days_of_week: {}, 76 | nth_days_of_week: {}, 77 | start_with_asterisk: false, 78 | }, 79 | timezone: TimeZone( 80 | "UTC", 81 | ), 82 | } 83 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-35.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | }, 36 | last_day_of_month: false, 37 | nearest_weekdays: {}, 38 | start_with_asterisk: false, 39 | }, 40 | days_of_week: ParsedDaysOfWeek { 41 | literals: { 42 | 1, 43 | 2, 44 | 3, 45 | 4, 46 | 5, 47 | 6, 48 | 7, 49 | }, 50 | last_days_of_week: {}, 51 | nth_days_of_week: {}, 52 | start_with_asterisk: true, 53 | }, 54 | timezone: TimeZone( 55 | "UTC", 56 | ), 57 | } 58 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-36.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | }, 36 | last_day_of_month: false, 37 | nearest_weekdays: {}, 38 | start_with_asterisk: false, 39 | }, 40 | days_of_week: ParsedDaysOfWeek { 41 | literals: { 42 | 1, 43 | 2, 44 | 3, 45 | 4, 46 | 5, 47 | 6, 48 | 7, 49 | }, 50 | last_days_of_week: {}, 51 | nth_days_of_week: {}, 52 | start_with_asterisk: true, 53 | }, 54 | timezone: TimeZone( 55 | "UTC", 56 | ), 57 | } 58 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-37.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 */2 * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 3, 20 | 5, 21 | 7, 22 | 9, 23 | 11, 24 | }, 25 | }, 26 | days_of_month: ParsedDaysOfMonth { 27 | literals: { 28 | 1, 29 | }, 30 | last_day_of_month: false, 31 | nearest_weekdays: {}, 32 | start_with_asterisk: false, 33 | }, 34 | days_of_week: ParsedDaysOfWeek { 35 | literals: { 36 | 1, 37 | 2, 38 | 3, 39 | 4, 40 | 5, 41 | 6, 42 | 7, 43 | }, 44 | last_days_of_week: {}, 45 | nth_days_of_week: {}, 46 | start_with_asterisk: true, 47 | }, 48 | timezone: TimeZone( 49 | "UTC", 50 | ), 51 | } 52 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-38.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 */3 * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 4, 20 | 7, 21 | 10, 22 | }, 23 | }, 24 | days_of_month: ParsedDaysOfMonth { 25 | literals: { 26 | 1, 27 | }, 28 | last_day_of_month: false, 29 | nearest_weekdays: {}, 30 | start_with_asterisk: false, 31 | }, 32 | days_of_week: ParsedDaysOfWeek { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | }, 42 | last_days_of_week: {}, 43 | nth_days_of_week: {}, 44 | start_with_asterisk: true, 45 | }, 46 | timezone: TimeZone( 47 | "UTC", 48 | ), 49 | } 50 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-39.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 */6 * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 7, 20 | }, 21 | }, 22 | days_of_month: ParsedDaysOfMonth { 23 | literals: { 24 | 1, 25 | }, 26 | last_day_of_month: false, 27 | nearest_weekdays: {}, 28 | start_with_asterisk: false, 29 | }, 30 | days_of_week: ParsedDaysOfWeek { 31 | literals: { 32 | 1, 33 | 2, 34 | 3, 35 | 4, 36 | 5, 37 | 6, 38 | 7, 39 | }, 40 | last_days_of_week: {}, 41 | nth_days_of_week: {}, 42 | start_with_asterisk: true, 43 | }, 44 | timezone: TimeZone( 45 | "UTC", 46 | ), 47 | } 48 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/3 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 3, 10 | 6, 11 | 9, 12 | 12, 13 | 15, 14 | 18, 15 | 21, 16 | 24, 17 | 27, 18 | 30, 19 | 33, 20 | 36, 21 | 39, 22 | 42, 23 | 45, 24 | 48, 25 | 51, 26 | 54, 27 | 57, 28 | }, 29 | }, 30 | hours: PossibleLiterals { 31 | values: { 32 | 0, 33 | 1, 34 | 2, 35 | 3, 36 | 4, 37 | 5, 38 | 6, 39 | 7, 40 | 8, 41 | 9, 42 | 10, 43 | 11, 44 | 12, 45 | 13, 46 | 14, 47 | 15, 48 | 16, 49 | 17, 50 | 18, 51 | 19, 52 | 20, 53 | 21, 54 | 22, 55 | 23, 56 | }, 57 | }, 58 | months: PossibleLiterals { 59 | values: { 60 | 1, 61 | 2, 62 | 3, 63 | 4, 64 | 5, 65 | 6, 66 | 7, 67 | 8, 68 | 9, 69 | 10, 70 | 11, 71 | 12, 72 | }, 73 | }, 74 | days_of_month: ParsedDaysOfMonth { 75 | literals: { 76 | 1, 77 | 2, 78 | 3, 79 | 4, 80 | 5, 81 | 6, 82 | 7, 83 | 8, 84 | 9, 85 | 10, 86 | 11, 87 | 12, 88 | 13, 89 | 14, 90 | 15, 91 | 16, 92 | 17, 93 | 18, 94 | 19, 95 | 20, 96 | 21, 97 | 22, 98 | 23, 99 | 24, 100 | 25, 101 | 26, 102 | 27, 103 | 28, 104 | 29, 105 | 30, 106 | 31, 107 | }, 108 | last_day_of_month: false, 109 | nearest_weekdays: {}, 110 | start_with_asterisk: true, 111 | }, 112 | days_of_week: ParsedDaysOfWeek { 113 | literals: { 114 | 1, 115 | 2, 116 | 3, 117 | 4, 118 | 5, 119 | 6, 120 | 7, 121 | }, 122 | last_days_of_week: {}, 123 | nth_days_of_week: {}, 124 | start_with_asterisk: true, 125 | }, 126 | timezone: TimeZone( 127 | "UTC", 128 | ), 129 | } 130 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-40.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 1 * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | }, 20 | }, 21 | days_of_month: ParsedDaysOfMonth { 22 | literals: { 23 | 1, 24 | }, 25 | last_day_of_month: false, 26 | nearest_weekdays: {}, 27 | start_with_asterisk: false, 28 | }, 29 | days_of_week: ParsedDaysOfWeek { 30 | literals: { 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 6, 37 | 7, 38 | }, 39 | last_days_of_week: {}, 40 | nth_days_of_week: {}, 41 | start_with_asterisk: true, 42 | }, 43 | timezone: TimeZone( 44 | "UTC", 45 | ), 46 | } 47 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/4 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 4, 10 | 8, 11 | 12, 12 | 16, 13 | 20, 14 | 24, 15 | 28, 16 | 32, 17 | 36, 18 | 40, 19 | 44, 20 | 48, 21 | 52, 22 | 56, 23 | }, 24 | }, 25 | hours: PossibleLiterals { 26 | values: { 27 | 0, 28 | 1, 29 | 2, 30 | 3, 31 | 4, 32 | 5, 33 | 6, 34 | 7, 35 | 8, 36 | 9, 37 | 10, 38 | 11, 39 | 12, 40 | 13, 41 | 14, 42 | 15, 43 | 16, 44 | 17, 45 | 18, 46 | 19, 47 | 20, 48 | 21, 49 | 22, 50 | 23, 51 | }, 52 | }, 53 | months: PossibleLiterals { 54 | values: { 55 | 1, 56 | 2, 57 | 3, 58 | 4, 59 | 5, 60 | 6, 61 | 7, 62 | 8, 63 | 9, 64 | 10, 65 | 11, 66 | 12, 67 | }, 68 | }, 69 | days_of_month: ParsedDaysOfMonth { 70 | literals: { 71 | 1, 72 | 2, 73 | 3, 74 | 4, 75 | 5, 76 | 6, 77 | 7, 78 | 8, 79 | 9, 80 | 10, 81 | 11, 82 | 12, 83 | 13, 84 | 14, 85 | 15, 86 | 16, 87 | 17, 88 | 18, 89 | 19, 90 | 20, 91 | 21, 92 | 22, 93 | 23, 94 | 24, 95 | 25, 96 | 26, 97 | 27, 98 | 28, 99 | 29, 100 | 30, 101 | 31, 102 | }, 103 | last_day_of_month: false, 104 | nearest_weekdays: {}, 105 | start_with_asterisk: true, 106 | }, 107 | days_of_week: ParsedDaysOfWeek { 108 | literals: { 109 | 1, 110 | 2, 111 | 3, 112 | 4, 113 | 5, 114 | 6, 115 | 7, 116 | }, 117 | last_days_of_week: {}, 118 | nth_days_of_week: {}, 119 | start_with_asterisk: true, 120 | }, 121 | timezone: TimeZone( 122 | "UTC", 123 | ), 124 | } 125 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/5 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 5, 10 | 10, 11 | 15, 12 | 20, 13 | 25, 14 | 30, 15 | 35, 16 | 40, 17 | 45, 18 | 50, 19 | 55, 20 | }, 21 | }, 22 | hours: PossibleLiterals { 23 | values: { 24 | 0, 25 | 1, 26 | 2, 27 | 3, 28 | 4, 29 | 5, 30 | 6, 31 | 7, 32 | 8, 33 | 9, 34 | 10, 35 | 11, 36 | 12, 37 | 13, 38 | 14, 39 | 15, 40 | 16, 41 | 17, 42 | 18, 43 | 19, 44 | 20, 45 | 21, 46 | 22, 47 | 23, 48 | }, 49 | }, 50 | months: PossibleLiterals { 51 | values: { 52 | 1, 53 | 2, 54 | 3, 55 | 4, 56 | 5, 57 | 6, 58 | 7, 59 | 8, 60 | 9, 61 | 10, 62 | 11, 63 | 12, 64 | }, 65 | }, 66 | days_of_month: ParsedDaysOfMonth { 67 | literals: { 68 | 1, 69 | 2, 70 | 3, 71 | 4, 72 | 5, 73 | 6, 74 | 7, 75 | 8, 76 | 9, 77 | 10, 78 | 11, 79 | 12, 80 | 13, 81 | 14, 82 | 15, 83 | 16, 84 | 17, 85 | 18, 86 | 19, 87 | 20, 88 | 21, 89 | 22, 90 | 23, 91 | 24, 92 | 25, 93 | 26, 94 | 27, 95 | 28, 96 | 29, 97 | 30, 98 | 31, 99 | }, 100 | last_day_of_month: false, 101 | nearest_weekdays: {}, 102 | start_with_asterisk: true, 103 | }, 104 | days_of_week: ParsedDaysOfWeek { 105 | literals: { 106 | 1, 107 | 2, 108 | 3, 109 | 4, 110 | 5, 111 | 6, 112 | 7, 113 | }, 114 | last_days_of_week: {}, 115 | nth_days_of_week: {}, 116 | start_with_asterisk: true, 117 | }, 118 | timezone: TimeZone( 119 | "UTC", 120 | ), 121 | } 122 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/6 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 6, 10 | 12, 11 | 18, 12 | 24, 13 | 30, 14 | 36, 15 | 42, 16 | 48, 17 | 54, 18 | }, 19 | }, 20 | hours: PossibleLiterals { 21 | values: { 22 | 0, 23 | 1, 24 | 2, 25 | 3, 26 | 4, 27 | 5, 28 | 6, 29 | 7, 30 | 8, 31 | 9, 32 | 10, 33 | 11, 34 | 12, 35 | 13, 36 | 14, 37 | 15, 38 | 16, 39 | 17, 40 | 18, 41 | 19, 42 | 20, 43 | 21, 44 | 22, 45 | 23, 46 | }, 47 | }, 48 | months: PossibleLiterals { 49 | values: { 50 | 1, 51 | 2, 52 | 3, 53 | 4, 54 | 5, 55 | 6, 56 | 7, 57 | 8, 58 | 9, 59 | 10, 60 | 11, 61 | 12, 62 | }, 63 | }, 64 | days_of_month: ParsedDaysOfMonth { 65 | literals: { 66 | 1, 67 | 2, 68 | 3, 69 | 4, 70 | 5, 71 | 6, 72 | 7, 73 | 8, 74 | 9, 75 | 10, 76 | 11, 77 | 12, 78 | 13, 79 | 14, 80 | 15, 81 | 16, 82 | 17, 83 | 18, 84 | 19, 85 | 20, 86 | 21, 87 | 22, 88 | 23, 89 | 24, 90 | 25, 91 | 26, 92 | 27, 93 | 28, 94 | 29, 95 | 30, 96 | 31, 97 | }, 98 | last_day_of_month: false, 99 | nearest_weekdays: {}, 100 | start_with_asterisk: true, 101 | }, 102 | days_of_week: ParsedDaysOfWeek { 103 | literals: { 104 | 1, 105 | 2, 106 | 3, 107 | 4, 108 | 5, 109 | 6, 110 | 7, 111 | }, 112 | last_days_of_week: {}, 113 | nth_days_of_week: {}, 114 | start_with_asterisk: true, 115 | }, 116 | timezone: TimeZone( 117 | "UTC", 118 | ), 119 | } 120 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/10 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 10, 10 | 20, 11 | 30, 12 | 40, 13 | 50, 14 | }, 15 | }, 16 | hours: PossibleLiterals { 17 | values: { 18 | 0, 19 | 1, 20 | 2, 21 | 3, 22 | 4, 23 | 5, 24 | 6, 25 | 7, 26 | 8, 27 | 9, 28 | 10, 29 | 11, 30 | 12, 31 | 13, 32 | 14, 33 | 15, 34 | 16, 35 | 17, 36 | 18, 37 | 19, 38 | 20, 39 | 21, 40 | 22, 41 | 23, 42 | }, 43 | }, 44 | months: PossibleLiterals { 45 | values: { 46 | 1, 47 | 2, 48 | 3, 49 | 4, 50 | 5, 51 | 6, 52 | 7, 53 | 8, 54 | 9, 55 | 10, 56 | 11, 57 | 12, 58 | }, 59 | }, 60 | days_of_month: ParsedDaysOfMonth { 61 | literals: { 62 | 1, 63 | 2, 64 | 3, 65 | 4, 66 | 5, 67 | 6, 68 | 7, 69 | 8, 70 | 9, 71 | 10, 72 | 11, 73 | 12, 74 | 13, 75 | 14, 76 | 15, 77 | 16, 78 | 17, 79 | 18, 80 | 19, 81 | 20, 82 | 21, 83 | 22, 84 | 23, 85 | 24, 86 | 25, 87 | 26, 88 | 27, 89 | 28, 90 | 29, 91 | 30, 92 | 31, 93 | }, 94 | last_day_of_month: false, 95 | nearest_weekdays: {}, 96 | start_with_asterisk: true, 97 | }, 98 | days_of_week: ParsedDaysOfWeek { 99 | literals: { 100 | 1, 101 | 2, 102 | 3, 103 | 4, 104 | 5, 105 | 6, 106 | 7, 107 | }, 108 | last_days_of_week: {}, 109 | nth_days_of_week: {}, 110 | start_with_asterisk: true, 111 | }, 112 | timezone: TimeZone( 113 | "UTC", 114 | ), 115 | } 116 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples-9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/15 * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 15, 10 | 30, 11 | 45, 12 | }, 13 | }, 14 | hours: PossibleLiterals { 15 | values: { 16 | 0, 17 | 1, 18 | 2, 19 | 3, 20 | 4, 21 | 5, 22 | 6, 23 | 7, 24 | 8, 25 | 9, 26 | 10, 27 | 11, 28 | 12, 29 | 13, 30 | 14, 31 | 15, 32 | 16, 33 | 17, 34 | 18, 35 | 19, 36 | 20, 37 | 21, 38 | 22, 39 | 23, 40 | }, 41 | }, 42 | months: PossibleLiterals { 43 | values: { 44 | 1, 45 | 2, 46 | 3, 47 | 4, 48 | 5, 49 | 6, 50 | 7, 51 | 8, 52 | 9, 53 | 10, 54 | 11, 55 | 12, 56 | }, 57 | }, 58 | days_of_month: ParsedDaysOfMonth { 59 | literals: { 60 | 1, 61 | 2, 62 | 3, 63 | 4, 64 | 5, 65 | 6, 66 | 7, 67 | 8, 68 | 9, 69 | 10, 70 | 11, 71 | 12, 72 | 13, 73 | 14, 74 | 15, 75 | 16, 76 | 17, 77 | 18, 78 | 19, 79 | 20, 80 | 21, 81 | 22, 82 | 23, 83 | 24, 84 | 25, 85 | 26, 86 | 27, 87 | 28, 88 | 29, 89 | 30, 90 | 31, 91 | }, 92 | last_day_of_month: false, 93 | nearest_weekdays: {}, 94 | start_with_asterisk: true, 95 | }, 96 | days_of_week: ParsedDaysOfWeek { 97 | literals: { 98 | 1, 99 | 2, 100 | 3, 101 | 4, 102 | 5, 103 | 6, 104 | 7, 105 | }, 106 | last_days_of_week: {}, 107 | nth_days_of_week: {}, 108 | start_with_asterisk: true, 109 | }, 110 | timezone: TimeZone( 111 | "UTC", 112 | ), 113 | } 114 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__crontab_guru_examples.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"* * * * * UTC\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 1, 10 | 2, 11 | 3, 12 | 4, 13 | 5, 14 | 6, 15 | 7, 16 | 8, 17 | 9, 18 | 10, 19 | 11, 20 | 12, 21 | 13, 22 | 14, 23 | 15, 24 | 16, 25 | 17, 26 | 18, 27 | 19, 28 | 20, 29 | 21, 30 | 22, 31 | 23, 32 | 24, 33 | 25, 34 | 26, 35 | 27, 36 | 28, 37 | 29, 38 | 30, 39 | 31, 40 | 32, 41 | 33, 42 | 34, 43 | 35, 44 | 36, 45 | 37, 46 | 38, 47 | 39, 48 | 40, 49 | 41, 50 | 42, 51 | 43, 52 | 44, 53 | 45, 54 | 46, 55 | 47, 56 | 48, 57 | 49, 58 | 50, 59 | 51, 60 | 52, 61 | 53, 62 | 54, 63 | 55, 64 | 56, 65 | 57, 66 | 58, 67 | 59, 68 | }, 69 | }, 70 | hours: PossibleLiterals { 71 | values: { 72 | 0, 73 | 1, 74 | 2, 75 | 3, 76 | 4, 77 | 5, 78 | 6, 79 | 7, 80 | 8, 81 | 9, 82 | 10, 83 | 11, 84 | 12, 85 | 13, 86 | 14, 87 | 15, 88 | 16, 89 | 17, 90 | 18, 91 | 19, 92 | 20, 93 | 21, 94 | 22, 95 | 23, 96 | }, 97 | }, 98 | months: PossibleLiterals { 99 | values: { 100 | 1, 101 | 2, 102 | 3, 103 | 4, 104 | 5, 105 | 6, 106 | 7, 107 | 8, 108 | 9, 109 | 10, 110 | 11, 111 | 12, 112 | }, 113 | }, 114 | days_of_month: ParsedDaysOfMonth { 115 | literals: { 116 | 1, 117 | 2, 118 | 3, 119 | 4, 120 | 5, 121 | 6, 122 | 7, 123 | 8, 124 | 9, 125 | 10, 126 | 11, 127 | 12, 128 | 13, 129 | 14, 130 | 15, 131 | 16, 132 | 17, 133 | 18, 134 | 19, 135 | 20, 136 | 21, 137 | 22, 138 | 23, 139 | 24, 140 | 25, 141 | 26, 142 | 27, 143 | 28, 144 | 29, 145 | 30, 146 | 31, 147 | }, 148 | last_day_of_month: false, 149 | nearest_weekdays: {}, 150 | start_with_asterisk: true, 151 | }, 152 | days_of_week: ParsedDaysOfWeek { 153 | literals: { 154 | 1, 155 | 2, 156 | 3, 157 | 4, 158 | 5, 159 | 6, 160 | 7, 161 | }, 162 | last_days_of_week: {}, 163 | nth_days_of_week: {}, 164 | start_with_asterisk: true, 165 | }, 166 | timezone: TimeZone( 167 | "UTC", 168 | ), 169 | } 170 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-10.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"29 ** * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 29 ** * * * Asia/Shanghai 7 | ^ malformed expression 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"29--30 * * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 29--30 * * * * Asia/Shanghai 7 | ^ malformed expression 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-12.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1,2,10,100 1 1 1 * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 1,2,10,100 1 1 1 * Asia/Shanghai 7 | ^ value must be in range 0..=59; found 100 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"104,2,10,100 1 1 1 * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 104,2,10,100 1 1 1 * Asia/Shanghai 7 | ^ value must be in range 0..=59; found 104 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-14.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1,2,10 * * 104,2,10,100 * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 1,2,10 * * 104,2,10,100 * Asia/Shanghai 7 | ^ value must be in range 1..=12; found 104 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-15.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1-10,2,10,50 1 * 1 TTT Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 1-10,2,10,50 1 * 1 TTT Asia/Shanghai 7 | ^ malformed expression 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-16.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 7 | ^ missing hours 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-17.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 7 | ^ missing days of month 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-18.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 1 7 | ^ missing months 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-19.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 1\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 1 1 7 | ^ missing days of week 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"* * * * * Unknown/Timezone\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | * * * * * Unknown/Timezone 7 | ^ failed to find timezone Unknown/Timezone; for a list of time zones, see the list of tz database time zones on Wikipedia: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-20.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 1 5\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 1 1 5 7 | ^ missing timezone 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-21.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 1 5 \").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 1 1 5 7 | ^ missing timezone 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-22.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 1 5 Z\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 1 1 5 Z 7 | ^ failed to find timezone Z; for a list of time zones, see the list of tz database time zones on Wikipedia: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-23.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"0 0 1 1 5 Z Z\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 0 0 1 1 5 Z Z 7 | ^ failed to find timezone Z Z; for a list of time zones, see the list of tz database time zones on Wikipedia: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-24.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 7 | ^ cannot be empty 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-25.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"H * * * * UTC\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | H * * * * UTC 7 | ^ malformed expression 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"* 5-4 * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | * 5-4 * * * Asia/Shanghai 7 | ^ range must be in ascending order; found 5-4 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"10086 * * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 10086 * * * * Asia/Shanghai 7 | ^ value must be in range 0..=59; found 10086 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"* 0-24 * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | * 0-24 * * * Asia/Shanghai 7 | ^ value must be in range 0..=23; found 24 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"* * * 25 * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | * * * 25 * Asia/Shanghai 7 | ^ value must be in range 1..=12; found 25 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"32-300 * * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 32-300 * * * * Asia/Shanghai 7 | ^ value must be in range 0..=59; found 300 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"129-300 * * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 129-300 * * * * Asia/Shanghai 7 | ^ value must be in range 0..=59; found 129 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed-9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"29- * * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | 29- * * * * Asia/Shanghai 7 | ^ malformed expression 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_failed.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"invalid 4 * * * Asia/Shanghai\").unwrap_err()" 4 | --- 5 | failed to parse crontab expression: 6 | invalid 4 * * * Asia/Shanghai 7 | ^ malformed expression 8 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-10.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1-10,2,10,50 1 1 1 * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 2, 10 | 3, 11 | 4, 12 | 5, 13 | 6, 14 | 7, 15 | 8, 16 | 9, 17 | 10, 18 | 50, 19 | }, 20 | }, 21 | hours: PossibleLiterals { 22 | values: { 23 | 1, 24 | }, 25 | }, 26 | months: PossibleLiterals { 27 | values: { 28 | 1, 29 | }, 30 | }, 31 | days_of_month: ParsedDaysOfMonth { 32 | literals: { 33 | 1, 34 | }, 35 | last_day_of_month: false, 36 | nearest_weekdays: {}, 37 | start_with_asterisk: false, 38 | }, 39 | days_of_week: ParsedDaysOfWeek { 40 | literals: { 41 | 1, 42 | 2, 43 | 3, 44 | 4, 45 | 5, 46 | 6, 47 | 7, 48 | }, 49 | last_days_of_week: {}, 50 | nth_days_of_week: {}, 51 | start_with_asterisk: true, 52 | }, 53 | timezone: TimeZone( 54 | TZif( 55 | "Asia/Shanghai", 56 | ), 57 | ), 58 | } 59 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1-10,2,10,50 1 * 1 TUE Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 2, 10 | 3, 11 | 4, 12 | 5, 13 | 6, 14 | 7, 15 | 8, 16 | 9, 17 | 10, 18 | 50, 19 | }, 20 | }, 21 | hours: PossibleLiterals { 22 | values: { 23 | 1, 24 | }, 25 | }, 26 | months: PossibleLiterals { 27 | values: { 28 | 1, 29 | }, 30 | }, 31 | days_of_month: ParsedDaysOfMonth { 32 | literals: { 33 | 1, 34 | 2, 35 | 3, 36 | 4, 37 | 5, 38 | 6, 39 | 7, 40 | 8, 41 | 9, 42 | 10, 43 | 11, 44 | 12, 45 | 13, 46 | 14, 47 | 15, 48 | 16, 49 | 17, 50 | 18, 51 | 19, 52 | 20, 53 | 21, 54 | 22, 55 | 23, 56 | 24, 57 | 25, 58 | 26, 59 | 27, 60 | 28, 61 | 29, 62 | 30, 63 | 31, 64 | }, 65 | last_day_of_month: false, 66 | nearest_weekdays: {}, 67 | start_with_asterisk: true, 68 | }, 69 | days_of_week: ParsedDaysOfWeek { 70 | literals: { 71 | 2, 72 | }, 73 | last_days_of_week: {}, 74 | nth_days_of_week: {}, 75 | start_with_asterisk: false, 76 | }, 77 | timezone: TimeZone( 78 | TZif( 79 | "Asia/Shanghai", 80 | ), 81 | ), 82 | } 83 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-12.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab_with(\"0 0 1 1 5\", options).unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | }, 20 | }, 21 | days_of_month: ParsedDaysOfMonth { 22 | literals: { 23 | 1, 24 | }, 25 | last_day_of_month: false, 26 | nearest_weekdays: {}, 27 | start_with_asterisk: false, 28 | }, 29 | days_of_week: ParsedDaysOfWeek { 30 | literals: { 31 | 5, 32 | }, 33 | last_days_of_week: {}, 34 | nth_days_of_week: {}, 35 | start_with_asterisk: false, 36 | }, 37 | timezone: TimeZone( 38 | "UTC", 39 | ), 40 | } 41 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab_with(\"0 0 1 1 5 \", options).unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | }, 20 | }, 21 | days_of_month: ParsedDaysOfMonth { 22 | literals: { 23 | 1, 24 | }, 25 | last_day_of_month: false, 26 | nearest_weekdays: {}, 27 | start_with_asterisk: false, 28 | }, 29 | days_of_week: ParsedDaysOfWeek { 30 | literals: { 31 | 5, 32 | }, 33 | last_days_of_week: {}, 34 | nth_days_of_week: {}, 35 | start_with_asterisk: false, 36 | }, 37 | timezone: TimeZone( 38 | "UTC", 39 | ), 40 | } 41 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-14.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab_with(\"0 0 1 1 5\", options).unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | }, 20 | }, 21 | days_of_month: ParsedDaysOfMonth { 22 | literals: { 23 | 1, 24 | }, 25 | last_day_of_month: false, 26 | nearest_weekdays: {}, 27 | start_with_asterisk: false, 28 | }, 29 | days_of_week: ParsedDaysOfWeek { 30 | literals: { 31 | 5, 32 | }, 33 | last_days_of_week: {}, 34 | nth_days_of_week: {}, 35 | start_with_asterisk: false, 36 | }, 37 | timezone: TimeZone( 38 | [SYSTEM], 39 | ), 40 | } 41 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-15.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab_with(\"0 0 1 1 5 \", options).unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | }, 20 | }, 21 | days_of_month: ParsedDaysOfMonth { 22 | literals: { 23 | 1, 24 | }, 25 | last_day_of_month: false, 26 | nearest_weekdays: {}, 27 | start_with_asterisk: false, 28 | }, 29 | days_of_week: ParsedDaysOfWeek { 30 | literals: { 31 | 5, 32 | }, 33 | last_days_of_week: {}, 34 | nth_days_of_week: {}, 35 | start_with_asterisk: false, 36 | }, 37 | timezone: TimeZone( 38 | [SYSTEM], 39 | ), 40 | } 41 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-16.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab_with(\"H * * * * America/Denver\", options).unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 42, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 0, 14 | 1, 15 | 2, 16 | 3, 17 | 4, 18 | 5, 19 | 6, 20 | 7, 21 | 8, 22 | 9, 23 | 10, 24 | 11, 25 | 12, 26 | 13, 27 | 14, 28 | 15, 29 | 16, 30 | 17, 31 | 18, 32 | 19, 33 | 20, 34 | 21, 35 | 22, 36 | 23, 37 | }, 38 | }, 39 | months: PossibleLiterals { 40 | values: { 41 | 1, 42 | 2, 43 | 3, 44 | 4, 45 | 5, 46 | 6, 47 | 7, 48 | 8, 49 | 9, 50 | 10, 51 | 11, 52 | 12, 53 | }, 54 | }, 55 | days_of_month: ParsedDaysOfMonth { 56 | literals: { 57 | 1, 58 | 2, 59 | 3, 60 | 4, 61 | 5, 62 | 6, 63 | 7, 64 | 8, 65 | 9, 66 | 10, 67 | 11, 68 | 12, 69 | 13, 70 | 14, 71 | 15, 72 | 16, 73 | 17, 74 | 18, 75 | 19, 76 | 20, 77 | 21, 78 | 22, 79 | 23, 80 | 24, 81 | 25, 82 | 26, 83 | 27, 84 | 28, 85 | 29, 86 | 30, 87 | 31, 88 | }, 89 | last_day_of_month: false, 90 | nearest_weekdays: {}, 91 | start_with_asterisk: true, 92 | }, 93 | days_of_week: ParsedDaysOfWeek { 94 | literals: { 95 | 1, 96 | 2, 97 | 3, 98 | 4, 99 | 5, 100 | 6, 101 | 7, 102 | }, 103 | last_days_of_week: {}, 104 | nth_days_of_week: {}, 105 | start_with_asterisk: true, 106 | }, 107 | timezone: TimeZone( 108 | TZif( 109 | "America/Denver", 110 | ), 111 | ), 112 | } 113 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-17.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab_with(\"H H H H H America/Denver\", options).unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 42, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 18, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 7, 19 | }, 20 | }, 21 | days_of_month: ParsedDaysOfMonth { 22 | literals: { 23 | 12, 24 | }, 25 | last_day_of_month: false, 26 | nearest_weekdays: {}, 27 | start_with_asterisk: false, 28 | }, 29 | days_of_week: ParsedDaysOfWeek { 30 | literals: { 31 | 2, 32 | }, 33 | last_days_of_week: {}, 34 | nth_days_of_week: {}, 35 | start_with_asterisk: false, 36 | }, 37 | timezone: TimeZone( 38 | TZif( 39 | "America/Denver", 40 | ), 41 | ), 42 | } 43 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"2 4 * * * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 2, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 4, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: true, 83 | }, 84 | timezone: TimeZone( 85 | TZif( 86 | "Asia/Shanghai", 87 | ), 88 | ), 89 | } 90 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"2 4 * * 0-6 Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 2, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 4, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 2, 36 | 3, 37 | 4, 38 | 5, 39 | 6, 40 | 7, 41 | 8, 42 | 9, 43 | 10, 44 | 11, 45 | 12, 46 | 13, 47 | 14, 48 | 15, 49 | 16, 50 | 17, 51 | 18, 52 | 19, 53 | 20, 54 | 21, 55 | 22, 56 | 23, 57 | 24, 58 | 25, 59 | 26, 60 | 27, 61 | 28, 62 | 29, 63 | 30, 64 | 31, 65 | }, 66 | last_day_of_month: false, 67 | nearest_weekdays: {}, 68 | start_with_asterisk: true, 69 | }, 70 | days_of_week: ParsedDaysOfWeek { 71 | literals: { 72 | 1, 73 | 2, 74 | 3, 75 | 4, 76 | 5, 77 | 6, 78 | 7, 79 | }, 80 | last_days_of_week: {}, 81 | nth_days_of_week: {}, 82 | start_with_asterisk: false, 83 | }, 84 | timezone: TimeZone( 85 | TZif( 86 | "Asia/Shanghai", 87 | ), 88 | ), 89 | } 90 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"2 4 */3 * 0-6 Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 2, 9 | }, 10 | }, 11 | hours: PossibleLiterals { 12 | values: { 13 | 4, 14 | }, 15 | }, 16 | months: PossibleLiterals { 17 | values: { 18 | 1, 19 | 2, 20 | 3, 21 | 4, 22 | 5, 23 | 6, 24 | 7, 25 | 8, 26 | 9, 27 | 10, 28 | 11, 29 | 12, 30 | }, 31 | }, 32 | days_of_month: ParsedDaysOfMonth { 33 | literals: { 34 | 1, 35 | 4, 36 | 7, 37 | 10, 38 | 13, 39 | 16, 40 | 19, 41 | 22, 42 | 25, 43 | 28, 44 | 31, 45 | }, 46 | last_day_of_month: false, 47 | nearest_weekdays: {}, 48 | start_with_asterisk: true, 49 | }, 50 | days_of_week: ParsedDaysOfWeek { 51 | literals: { 52 | 1, 53 | 2, 54 | 3, 55 | 4, 56 | 5, 57 | 6, 58 | 7, 59 | }, 60 | last_days_of_week: {}, 61 | nth_days_of_week: {}, 62 | start_with_asterisk: false, 63 | }, 64 | timezone: TimeZone( 65 | TZif( 66 | "Asia/Shanghai", 67 | ), 68 | ), 69 | } 70 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"*/2 1 1 1 * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 2, 10 | 4, 11 | 6, 12 | 8, 13 | 10, 14 | 12, 15 | 14, 16 | 16, 17 | 18, 18 | 20, 19 | 22, 20 | 24, 21 | 26, 22 | 28, 23 | 30, 24 | 32, 25 | 34, 26 | 36, 27 | 38, 28 | 40, 29 | 42, 30 | 44, 31 | 46, 32 | 48, 33 | 50, 34 | 52, 35 | 54, 36 | 56, 37 | 58, 38 | }, 39 | }, 40 | hours: PossibleLiterals { 41 | values: { 42 | 1, 43 | }, 44 | }, 45 | months: PossibleLiterals { 46 | values: { 47 | 1, 48 | }, 49 | }, 50 | days_of_month: ParsedDaysOfMonth { 51 | literals: { 52 | 1, 53 | }, 54 | last_day_of_month: false, 55 | nearest_weekdays: {}, 56 | start_with_asterisk: false, 57 | }, 58 | days_of_week: ParsedDaysOfWeek { 59 | literals: { 60 | 1, 61 | 2, 62 | 3, 63 | 4, 64 | 5, 65 | 6, 66 | 7, 67 | }, 68 | last_days_of_week: {}, 69 | nth_days_of_week: {}, 70 | start_with_asterisk: true, 71 | }, 72 | timezone: TimeZone( 73 | TZif( 74 | "Asia/Shanghai", 75 | ), 76 | ), 77 | } 78 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1/2 1 1 1 * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 3, 10 | 5, 11 | 7, 12 | 9, 13 | 11, 14 | 13, 15 | 15, 16 | 17, 17 | 19, 18 | 21, 19 | 23, 20 | 25, 21 | 27, 22 | 29, 23 | 31, 24 | 33, 25 | 35, 26 | 37, 27 | 39, 28 | 41, 29 | 43, 30 | 45, 31 | 47, 32 | 49, 33 | 51, 34 | 53, 35 | 55, 36 | 57, 37 | 59, 38 | }, 39 | }, 40 | hours: PossibleLiterals { 41 | values: { 42 | 1, 43 | }, 44 | }, 45 | months: PossibleLiterals { 46 | values: { 47 | 1, 48 | }, 49 | }, 50 | days_of_month: ParsedDaysOfMonth { 51 | literals: { 52 | 1, 53 | }, 54 | last_day_of_month: false, 55 | nearest_weekdays: {}, 56 | start_with_asterisk: false, 57 | }, 58 | days_of_week: ParsedDaysOfWeek { 59 | literals: { 60 | 1, 61 | 2, 62 | 3, 63 | 4, 64 | 5, 65 | 6, 66 | 7, 67 | }, 68 | last_days_of_week: {}, 69 | nth_days_of_week: {}, 70 | start_with_asterisk: true, 71 | }, 72 | timezone: TimeZone( 73 | TZif( 74 | "Asia/Shanghai", 75 | ), 76 | ), 77 | } 78 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1-29/2 1 1 1 * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 3, 10 | 5, 11 | 7, 12 | 9, 13 | 11, 14 | 13, 15 | 15, 16 | 17, 17 | 19, 18 | 21, 19 | 23, 20 | 25, 21 | 27, 22 | 29, 23 | }, 24 | }, 25 | hours: PossibleLiterals { 26 | values: { 27 | 1, 28 | }, 29 | }, 30 | months: PossibleLiterals { 31 | values: { 32 | 1, 33 | }, 34 | }, 35 | days_of_month: ParsedDaysOfMonth { 36 | literals: { 37 | 1, 38 | }, 39 | last_day_of_month: false, 40 | nearest_weekdays: {}, 41 | start_with_asterisk: false, 42 | }, 43 | days_of_week: ParsedDaysOfWeek { 44 | literals: { 45 | 1, 46 | 2, 47 | 3, 48 | 4, 49 | 5, 50 | 6, 51 | 7, 52 | }, 53 | last_days_of_week: {}, 54 | nth_days_of_week: {}, 55 | start_with_asterisk: true, 56 | }, 57 | timezone: TimeZone( 58 | TZif( 59 | "Asia/Shanghai", 60 | ), 61 | ), 62 | } 63 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1-30/2 1 1 1 * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 3, 10 | 5, 11 | 7, 12 | 9, 13 | 11, 14 | 13, 15 | 15, 16 | 17, 17 | 19, 18 | 21, 19 | 23, 20 | 25, 21 | 27, 22 | 29, 23 | }, 24 | }, 25 | hours: PossibleLiterals { 26 | values: { 27 | 1, 28 | }, 29 | }, 30 | months: PossibleLiterals { 31 | values: { 32 | 1, 33 | }, 34 | }, 35 | days_of_month: ParsedDaysOfMonth { 36 | literals: { 37 | 1, 38 | }, 39 | last_day_of_month: false, 40 | nearest_weekdays: {}, 41 | start_with_asterisk: false, 42 | }, 43 | days_of_week: ParsedDaysOfWeek { 44 | literals: { 45 | 1, 46 | 2, 47 | 3, 48 | 4, 49 | 5, 50 | 6, 51 | 7, 52 | }, 53 | last_days_of_week: {}, 54 | nth_days_of_week: {}, 55 | start_with_asterisk: true, 56 | }, 57 | timezone: TimeZone( 58 | TZif( 59 | "Asia/Shanghai", 60 | ), 61 | ), 62 | } 63 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success-9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"1,2,10 1 1 1 * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 1, 9 | 2, 10 | 10, 11 | }, 12 | }, 13 | hours: PossibleLiterals { 14 | values: { 15 | 1, 16 | }, 17 | }, 18 | months: PossibleLiterals { 19 | values: { 20 | 1, 21 | }, 22 | }, 23 | days_of_month: ParsedDaysOfMonth { 24 | literals: { 25 | 1, 26 | }, 27 | last_day_of_month: false, 28 | nearest_weekdays: {}, 29 | start_with_asterisk: false, 30 | }, 31 | days_of_week: ParsedDaysOfWeek { 32 | literals: { 33 | 1, 34 | 2, 35 | 3, 36 | 4, 37 | 5, 38 | 6, 39 | 7, 40 | }, 41 | last_days_of_week: {}, 42 | nth_days_of_week: {}, 43 | start_with_asterisk: true, 44 | }, 45 | timezone: TimeZone( 46 | TZif( 47 | "Asia/Shanghai", 48 | ), 49 | ), 50 | } 51 | -------------------------------------------------------------------------------- /src/snapshots/cronexpr__parser__tests__parse_crontab_success.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/parser.rs 3 | expression: "parse_crontab(\"* * * * * Asia/Shanghai\").unwrap()" 4 | --- 5 | Crontab { 6 | minutes: PossibleLiterals { 7 | values: { 8 | 0, 9 | 1, 10 | 2, 11 | 3, 12 | 4, 13 | 5, 14 | 6, 15 | 7, 16 | 8, 17 | 9, 18 | 10, 19 | 11, 20 | 12, 21 | 13, 22 | 14, 23 | 15, 24 | 16, 25 | 17, 26 | 18, 27 | 19, 28 | 20, 29 | 21, 30 | 22, 31 | 23, 32 | 24, 33 | 25, 34 | 26, 35 | 27, 36 | 28, 37 | 29, 38 | 30, 39 | 31, 40 | 32, 41 | 33, 42 | 34, 43 | 35, 44 | 36, 45 | 37, 46 | 38, 47 | 39, 48 | 40, 49 | 41, 50 | 42, 51 | 43, 52 | 44, 53 | 45, 54 | 46, 55 | 47, 56 | 48, 57 | 49, 58 | 50, 59 | 51, 60 | 52, 61 | 53, 62 | 54, 63 | 55, 64 | 56, 65 | 57, 66 | 58, 67 | 59, 68 | }, 69 | }, 70 | hours: PossibleLiterals { 71 | values: { 72 | 0, 73 | 1, 74 | 2, 75 | 3, 76 | 4, 77 | 5, 78 | 6, 79 | 7, 80 | 8, 81 | 9, 82 | 10, 83 | 11, 84 | 12, 85 | 13, 86 | 14, 87 | 15, 88 | 16, 89 | 17, 90 | 18, 91 | 19, 92 | 20, 93 | 21, 94 | 22, 95 | 23, 96 | }, 97 | }, 98 | months: PossibleLiterals { 99 | values: { 100 | 1, 101 | 2, 102 | 3, 103 | 4, 104 | 5, 105 | 6, 106 | 7, 107 | 8, 108 | 9, 109 | 10, 110 | 11, 111 | 12, 112 | }, 113 | }, 114 | days_of_month: ParsedDaysOfMonth { 115 | literals: { 116 | 1, 117 | 2, 118 | 3, 119 | 4, 120 | 5, 121 | 6, 122 | 7, 123 | 8, 124 | 9, 125 | 10, 126 | 11, 127 | 12, 128 | 13, 129 | 14, 130 | 15, 131 | 16, 132 | 17, 133 | 18, 134 | 19, 135 | 20, 136 | 21, 137 | 22, 138 | 23, 139 | 24, 140 | 25, 141 | 26, 142 | 27, 143 | 28, 144 | 29, 145 | 30, 146 | 31, 147 | }, 148 | last_day_of_month: false, 149 | nearest_weekdays: {}, 150 | start_with_asterisk: true, 151 | }, 152 | days_of_week: ParsedDaysOfWeek { 153 | literals: { 154 | 1, 155 | 2, 156 | 3, 157 | 4, 158 | 5, 159 | 6, 160 | 7, 161 | }, 162 | last_days_of_week: {}, 163 | nth_days_of_week: {}, 164 | start_with_asterisk: true, 165 | }, 166 | timezone: TimeZone( 167 | TZif( 168 | "Asia/Shanghai", 169 | ), 170 | ), 171 | } 172 | -------------------------------------------------------------------------------- /taplo.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include = ["Cargo.toml", "**/*.toml"] 16 | 17 | [formatting] 18 | # Align consecutive entries vertically. 19 | align_entries = false 20 | # Append trailing commas for multi-line arrays. 21 | array_trailing_comma = true 22 | # Expand arrays to multiple lines that exceed the maximum column width. 23 | array_auto_expand = true 24 | # Collapse arrays that don't exceed the maximum column width and don't contain comments. 25 | array_auto_collapse = true 26 | # Omit white space padding from single-line arrays 27 | compact_arrays = true 28 | # Omit white space padding from the start and end of inline tables. 29 | compact_inline_tables = false 30 | # Maximum column width in characters, affects array expansion and collapse, this doesn't take whitespace into account. 31 | # Note that this is not set in stone, and works on a best-effort basis. 32 | column_width = 80 33 | # Indent based on tables and arrays of tables and their subtables, subtables out of order are not indented. 34 | indent_tables = false 35 | # The substring that is used for indentation, should be tabs or spaces (but technically can be anything). 36 | indent_string = ' ' 37 | # Add trailing newline at the end of the file if not present. 38 | trailing_newline = true 39 | # Alphabetically reorder keys that are not separated by empty lines. 40 | reorder_keys = true 41 | # Maximum amount of allowed consecutive blank lines. This does not affect the whitespace at the end of the document, as it is always stripped. 42 | allowed_blank_lines = 1 43 | # Use CRLF for line endings. 44 | crlf = false 45 | -------------------------------------------------------------------------------- /typos.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 tison 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | [default.extend-words] 16 | 17 | [files] 18 | extend-exclude = [] 19 | --------------------------------------------------------------------------------