{"id":27154364,"url":"https://github.com/scogun/kcron-common","last_synced_at":"2026-01-11T17:33:59.399Z","repository":{"id":40548069,"uuid":"309119232","full_name":"Scogun/kcron-common","owner":"Scogun","description":"Cron realization for Kotlin Multiplatform","archived":false,"fork":false,"pushed_at":"2025-03-14T14:12:51.000Z","size":452,"stargazers_count":29,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T03:34:44.408Z","etag":null,"topics":["cron","kotlin","kotlin-multiplatform"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Scogun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-01T14:55:45.000Z","updated_at":"2025-03-24T12:37:36.000Z","dependencies_parsed_at":"2024-01-16T15:40:32.419Z","dependency_job_id":"362f91fd-8ecb-4302-85ee-da19864b1702","html_url":"https://github.com/Scogun/kcron-common","commit_stats":null,"previous_names":["scogun/kcron"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scogun%2Fkcron-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scogun%2Fkcron-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scogun%2Fkcron-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scogun%2Fkcron-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Scogun","download_url":"https://codeload.github.com/Scogun/kcron-common/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247891052,"owners_count":21013469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","kotlin","kotlin-multiplatform"],"created_at":"2025-04-08T17:27:18.246Z","updated_at":"2026-01-11T17:33:59.394Z","avatar_url":"https://github.com/Scogun.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KCron\nCron realization for Kotlin Multiplatform\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Scogun_kcron-common\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Scogun_kcron-common) ![GitHub](https://img.shields.io/github/license/Scogun/kcron-common?color=blue) ![Publish workflow](https://github.com/Scogun/kcron-common/actions/workflows/publish.yml/badge.svg) [![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.kcron/kcron-common/0.31.7?color=blue)](https://search.maven.org/artifact/com.ucasoft.kcron/kcron-common/0.31.7/jar)\n\n### Features\n* Kotlin Multiplatform library\n* Parse Cron expressions\n  * Include L, W, LW, '?' and #\n* Build Cron expression by smart builder functions:\n```kotlin\nbuilder\n    .seconds(10 at 0) //Every 10 seconds starting at 0 seconds\n    .minutes(5..25) // Every minute between 5 and 25\n    .hours(5, 12) // Specific hours: 5 and 12\n    .daysOfWeek(7 on 5) // On the 5th Sunday of the month\n    .years(2050) // Specific year: 2050\n```\n* Build Cron expression via Kotlin style function:\n```kotlin\ncron {\n    seconds(10 at 0)//Every 10 seconds starting at 0 seconds\n    minutes(5..25) // Every minute between 5 and 25\n    hours(5, 12) // Specific hours: 5 and 12\n    daysOfWeek(7 on 5) // On the 5th Sunday of the month\n    years(2050) // Specific year: 2050\n}\n```\n* Support custom first week day\n```kotlin\nval builder = Builder(WeekDays.Sunday)\nbuilder\n    .daysOfWeek(7 on 5) // On the 5th Saturday of the month\n```\n* Parsing validation includes combination rules\n  * 'days' and 'days of week' could not be setup simultaneously\n* Support\n  * JVM\n  * Linux\n  * Windows (mingwX64)\n  * macOS\n  * Javascript\n  * Wasm\n  * iOS\n* Support different DateTime libraries (via DateTime Provider Abstractions)\n* Provide UI builder for JVM, macOS, JavaScript and iOS on Compose UI multiplatform\n  * Multilanguage support (English and Russian now)\n\n\u003cimg src=\"docs/images/CronUiBuilderEn.png\" alt=\"KCron Compose UI\" width=\"300\"/\u003e\n\n### Usage\n#### KCron-Common library as default implementation uses [Kotlinx-DateTime](https://github.com/Kotlin/kotlinx-datetime) library\n***Add with Gradle***\n```groovy\nkotlin {\n    sourceSets {\n        commonMain {\n            dependencies {\n                implementation 'com.ucasoft.kcron:kcron-common:0.31.7'\n            }\n        }\n    }\n}\n```\n***Build Cron expression***\n```kotlin\nval builder = Cron.builder()\n// By default, builder contains any expression for every part\nprintln(builder.expression) // * * * ? * * *\nbuilder\n    .seconds(10 at 0)\n    .minutes(5..25)\n    .hours(5, 12)\n    .daysOfWeek(7 on 5)\n    .years(2050)\nprintln(builder.expression) // 0/10 5-25 5,12 ? * 7#5 2050\n```\n***Parse as Classic as well as Modern Cron expressions***\n```kotlin\n// Auto detect\nval builder = Cron.parseAndBuild(\"0/10 5-25 5,12 ? * 7#5 2050\") {\n    it.firstDayOfWeek = WeekDays.Sunday\n}\n@OptIn(DelicateIterableApi::class)\nprintln(builder.asIterable().take(10))\n/* Result:\n[\n    2050-01-29T05:05,\n    2050-01-29T05:05:10,\n    2050-01-29T05:05:20,\n    2050-01-29T05:05:30,\n    2050-01-29T05:05:40,\n    2050-01-29T05:05:50,\n    2050-01-29T05:06,\n    2050-01-29T05:06:10,\n    2050-01-29T05:06:20,\n    2050-01-29T05:06:30\n]\n*/\n// OR Force to parse only Classic expressions\ntry {\n    val builder = Cron.parseAndBuild(\"0/10 5-25 5,12 ? * 7#5 2050\") {\n        it.version = Version.Classic\n    }\n} catch(e: WrongCronExpression) {\n    println(e.message) // Expression 0/10 5-25 5,12 ? * 7#5 2050 is not Classic Cron one!\n}\n```\n***Days of week and months can be defined in a parsed expression as numbers as well as short names***\n```kotlin\nbuilder = Cron.parseAndBuild(\"15/10 5-25 5 ? JAN,MAR 2,3,4,5 2050\")\nprintln(builder.nextRun) // 2050-01-04T05:05:15\n// OR\nbuilder = Cron.parseAndBuild(\"15/10 5-25 5 ? 2-4 MON 2050\")\nprintln(builder.nextRun) // 2050-02-07T05:05:15\n```\n***Easy change any part of expression***\n```kotlin\nval builder = Cron.parseAndBuild(\"0/10 5-25 5,12 ? * SUN#5 2050\")\nbuilder.years(2021..2025)\nprintln(builder.expression) // 0/10 5-25 5,12 ? * SUN#5 2021-2025\n``` \n### Current status\nThis library is on beta version `0.31.7`.\nIt is continuing to develop.\nCheck the news!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscogun%2Fkcron-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscogun%2Fkcron-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscogun%2Fkcron-common/lists"}