All Projects → aminography → PrimeCalendar

aminography / PrimeCalendar

Licence: Apache-2.0 License
PrimeCalendar provides all of the java.util.Calendar functionalities for Persian, Hijri, and ... dates. It is also possible to convert dates to each other.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to PrimeCalendar

Calendarview
A highly customizable calendar library for Android, powered by RecyclerView.
Stars: ✭ 2,862 (+6260%)
Mutual labels:  date, calendar
LunarCalendar
A lightweight macOS App for displaying calendar and time
Stars: ✭ 82 (+82.22%)
Mutual labels:  date, calendar
react-calendar-datetime-picker
A simple and fast date and time picker component for React
Stars: ✭ 58 (+28.89%)
Mutual labels:  date, persian-calendar
Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+5208.89%)
Mutual labels:  date, calendar
persian-date-time
Persian Date Time
Stars: ✭ 54 (+20%)
Mutual labels:  calendar, persian-calendar
Dpicker
A framework-agnostic minimal date picker
Stars: ✭ 187 (+315.56%)
Mutual labels:  date, calendar
js-calendar
The lightest Javascript calendar out there, without any dependency.
Stars: ✭ 37 (-17.78%)
Mutual labels:  date, calendar
Tail.datetime
A lightweight, translat- and configurable Open Source DateTime Picker, written in pure vanilla JavaScript!
Stars: ✭ 139 (+208.89%)
Mutual labels:  date, calendar
gahshomar
A Persian (Jalali/Farsi) calendar for Linux
Stars: ✭ 69 (+53.33%)
Mutual labels:  calendar, persian-calendar
GDCalendar
Calendar component with RTL languages written in swift
Stars: ✭ 27 (-40%)
Mutual labels:  calendar, persian-calendar
Things Calendar
Simple but elegant datepicker for the web — inspired by Things for mac
Stars: ✭ 165 (+266.67%)
Mutual labels:  date, calendar
vuejs3-datepicker
vue 3 datepicker. supports disabling, highlighting of dates and programmatic access of date.
Stars: ✭ 23 (-48.89%)
Mutual labels:  date, calendar
Xk Time
xk-time 是时间转换,时间计算,时间格式化,时间解析,日历,时间cron表达式和时间NLP等的工具,使用Java8,线程安全,简单易用,多达70几种常用日期格式化模板,支持Java8时间类和Date,轻量级,无第三方依赖。
Stars: ✭ 162 (+260%)
Mutual labels:  date, calendar
Datepicker
Get a date with JavaScript! A datepicker with no dependencies.
Stars: ✭ 212 (+371.11%)
Mutual labels:  date, calendar
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+4306.67%)
Mutual labels:  date, calendar
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (+31.11%)
Mutual labels:  date, calendar
Calendar
📆 calendar 日历
Stars: ✭ 119 (+164.44%)
Mutual labels:  date, calendar
React Calendar
Ultimate calendar for your React app.
Stars: ✭ 2,082 (+4526.67%)
Mutual labels:  date, calendar
JalaliCalendar
Jalali Calendar for java
Stars: ✭ 76 (+68.89%)
Mutual labels:  persian-calendar, date-conversion
isoweek
Go package for calculating a start date and time of ISO 8601 week. (golang)
Stars: ✭ 32 (-28.89%)
Mutual labels:  date, calendar

PrimeCalendar

Android Arsenal mavenCentral Codacy Badge Awesome Kotlin Badge

PrimeCalendar provides all the java.util.Calendar functionalities for Persian, Hijri, and Japanese dates. PrimeCalendar can be used in every JVM-based projects such as Java/kotlin applications, Android apps, etc.

This library contains three types of calendar systems as well as their conversion to each other.

Calendar System Provider Class Descriptions
Iranian PersianCalendar The most accurate solar calendar in use today.
Islamic HijriCalendar A lunar calendar consisting of 12 lunar months in a year of 354 or 355 days.
Gregorian CivilCalendar The common calendar which is used in most of the world.
Japanese JapaneseCalendar The calendar which is used in Japan.

