{"id":22376710,"url":"https://github.com/aminography/primecalendar","last_synced_at":"2025-07-30T23:31:43.046Z","repository":{"id":45233767,"uuid":"188237289","full_name":"aminography/PrimeCalendar","owner":"aminography","description":"PrimeCalendar provides all of the java.util.Calendar functionalities for Persian, Hijri, and ... dates. It is also possible to convert dates to each other.","archived":false,"fork":false,"pushed_at":"2021-12-29T14:43:40.000Z","size":528,"stargazers_count":66,"open_issues_count":5,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T16:09:52.355Z","etag":null,"topics":["calendar","date","date-conversion","gregorian-calendar","hijri-calendar","japanese-calendar","java","kotlin-library","persian-calendar"],"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/aminography.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-23T13:14:53.000Z","updated_at":"2025-01-31T10:38:47.000Z","dependencies_parsed_at":"2022-07-16T14:18:20.795Z","dependency_job_id":null,"html_url":"https://github.com/aminography/PrimeCalendar","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aminography/PrimeCalendar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FPrimeCalendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FPrimeCalendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FPrimeCalendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FPrimeCalendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aminography","download_url":"https://codeload.github.com/aminography/PrimeCalendar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminography%2FPrimeCalendar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267960677,"owners_count":24172506,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["calendar","date","date-conversion","gregorian-calendar","hijri-calendar","japanese-calendar","java","kotlin-library","persian-calendar"],"created_at":"2024-12-04T22:10:42.966Z","updated_at":"2025-07-30T23:31:42.745Z","avatar_url":"https://github.com/aminography.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `PrimeCalendar` :zap:\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-PrimeCalendar-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/7744)\n![mavenCentral](https://img.shields.io/maven-central/v/com.aminography/primecalendar?color=blue)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7bba3b163d4444c4a8913f82386ad379)](https://www.codacy.com/manual/aminography/PrimeCalendar?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=aminography/PrimeCalendar\u0026amp;utm_campaign=Badge_Grade)\n[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)\n\n**`PrimeCalendar`** provides all the [`java.util.Calendar`](https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html) functionalities for `Persian`, `Hijri`, and `Japanese` dates.\n**`PrimeCalendar`** can be used in every **JVM-based** projects such as **Java/kotlin** applications, **Android** apps, *etc*.  \n\nThis library contains three types of calendar systems as well as their conversion to each other.\n\n  | Calendar System | Provider Class | Descriptions |\n  | --- | --- | --- |\n  |[Iranian](https://en.wikipedia.org/wiki/Iranian_calendars)| [PersianCalendar](https://github.com/aminography/PrimeCalendar/blob/master/library/src/main/java/com/aminography/primecalendar/persian/PersianCalendar.kt) | The most accurate solar calendar in use today. |\n  |[Islamic](https://en.wikipedia.org/wiki/Islamic_calendar)| [HijriCalendar](https://github.com/aminography/PrimeCalendar/blob/master/library/src/main/java/com/aminography/primecalendar/hijri/HijriCalendar.kt) | A lunar calendar consisting of 12 lunar months in a year of 354 or 355 days. |\n  |[Gregorian](https://en.wikipedia.org/wiki/Gregorian_calendar)| [CivilCalendar](https://github.com/aminography/PrimeCalendar/blob/master/library/src/main/java/com/aminography/primecalendar/civil/CivilCalendar.kt) | The common calendar which is used in most of the world. |\n  |[Japanese](https://en.wikipedia.org/wiki/Japanese_calendar)| [JapaneseCalendar](https://github.com/aminography/PrimeCalendar/blob/master/library/src/main/java/com/aminography/primecalendar/japanese/JapaneseCalendar.kt) | The calendar which is used in Japan. |\n\n![](static/prime_logo.png)\n  \nDownload\n--------\n**`PrimeCalendar`** is available on `MavenCentral` to download using build tools systems.\n\n### • Gradle\nAdd the following lines to your `build.gradle` file:\n\n```gradle\ndependencies {\n    implementation 'com.aminography:primecalendar:1.7.0'\n}\n```\n\n### • Maven\nAdd the following lines to your `pom.xml` file:\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.aminography\u003c/groupId\u003e\n        \u003cartifactId\u003eprimecalendar\u003c/artifactId\u003e\n        \u003cversion\u003e1.7.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n\u003cbr/\u003e\n\nUsage\n-----\nCalendar objects can be instantiated by the class constructors or using [`CalendarFactory`](https://github.com/aminography/PrimeCalendar/blob/master/library/src/main/java/com/aminography/primecalendar/common/CalendarFactory.kt).\n\n\u003e **Java**\n```java\nPrimeCalendar calendar = new PersianCalendar();\n// or\nPrimeCalendar calendar = CalendarFactory.newInstance(CalendarType.PERSIAN);\n```\n\n\u003e **Kotlin**\n```kotlin\nval calendar = HijriCalendar()\n// or\nval calendar = CalendarFactory.newInstance(CalendarType.HIJRI)\n```\n\n\u003cbr/\u003e\n\n### • Functionalities\nExactly all of the standard `Calendar` functionalities are implemented in **`PrimeCalendar`** including `set`, `add`, `roll`, *etc*.  \nTo see list of [**methods**](https://github.com/aminography/PrimeCalendar/wiki#methods) and [**fields**](https://github.com/aminography/PrimeCalendar/wiki#fields), refer to the [wiki page](https://github.com/aminography/PrimeCalendar/wiki).\n\n```kotlin\nval civil = CivilCalendar()\ncivil.set(2019, 5, 17)\nprintln(civil.longDateString)\n\ncivil.set(Calendar.DAY_OF_YEAR, 192)\nprintln(civil.longDateString)\n\ncivil.add(Calendar.WEEK_OF_YEAR, 14)\nprintln(civil.longDateString)\n\ncivil.roll(Calendar.DAY_OF_WEEK, -3)\nprintln(civil.longDateString)\n\n---------------------------\n\u003e Monday, 17 June 2019\n\u003e Thursday, 11 July 2019\n\u003e Thursday, 17 October 2019\n\u003e Monday, 14 October 2019\n```\n\n\u003cbr/\u003e\n\n### • Date Conversion\nConversion of dates to each other is simply possible by calling the converter methods.\n\n```kotlin\n// Converting calendar instance to PersianCalendar:\nval persian = calendar.toPersian()\n\n// Converting calendar instance to HijriCalendar:\nval hijri = calendar.toHijri()\n\n// Converting calendar instance to CivilCalendar:\nval civil = calendar.toCivil()\n\n// Converting calendar instance to JapaneseCalendar:\nval japanese = calendar.toJapanese()\n```\n\n\u003cbr/\u003e\n\nAlso, it is possible to convert an instance of `java.util.Calendar` to an instance of `PrimeCalendar`. For example:\n```kotlin\nimport java.util.Calendar\n\nval calendar = Calendar.getInstance()\n\n// Converting to PersianCalendar:\nval persian = calendar.toPersian()\n```\n\n\u003cbr/\u003e\n\n### • Kotlin Operators\nThere is a different way to use `get`, `set`, and `add` methods. Using operators you can do it much simpler.\nSuppose that the `calendar` is an instance of `PrimeCalendar`:\n\n\u003e get\n```kotlin\nval year = calendar.get(Calendar.YEAR)\n\n// equivalent operations:\nval year = calendar[Calendar.YEAR]\nval year = calendar.year\n```\n\n\u003e set\n```kotlin\ncalendar.set(Calendar.MONTH, 7)\n\n// equivalent operations:\ncalendar[Calendar.MONTH] = 7\ncalendar.set(Month(7))\ncalendar.set(7.month)\ncalendar.month = 7\n```\n\n\u003e add\n```kotlin\ncalendar.add(Calendar.DAY_OF_MONTH, 27)\n\n// equivalent operations:\ncalendar[Calendar.DAY_OF_MONTH] += 27\ncalendar += DayOfMonth(27)\ncalendar += 27.dayOfMonth\n```\n\n\u003cbr/\u003e\n\n### • Localization\nYou can localize digits, month names, and week day names by passing locale in constructor. For Persian and Hijri calendars, the default locale is set to Farsi and Arabic respectively.\n\n```kotlin\nval persian = PersianCalendar()\nprintln(persian.longDateString)\n\n---------------------------\n\u003e پنج‌شنبه، ۲۳ خرداد ۱۳۹۸\n```\n\n```kotlin\nval persian = PersianCalendar(Locale.ENGLISH)\nprintln(persian.longDateString)\n\n---------------------------\n\u003e Thursday, 23 Khordad 1398\n```\n\n\u003cbr/\u003e\n\nThird Party Libraries\n---------------------\n**• ThreeTen-Backport** (https://www.threeten.org/threetenbp)\n\n\u003cbr/\u003e\n\nChange Log\n----------\n### Version 1.4.0\n- Migrating to MavenCentral.\n\n### Version 1.3.2\n- Improving Arabic digits.\n\n### Version 1.3.0\n- Adding getter/setter field for all the calendar fields, such as dayOfWeek, hour, *etc*.\n- Adding date conversion extension functions for `java.util.Calendar` instances.\n- Adding calendar fields extensions for numbers, *e.g.* `calendar += 27.dayOfMonth`\n\n### Version 1.2.21\n- Japanese month names and other temporal names are changed.\n- Month constants are added into calendar classes.\n\n\u003cbr/\u003e\n\nLicense\n--------\n```\nCopyright 2019 Mohammad Amin Hassani.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminography%2Fprimecalendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faminography%2Fprimecalendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminography%2Fprimecalendar/lists"}