Skip to content

Commit

Permalink
Merge pull request #1 from hasancse91/library-update
Browse files Browse the repository at this point in the history
Readme File and Library version update
  • Loading branch information
hasancse91 authored Oct 21, 2024
2 parents a044538 + 087be90 commit 2165d83
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 22 deletions.
124 changes: 110 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# Bongabdo - A Bengali Calendar Converter Library

Bongabdo is a Kotlin library that allows you to convert Gregorian calendar dates to Bengali calendar dates (Bongabdo). This library provides two popular calculation methods: **Bangla Academy** (used in Bangladesh) and **Drik Shiddhanta** (used in India). You can easily integrate this library into your Android or Kotlin Multiplatform project.
![Unit Tests](https://github.com/hasancse91/bongabdo/actions/workflows/github-actions.yml/badge.svg)
[![](https://jitpack.io/v/hasancse91/bongabdo.svg)](https://jitpack.io/#hasancse91/bongabdo)

## Features
Bongabdo is a powerful Kotlin library that simplifies converting Gregorian dates to Bengali calendar dates (Bongabdo) for your Android or Java/Kotlin projects. It provides flexibility for regional variations and offers customization options.

- Convert any Gregorian date to Bengali date (Bongabdo).
- Supports both **Bangla Academy (Bangladesh)** and **Drik Shiddhanta (India)** methods. (extendable for your own method)
- Localization support for Bengali and English (easily extendable).
<img src="https://raw.githubusercontent.com/hasancse91/bongabdo/main/sample_data/sample-app-screenshot.jpeg" width="280" alt="bongabdo calendar library sample"/>

## Key Features:

- **Easy Conversions:** Convert any Gregorian date to its corresponding Bengali date using two popular calculation methods:
- Bangla Academy: Used in Bangladesh
- Drik Shiddhanta: Used in India
- **Extendable:** Easily implement additional calculation methods like Surjo Shiddhanta for further customization.
- **Multilingual Support:** Currently offers English and Bengali localization, with options for extending to other languages.

## Getting Started

### 1. Installation

#### Jitpack Integration

To integrate the Bongabdo library in your project, add the following to your root `build.gradle.kts` (or `build.gradle` for Groovy):
#### Gradle Integration
For Gradle version 7.0 and above (`settings.gradle.kts`):

```kotlin
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
}
}
```
For Gradle version below 7.0 (root level `build.gradle`)
```kotlin
allprojects {
repositories {
Expand All @@ -25,26 +41,106 @@ allprojects {
}
}
```

Then add the dependency to your module's build.gradle.kts:
Add the following dependency to your module's `build.gradle.kts`:
```kotlin
dependencies {
implementation("com.github.hasancse91:bongabdo:0.0.3")
implementation("com.github.hasancse91:bongabdo:<latest-version>")
}
```
Latest version:

[![](https://jitpack.io/v/hasancse91/bongabdo.svg)](https://jitpack.io/#hasancse91/bongabdo)
-----

### 2. Usage
You can start using the library by creating an instance of the Bongabdo class and calling the appropriate conversion methods.
To convert a Gregorian date to a Bengali date, initialize the `Bongabdo` class and call the appropriate conversion method.

Example: Convert a Gregorian Date to Bengali Date (Bangla Academy Method)
Example: Convert a Gregorian Date to a Bengali Date (Bangla Academy Method)
```kotlin
fun main() {
val bongabdo = Bongabdo.getInstance(BongabdoMethod.BANGLA_ACADEMY)
val result = bongabdo.getBongabdoData(year = 2014, month = 3, day = 14) // 14 Apr 2024

println("Bongabdo Date: ${result.getFullDate()}")
println("Bongabdo Date: ${result.getFullDate()}") // 1 Baishakh, 1431
}
```
-----
### 3. Localization Support
Bongabdo supports both English and Bengali locales. English is our default locale. You can set the desired locale using the configuration settings.

**Bengali Localization**
```kotlin
bongabdo.mLocalizationConfig = BengaliLocalizationConfig()
```
#### Custom Localization (e.g., Hindi)
You can extend the BongabdoLocalizationConfig class to add your own localization support.
```kotlin
class HindiLocalisationConfig : BongabdoLocalizationConfig() {
override val digitMap: Map<Int, String>
get() = TODO("Not yet implemented")
override val monthNameList: List<String>
get() = TODO("Not yet implemented")
override val seasonNameList: List<String>
get() = TODO("Not yet implemented")
}

fun main() {
val bongabdo = Bongabdo.getInstance(BongabdoMethod.BANGLA_ACADEMY)
bongabdo.mLocalizationConfig = HindiLocalisationConfig()
val bongabdoData = bongabdo.getBongabdoData(2014, 3, 14)

println(bongabdoData.getFullDate())
}
```
----
### 4. Calculation Method
Bongabdo currently supports two calculation methods:
1. Bangla Academy (used in Bangladesh)
2. Drik Shiddhanta (used in India)

Specify the calculation method during initialization:
```kotlin
val bongabdo = Bongabdo.getInstance(BongabdoMethod.BANGLA_ACADEMY)`
// or
val bongabdo = Bongabdo.getInstance(BongabdoMethod.INDIAN_DRIK_SIDDHANTA)
```
**Custom Calculation Methods**

To add a custom calculation method (e.g., Surya Shiddhanta), extend the Bongabdo class and implement the required logic.

Extend your own class from `Bongabdo` abstract class:
```kotlin
class SurjaShiddhantaBongabdo : Bongabdo() {
override fun getBongabdoData(year: Int, month: Int, day: Int): BongabdoData {
TODO("Implement your logic here")
}
}

fun main() {
val bongabdo = SurjaShiddhantaBongabdo() // your implemented class
bongabdo.mLocalizationConfig = HindiLocalisationConfig() // you cat use your own localization class
val bongabdoData = bongabdo.getBongabdoData(2014, 3, 14)

println(bongabdoData.getFullDate())
}
```
----
In this way you can extend this library for localization and calculation method variation.

#### Contribution Guidelines
Want to contribute? Here’s how you can help:

1. Fork the repository.
2. Contribute your feature or improvement.
3. Ensure that unit tests are updated or created for your changes.
4. Submit a pull request.

We appreciate your contributions and will review your pull requests as soon as possible!

----

#### Special thanks
A special thanks to [Shafayat Hossain Khan](https://www.linkedin.com/in/shafayat-hossain-khan/) for his significant contributions to this project.

#### License
This project is licensed under the MIT License. See the LICENSE file for details.
2 changes: 1 addition & 1 deletion bongabdo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ publishing {
create<MavenPublication>("maven") {
groupId = "com.github.hasancse91"
artifactId = "bongabdo"
version = "0.0.3"
version = "1.0.0"
from(components["kotlin"])
}
}
Expand Down
12 changes: 5 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
[versions]
agp = "8.7.0"
agp = "8.7.1"
kotlin = "2.0.21"
coreKtx = "1.13.1"
junitJupiter = "5.8.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
kotlinxDatetime = "0.6.1"
lifecycleRuntimeKtx = "2.8.6"
activityCompose = "1.9.2"
composeBom = "2024.09.03"
activityCompose = "1.9.3"
composeBom = "2024.10.00"
jetbrainsKotlinJvm = "1.9.0"
materialIconsExtended = "1.7.3"
navigationCompose = "2.8.2"
materialIconsExtended = "1.7.4"
navigationCompose = "2.8.3"
appcompat = "1.7.0"
bongabdo = "0.0.1"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
bongabdo = { module = "com.github.hasancse91:bongabdo", version.ref = "bongabdo" }
junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junitJupiter" }
junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junitJupiter" }
junit-jupiter-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junitJupiter" }
Expand Down
Binary file added sample_data/sample-app-screenshot.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2165d83

Please sign in to comment.