Download

PrimeCalendar is available on MavenCentral to download using build tools systems.

• Gradle

Add the following lines to your build.gradle file:

dependencies {
    implementation 'com.aminography:primecalendar:1.7.0'
}

• Maven

Add the following lines to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>com.aminography</groupId>
        <artifactId>primecalendar</artifactId>
        <version>1.7.0</version>
    </dependency>
</dependencies>

Usage

Calendar objects can be instantiated by the class constructors or using CalendarFactory.

Java

PrimeCalendar calendar = new PersianCalendar();
// or
PrimeCalendar calendar = CalendarFactory.newInstance(CalendarType.PERSIAN);

Kotlin

val calendar = HijriCalendar()
// or
val calendar = CalendarFactory.newInstance(CalendarType.HIJRI)

• Functionalities

Exactly all of the standard Calendar functionalities are implemented in PrimeCalendar including set, add, roll, etc.
To see list of methods and fields, refer to the wiki page.

val civil = CivilCalendar()
civil.set(2019, 5, 17)
println(civil.longDateString)

civil.set(Calendar.DAY_OF_YEAR, 192)
println(civil.longDateString)

civil.add(Calendar.WEEK_OF_YEAR, 14)
println(civil.longDateString)

civil.roll(Calendar.DAY_OF_WEEK, -3)
println(civil.longDateString)

---------------------------
> Monday, 17 June 2019
> Thursday, 11 July 2019
> Thursday, 17 October 2019
> Monday, 14 October 2019

• Date Conversion

Conversion of dates to each other is simply possible by calling the converter methods.

// Converting calendar instance to PersianCalendar:
val persian = calendar.toPersian()

// Converting calendar instance to HijriCalendar:
val hijri = calendar.toHijri()

// Converting calendar instance to CivilCalendar:
val civil = calendar.toCivil()

// Converting calendar instance to JapaneseCalendar:
val japanese = calendar.toJapanese()

Also, it is possible to convert an instance of java.util.Calendar to an instance of PrimeCalendar. For example:

import java.util.Calendar

val calendar = Calendar.getInstance()

// Converting to PersianCalendar:
val persian = calendar.toPersian()

• Kotlin Operators

There is a different way to use get, set, and add methods. Using operators you can do it much simpler. Suppose that the calendar is an instance of PrimeCalendar:

get

val year = calendar.get(Calendar.YEAR)

// equivalent operations:
val year = calendar[Calendar.YEAR]
val year = calendar.year

set

calendar.set(Calendar.MONTH, 7)

// equivalent operations:
calendar[Calendar.MONTH] = 7
calendar.set(Month(7))
calendar.set(7.month)
calendar.month = 7

add

calendar.add(Calendar.DAY_OF_MONTH, 27)

// equivalent operations:
calendar[Calendar.DAY_OF_MONTH] += 27
calendar += DayOfMonth(27)
calendar += 27.dayOfMonth

• Localization

You 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.

val persian = PersianCalendar()
println(persian.longDateString)

---------------------------
> پنج‌شنبه، ۲۳ خرداد ۱۳۹۸
val persian = PersianCalendar(Locale.ENGLISH)
println(persian.longDateString)

---------------------------
> Thursday, 23 Khordad 1398

Third Party Libraries

• ThreeTen-Backport (https://www.threeten.org/threetenbp)


Change Log

Version 1.4.0

  • Migrating to MavenCentral.

Version 1.3.2

  • Improving Arabic digits.

Version 1.3.0

  • Adding getter/setter field for all the calendar fields, such as dayOfWeek, hour, etc.
  • Adding date conversion extension functions for java.util.Calendar instances.
  • Adding calendar fields extensions for numbers, e.g. calendar += 27.dayOfMonth

Version 1.2.21

  • Japanese month names and other temporal names are changed.
  • Month constants are added into calendar classes.

License

Copyright 2019 Mohammad Amin Hassani.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].