GithubHelp home page GithubHelp logo

javalunarcore's Introduction

JavaLunarCore

JitPack release Language License

JavaLunarCore is the core library of Lunar calendar in Android devices. The library does not contain any UI implementation only Lunar date conversion and Good/Bad/Normal day calculation in file LunarCoreHelper.java.

Lịch Như Ý

This library is used in Lịch Như Ý by Appota. The app was in Top 10 - Productivity on Google Play multiple times.

Image of Lịch Như Ý

Install

Add JitPack repository in your project's build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add the dependency in your app's build.gradle The latestVersion is JitPack release

dependencies {
  implementation 'com.github.appota:JavaLunarCore:${latestVersion}'
}

Usage

Convert between the Gregorian Calendar (or the Western Solar Calendar) and the Lunar Calendar (or the Traditional Chinese/Vietnamese Calendar)

int[] lunarDay = LunarCoreHelper.convertSolar2Lunar(day, month, year, timeZone);
Log.d(TAG, "Lunar date:\n" +
            "Day: " + lunarDay[0] + "\n" +
            "Month: " + lunarDay[1] + "\n" +
            "Year: " + lunarDay[2] + "\n" +
            "Leap Month: " + (lunarDay[3]==1 ? "Yes" : "No"));


int[] solarDay = LunarCoreHelper.convertLunar2Solar(day, month, year, lunarLeapMonth, timeZone);
Log.d(TAG, "Solar date:\n" +
           "Day: " + solarDay[0] + "\n" +
           "Month: " + solarDay[1] + "\n" +
           "Year: " + solarDay[2] + "\n");

Get Can-Chi (Stem-Branch) of a day based on Sexagenary cycle

Log.d(TAG, "Can Chi: " + LunarCoreHelper.getCanDayLunar(solarDay, solarMonth, solarYear) + " " 
                       + LunarCoreHelper.getChiDayLunar(solarDay, solarMonth, solarYear) + "\n" +
           "Chinese 干支: " + LunarCoreHelper.getChineseCanDayLunar(solarDay, solarMonth, solarYear) 
                           + LunarCoreHelper.getChineseChiDayLunar(solarDay, solarMonth, solarYear));

Get day rating (Good/Bad/Normal Day)

String chiDay = LunarCoreHelper.getChiDayLunar(solarDay, solarMonth, solarYear);
Log.d(TAG, "Good/Bad Day: " + LunarCoreHelper.rateDay(chiDay, lunarMonth));

javalunarcore's People

Contributors

dovahkrid avatar tuenguyenhd avatar

Stargazers

Jolo Phamm avatar DoXuanNguyen avatar Dat Nguyen avatar Egor Smirnov avatar Lưu Thảo avatar White Tiger avatar  avatar

Watchers

Appota Inc. avatar  avatar  avatar

Forkers

nickevan9 ngxson

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.