Giter Club home page Giter Club logo

lunarcore's Introduction

LunarCore

生成1890 - 2100 年的农历数据

源代码为 @cyanzhong 写的 Objective-C 版本的 LunarCore, 由@Elors改写为 Swift 版本 LunarCore-Swift

我在这两个的基础上将 LunarCore 写为了支持 Swift Package Manager 的版本,使用起来应该更加方便简单

安装

Swift Package Manager

通过 URL https://github.com/L1cardo/LunarCore 安装

使用

import LunarCore
LunarCore.calendar

计算一个日历面板(42 天)的所有信息

/// 计算一个日历面板(42 天)的所有信息
/// - Parameters:
///   - year: 公历年
///   - month: 月(1-12)
/// - Returns: 一个日历面板(42 天)的所有信息 [String: Any]

LunarCore.calendar(_ year: Int, _ month: Int) -> [String: Any]

返回的数据格式如下所示:

[
    "firstDay": 3,
    "monthDays": 31,
    "monthData": [
        [
            "lunarDayName": "初八", 
            "solarFestival": "", 
            "month": 6, 
            "lunarMonthName": "五月", 
            "worktime": 0,
            "GanZhiYear": "庚子", 
            "lunarDay": 8, 
            "zodiac": "", 
            "year": 2020, 
            "lunarFestival": "",
            "day": 28,
            "term": ""
        ],
        ......
]
LunarCore.solarToLunar

公历转换成农历

/// 公历转换成农历
/// - Parameters:
///   - _year: 公历年
///   - _month: 公历月
///   - _day: 公历日
/// - Returns: 农历年月日
LunarCore.solarToLunar(_ _year: Int, _ _month: Int, _ _day: Int) -> [String: Any]

返回的数据格式如下所示:

[
    "worktime": 0, 
    "weekFestival": "", 
    "term": "小暑", 
    "lunarDayName": "十六", 
    "GanZhiYear": "庚子", 
    "lunarFestival": "", 
    "lunarMonthName": "五月", 
    "solarFestival": "", 
    "zodiac": "", 
    "lunarDay": 16
]
LunarCore.lunarToSolar

将农历转换为公历

/// 将农历转换为公历
/// - Parameters:
///   - year: 农历年
///   - month: 月(1-13,有闰月)
///   - day: 日
/// - Returns: 公历数据
LunarCore.lunarToSolar(_ _year: Int, _ _month: Int, _ _day: Int) -> [String: Any]

返回的数据格式如下:

[
    "year": 2020,
    "month": 6, 
    "day": 7
]
LunarCore.isLeapYear

判断公历年是否是闰年

/// 判断公历年是否是闰年
/// - Parameter year: 公历年
/// - Returns: 是否是闰年
LunarCore.isLeapYear(_ year: Int) -> Bool

lunarcore's People

Contributors

l1cardo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.