Full featured lunar calendar library

Related tags

Calendar LunarCore
Overview

LunarCore

Language License

小历(iOS & OS X)的农历核心部分。

何为小历

小历是一个简洁的农历 app,目前支持 iOS & OS X 两端,iOS 端多次被 App Store 官方推荐。 image image

前世今生

LunarCore 最早来自于一个 JavaScript 编写的农历库:LunarCalendar

出于性能原因,我将其用 Objective-C 重写,同时改进了原版里面一些数据不准确的问题。LunarCore 现已工作在小历上面,在未来可能会使用 Swift 重写。

为了更灵活的抽离,LunarCore 不包含任何 UI 实现,所有的数据均以 Dictionary 的形式透出。

食用方法

#import "AppDelegate.h"
#import "LunarCore.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSDictionary *lunarCalendar = calendar(2016, 5);
    NSLog(@"%@", lunarCalendar);
    
    return YES;
}

@end

即获得一个 2016年5月 的日历数据,你可以方便的用其实现 UI 部分,利用 LunarCore,我使用一周的时间将 iOS 版本的小历移植到了 OS X。

更多内部接口请参考:LunarCore/LunarCore.m

温馨提示

计算农历的耗时较长(主要是节气计算,如果你不需要也可以直接去掉),如果你在 UI 上面每次日历变化都计算一次,显然是不划算的做法。我个人的建议是做内存和文件缓存,小历的缓存策略如下(以 2016年5月 日历为例):

  • 从内存中读取 2016.5 的日历
  • 没有读到的话从文件中读取
  • 还是没有读到的话构建 2016.5 的日历
  • 构建日历后缓存到文件和内存
  • 在子线程生成上个月和下个月的日历

联系方式

Weibo Twitter Email

You might also like...
SwiftUI Simple Calendar / Date Picker for iOS
SwiftUI Simple Calendar / Date Picker for iOS

RKCalendar RKCalendar is a SwiftUI Calendar / Date Picker for iOS. Features include: minimum and maximum calendar dates selectable, single date select

A customizable swiftui calendar
A customizable swiftui calendar

Description not available. Installation From Xcode 11, you can use Swift Package Manager to add Kingfisher to your project. Select File Swift Packag

An easy to use SwiftUI date picker for Shamsi (Persian) calendar
An easy to use SwiftUI date picker for Shamsi (Persian) calendar

ShamsiDatePicker An easy-to-use SwiftUI iOS/watchOS date picker for Shamsi (Persian) calendar. Features Pure (100%) SwiftUI implementation Full suppor

SwiftUICalendar - SwiftUI simple calendar
SwiftUICalendar - SwiftUI simple calendar

SwiftUICalendar Installation CocoaPods pod 'SwiftUICalendar' import import SwiftUICalendar Features Infinite scroll Support horizontal and vertical sc

Dead simple calendar implementation
Dead simple calendar implementation

Package provides a CalendarView which can be used to display simple calendar in your App.

A calendar quick view for the MacOS status bar

Calendar Quick View Quick Menu Calendar in the mac app store An open source macOS calendar preview utility Download from the Mac App Store Visualizati

Clendar - universal calendar app. Written in SwiftUI. Available on App Store. MIT License.

Clendar - minimal calendar Minimal Calendar & Widgets Landing Page About This project is started out as an UIKit base app for me to learn new WWDC fea

A custom visual calendar for iOS 8+ written in Swift (>= 4.0).
A custom visual calendar for iOS 8+ written in Swift (= 4.0).

Overview Screenshots GIF Demo Installation Usage Architecture Version matrix Advanced API For contributors Screenshots GIF Demo Installation CocoaPods

iOS 7+ Calendar (Date Picker) with Infinite Scrolling.
iOS 7+ Calendar (Date Picker) with Infinite Scrolling.

RSDayFlow iOS 7 Calendar with Infinite Scrolling. Only need 4 lines of code to set up. RSDayFlow is a slim fork of DayFlow with updates and extensions

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

HorizonCalendar A declarative, performant, calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-feat

Airbnb 2.2k Jan 4, 2023
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable

Q: How will my calendar dateCells look with this library? A: However you want them to look. More Images Features Range selection - select dates in a r

PatchTheCode 7.3k Jan 2, 2023
RCalendarPicker A date picker control, Calendar calendar control, select control, calendar, date selection, the clock selection control.

RCalendarPicker RCalendarPicker Calendar calendar control, select control, calendar, date selection, the clock selection control. 日历控件 ,日历选择控件,日历,日期选择

杜耀辉 131 Jul 18, 2022
Simple customizable calendar component in Swift :calendar:

Koyomi Koyomi is a simple calendar view framework for iOS, written in Swift ?? Content Features Demo App Usage introduction : Change displayed month,

Shohei Yokoyama 741 Dec 24, 2022
Malendar is a personal calendar app that connects to your default calendar and lets you add/delete events

Malendar is a personal calendar app that connects to your default calendar and lets you add/delete events. It will gather events from your default iOS calendar.

Chase 194 Jan 4, 2023
The elegant full screen calendar missed in SwiftUI.

ElegantCalendar ElegantCalendar is an efficient and customizable full screen calendar written in SwiftUI. ElegantTimeline - Shows what's possible usin

Kevin Li 553 Dec 27, 2022
A fully customizable iOS calendar library, compatible with Objective-C and Swift

Table of contents Screenshots Installation Pre-knowledge Support Contact Screenshots iPhone iPad Safe Orientation Today Extension iOS8/9 iOS10 Interac

Wenchao Ding 10.2k Jan 2, 2023
A library that expresses a github contribution calendar through an array of dates. Supports iOS and macOS.

A library that expresses a github contribution calendar through an array of dates. Supports iOS and macOS.

jasu 45 Dec 20, 2022
📅 Calendar for iOS, iPadOS and macOS in Swift

CalendarKit CalendarKit is a Swift calendar UI library for iOS, iPadOS and Mac Catalyst. It looks similar to the Apple Calendar app out-of-the-box, wh

Richard Topchii 2.2k Jan 5, 2023
An Easy to Use Calendar for iOS (Swift 5.0)

This is an easy to use, "just drag and drop it in your code" type of calendar for iOS. It supports both vertical and horizontal scrolling, as well as

Michael Michailidis 525 Dec 23, 2022