├── calendar.gif
├── GYZCalendarPicker
├── GYZCalendarPicker
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ ├── icon_xyk.imageset
│ │ │ ├── icon_xyk@2x.png
│ │ │ ├── icon_xyk@3x.png
│ │ │ └── Contents.json
│ │ ├── icon_xyk_selected.imageset
│ │ │ ├── icon_xyk_selected@2x.png
│ │ │ ├── icon_xyk_selected@3x.png
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ ├── AppDelegate.m
│ └── ViewController.m
├── GYZCalendarPicker.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
├── GYZCalendarPickerTests
│ ├── Info.plist
│ └── GYZCalendarPickerTests.m
├── GYZCalendarPickerUITests
│ ├── Info.plist
│ └── GYZCalendarPickerUITests.m
└── CustomCalendar
│ ├── GYZCustomCalendarPickerView.h
│ ├── IDJChineseCalendar.h
│ ├── IDJCalendarUtil.h
│ ├── IDJCalendar.h
│ ├── GYZCommon.h
│ ├── IDJCalendar.m
│ ├── solar_chinese_calendar
│ ├── ChineseDate.cpp
│ ├── ChineseDate.h
│ ├── SolarDate.cpp
│ ├── ChineseCalendarDB.h
│ ├── SolarDate.h
│ └── ChineseCalendarDB.cpp
│ ├── IDJChineseCalendar.mm
│ ├── IDJCalendarUtil.mm
│ └── GYZCustomCalendarPickerView.m
├── README.md
├── LICENSE
└── .gitignore
/calendar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gouyz/GYZCalendarPicker/HEAD/calendar.gif
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GYZCalendarPicker
2 | 类似万年历的阴历、阳历可以切换的日期选择控件,参考http://www.cocoachina.com/bbs/read.php?tid=85374&page=1&toread=1的类库,欢迎大家指正和star。
3 |
4 | 
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk.imageset/icon_xyk@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gouyz/GYZCalendarPicker/HEAD/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk.imageset/icon_xyk@2x.png
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk.imageset/icon_xyk@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gouyz/GYZCalendarPicker/HEAD/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk.imageset/icon_xyk@3x.png
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk_selected.imageset/icon_xyk_selected@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gouyz/GYZCalendarPicker/HEAD/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk_selected.imageset/icon_xyk_selected@2x.png
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk_selected.imageset/icon_xyk_selected@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gouyz/GYZCalendarPicker/HEAD/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk_selected.imageset/icon_xyk_selected@3x.png
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // GYZCalendarPicker
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // GYZCalendarPicker
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // GYZCalendarPicker
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "icon_xyk@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "icon_xyk@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/icon_xyk_selected.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "icon_xyk_selected@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "icon_xyk_selected@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPickerTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPickerUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/GYZCustomCalendarPickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // GYZCustomCalendarPickerView.h
3 | // GYZCalendarPicker
4 | //
5 | // Created by GYZ on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "IDJChineseCalendar.h"
11 | #import "IDJCalendarUtil.h"
12 | #import "GYZCommon.h"
13 |
14 | #define YEAR_START 1970//滚轮显示的起始年份
15 | #define YEAR_END 2049//滚轮显示的结束年份
16 |
17 |
18 | //日历显示的类型
19 | typedef NS_ENUM(NSUInteger, CalendarType) {
20 | GregorianCalendar=1,//公历、阳历
21 | ChineseCalendar //农历、阴历
22 | };
23 |
24 | @protocol GYZCustomCalendarPickerViewDelegate;
25 |
26 | @interface GYZCustomCalendarPickerView : UIView
27 |
28 | @property(nonatomic) CalendarType calendarType;
29 | @property (nonatomic, assign) id delegate;
30 |
31 | - (instancetype)initWithTitle:(NSString *)title;
32 | -(void)show;
33 | @end
34 |
35 | @protocol GYZCustomCalendarPickerViewDelegate
36 | //通知使用这个控件的类,用户选取的日期
37 | - (void)notifyNewCalendar:(IDJCalendar *)cal;
38 | @end
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPickerTests/GYZCalendarPickerTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // GYZCalendarPickerTests.m
3 | // GYZCalendarPickerTests
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GYZCalendarPickerTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation GYZCalendarPickerTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/IDJChineseCalendar.h:
--------------------------------------------------------------------------------
1 | //
2 | // 农历的日历类,从公历类继承而来
3 | // IDJChineseCalendar.h
4 | //
5 | // Created by Lihaifeng on 11-11-28, QQ:61673110.
6 | // Copyright (c) 2011年 www.idianjing.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "IDJCalendar.h"
11 | #define MONTH_COUNTS_IN_YEAR_CHINESE 13//农历的每年的月份的最多的个数
12 | #define DAY_COUNTS_IN_YEAR_CHINESE 30//农历的每月的天数的最多的个数
13 |
14 | //这里要声明的是不要使用NSCalendar *cal=[[NSCalendar alloc]initWithCalendarIdentifier:NSChineseCalendar];的方式,也就是不要使用iOS自带的农历支持,因为存在很大的问题,例如:2012年8月17日iOS经过iOS的转换之后的农历为六月三十,但实际这一年的农历六月只有二十九天,我不明白苹果为什么会犯如此低级的错误。所以本程序的农历算法使用一个C++的开源库,我对其加了一些方法ChineseCalendarDB::GetEraAndYearOfLunar()等,以便和iOS的NSCalendar相匹配。
15 | @interface IDJChineseCalendar : IDJCalendar {
16 | NSArray *chineseYears;//农历年份的天干地支
17 | NSArray *chineseMonths;//农历月份的文字
18 | NSArray *chineseDays;//农历月份的每天的文字
19 | NSString *jiazi;//农历的甲子年份
20 | NSString *animal;//农历的生肖
21 | }
22 | @property (nonatomic, retain) NSArray * chineseYears;
23 | @property (nonatomic, retain) NSArray * chineseMonths;
24 | @property (nonatomic, retain) NSArray * chineseDays;
25 | @property (nonatomic, copy) NSString *jiazi;
26 | @property (nonatomic, copy) NSString *animal;
27 | @end
28 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPickerUITests/GYZCalendarPickerUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // GYZCalendarPickerUITests.m
3 | // GYZCalendarPickerUITests
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GYZCalendarPickerUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation GYZCalendarPickerUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/IDJCalendarUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // 日历的工具类
3 | // IDJCalendarUtil.h
4 | //
5 | // Created by Lihaifeng on 11-11-30, QQ:61673110.
6 | // Copyright (c) 2011年 www.idianjing.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #define CHINESE_MONTH_NORMAL @"a"//农历的状态下,month字段中存储a-1,a表示非闰月
11 | #define CHINESE_MONTH_LUNAR @"b"//农历的状态下,month字段中存储b-1,b表示闰月
12 |
13 | @interface IDJCalendarUtil : NSObject
14 | //农历转公历,这里只是借助NSDateComponents存放转换后的年月日
15 | + (NSDateComponents *)toSolarDateWithYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day;
16 | //公历转农历,这里只是借助NSDateComponents存放转换后的年月日
17 | + (NSDateComponents *)toChineseDateWithYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day;
18 | //依据公历日期计算星期
19 | + (int)weekDayWithSolarYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day;
20 | //依据农历日期计算星期
21 | + (int)weekDayWithChineseYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day;
22 | //这里把a-1、b-1的月份转换为1 - 13
23 | + (NSUInteger)monthFromMineToCppWithYear:(NSUInteger)_year month:(NSString *)_month;
24 | //这里把1 - 13的月份转换为a-1、b-1
25 | + (NSString *)monthFromCppToMineWithYear:(NSUInteger)_year month:(NSUInteger)_month;
26 | //通过甲子年份获取生肖
27 | + (NSString *)animalWithJiazi:(NSUInteger)jiazi;
28 | //通过年份获取农历的年代和甲子年份,对C++里的ChineseCalendarDB::GetEraAndYearOfLunar()的再次封装,避免视图层介入C++的API
29 | + (void)jiaziWithYear:(NSUInteger)_year outEra:(int *)era outJiazi:(int *)jiazi;
30 | //获取某一年的24个节气,数组中的每一项为1-6-小寒,1-6为农历正月初六
31 | + (NSMutableDictionary *)jieqiWithYear:(NSUInteger)_year;
32 | @end
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | # CocoaPods
31 | #
32 | # We recommend against adding the Pods directory to your .gitignore. However
33 | # you should judge for yourself, the pros and cons are mentioned at:
34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
35 | #
36 | # Pods/
37 |
38 | # Carthage
39 | #
40 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
41 | # Carthage/Checkouts
42 |
43 | Carthage/Build
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51 |
52 | fastlane/report.xml
53 | fastlane/screenshots
54 |
55 | #Code Injection
56 | #
57 | # After new code Injection tools there's a generated folder /iOSInjectionProject
58 | # https://github.com/johnno1962/injectionforxcode
59 |
60 | iOSInjectionProject/
61 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/IDJCalendar.h:
--------------------------------------------------------------------------------
1 | //
2 | // 公历的日历类
3 | // IDJCalendar.h
4 | //
5 | // Created by Lihaifeng on 11-11-28, QQ:61673110.
6 | // Copyright (c) 2011年 www.idianjing.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #define MONTH_COUNTS_IN_YEAR_GRE 12//公历每年的月份的个数
11 | #define DAY_COUNTS_IN_YEAR__GRE 31//公历每月的最多的天数
12 | #define CALENDAR_UNIT_FLAGS (NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit)//从日期中获取的字段列表
13 |
14 | @interface IDJCalendar : NSObject{
15 | NSUInteger yearStart;//日历的年份起始值
16 | NSUInteger yearEnd;//日历的年份结束值
17 | NSCalendar *greCal;//系统的日历类
18 | NSString *era;//年代
19 | NSString *year;//年份
20 | NSString *month;//月份
21 | NSString *day;//日期
22 | NSString *weekday;//星期
23 | NSArray *weekdays;//星期的数据
24 | }
25 | @property (nonatomic, assign) NSUInteger yearStart;
26 | @property (nonatomic, assign) NSUInteger yearEnd;
27 | @property (nonatomic, retain) NSCalendar *greCal;
28 | @property (nonatomic, copy) NSString * era;
29 | @property (nonatomic, copy) NSString * year;
30 | @property (nonatomic, copy) NSString * month;
31 | @property (nonatomic, copy) NSString * day;
32 | @property (nonatomic, copy) NSString * weekday;
33 | @property (nonatomic, retain) NSArray * weekdays;
34 | - (id)initWithYearStart:(NSUInteger)start end:(NSUInteger)end;
35 | //计算指定范围yearStart - yearEnd的年份数据
36 | - (NSMutableArray *)yearsInRange;
37 | //计算指定年份的月份数据
38 | - (NSMutableArray *)monthsInYear:(NSUInteger)_year;
39 | //计算指定月份的日期数据
40 | - (NSMutableArray *)daysInMonth:(NSString *)_month year:(NSUInteger)_year;
41 | @end
42 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/GYZCommon.h:
--------------------------------------------------------------------------------
1 | //
2 | // GYZCommon.h
3 | // GYZCalendarPicker
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #ifndef GYZCommon_h
10 | #define GYZCommon_h
11 |
12 | #define PADDING 10
13 | #define kLineHeight 1
14 |
15 |
16 | #define IMAGE(img) [UIImage imageNamed:img]
17 |
18 | /********颜色相关宏***********/
19 | //十六进制颜色
20 | #define UIColorFromRGB(rgbValue) [UIColor \
21 | colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
22 | green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
23 | blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
24 | #define kColor(R,G,B,A) [UIColor colorWithRed:R/255.f green:G/255.f blue:B/255.f alpha:A]
25 |
26 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height
27 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width
28 |
29 |
30 | // View 坐标(x,y)和宽高(width,height)
31 | #define X(v) (v).frame.origin.x
32 | #define Y(v) (v).frame.origin.y
33 | #define WIDTH(v) (v).frame.size.width
34 | #define HEIGHT(v) (v).frame.size.height
35 |
36 | #define MinX(v) CGRectGetMinX((v).frame) // 获得控件屏幕的x坐标
37 | #define MinY(v) CGRectGetMinY((v).frame) // 获得控件屏幕的Y坐标
38 |
39 | #define MidX(v) CGRectGetMidX((v).frame) //横坐标加上到控件中点坐标
40 | #define MidY(v) CGRectGetMidY((v).frame) //纵坐标加上到控件中点坐标
41 |
42 | #define MaxX(v) CGRectGetMaxX((v).frame) //横坐标加上控件的宽度
43 | #define MaxY(v) CGRectGetMaxY((v).frame) //纵坐标加上控件的高度
44 |
45 | //字体定义
46 | #define k12Font [UIFont systemFontOfSize:12.0f]
47 | #define k14Font [UIFont systemFontOfSize:14.0f]
48 | #define k15Font [UIFont systemFontOfSize:15.0f]
49 | #define k18Font [UIFont systemFontOfSize:18.0f]
50 |
51 | #endif /* GYZCommon_h */
52 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // GYZCalendarPicker
4 | //
5 | // Created by Mac on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/IDJCalendar.m:
--------------------------------------------------------------------------------
1 | //
2 | // IDJCalendar.m
3 | //
4 | // Created by Lihaifeng on 11-11-28, QQ:61673110.
5 | // Copyright (c) 2011年 www.idianjing.com. All rights reserved.
6 | //
7 |
8 | #import "IDJCalendar.h"
9 |
10 | @implementation IDJCalendar
11 | @synthesize yearStart, yearEnd, greCal, era, year, month, day, weekday, weekdays;
12 |
13 | - (id)initWithYearStart:(NSUInteger)start end:(NSUInteger)end {
14 | self=[super init];
15 | if (self) {
16 | self.yearStart=start;
17 | self.yearEnd=end;
18 | NSCalendar *cal=[[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
19 | [cal setTimeZone:[NSTimeZone defaultTimeZone]];
20 | self.greCal=cal;
21 | self.weekdays=[NSArray arrayWithObjects:@"周日", @"周一", @"周二", @"周三", @"周四", @"周五", @"周六", nil];
22 |
23 | //设置当前时间的相关字段
24 | NSDate *currentDate = [NSDate date];
25 | NSDateComponents *dc = nil;
26 | dc = [cal components:CALENDAR_UNIT_FLAGS fromDate:currentDate];
27 | self.era=[NSString stringWithFormat:@"%d", dc.era];
28 | self.year=[NSString stringWithFormat:@"%d", dc.year];
29 | self.month=[NSString stringWithFormat:@"%d", dc.month];
30 | self.day=[NSString stringWithFormat:@"%d", dc.day];
31 | self.weekday=[NSString stringWithFormat:@"%d", dc.weekday];
32 | }
33 | return self;
34 | }
35 |
36 | - (NSMutableArray *)yearsInRange {
37 | NSMutableArray * array=[[NSMutableArray alloc]initWithCapacity:yearEnd-yearStart+1];
38 | for (int i=yearStart; i<=yearEnd; i++) {
39 | [array addObject:[NSString stringWithFormat:@"%d", i]];
40 | }
41 | return array;
42 | }
43 |
44 | //公历的一年只有12个月
45 | - (NSMutableArray *)monthsInYear:(NSUInteger)_year {
46 | NSMutableArray *array=[[NSMutableArray alloc]initWithCapacity:MONTH_COUNTS_IN_YEAR_GRE];
47 | for (int i=0; i{
14 | UIButton *_selectBtn;
15 | }
16 |
17 | @end
18 |
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 |
24 | _selectBtn = [[UIButton alloc]initWithFrame:CGRectMake(30, 100, WIDTH(self.view)-30*2, 60)];
25 | [_selectBtn setTitle:@"点击" forState:UIControlStateNormal];
26 | [_selectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
27 | [_selectBtn addTarget:self action:@selector(showCalendar) forControlEvents:UIControlEventTouchUpInside];
28 | [self.view addSubview:_selectBtn];
29 |
30 | }
31 |
32 | - (void)didReceiveMemoryWarning {
33 | [super didReceiveMemoryWarning];
34 | // Dispose of any resources that can be recreated.
35 | }
36 |
37 | -(void)showCalendar{
38 | //日期实现
39 | GYZCustomCalendarPickerView *pickerView = [[GYZCustomCalendarPickerView alloc]initWithTitle:@"选择日期"];
40 | pickerView.delegate = self;
41 | pickerView.calendarType = GregorianCalendar;//日期类型
42 | [pickerView show];
43 | }
44 |
45 | #pragma QTCustomCalendarPickerViewDelegate
46 | //接收日期选择器选项变化的通知
47 | - (void)notifyNewCalendar:(IDJCalendar *)cal {
48 | NSString *result = @"点击";
49 | if ([cal isMemberOfClass:[IDJCalendar class]]) {//阳历
50 |
51 | NSString *year =[NSString stringWithFormat:@"%@",cal.year];
52 | NSString *month = [cal.month intValue] > 9 ? cal.month:[NSString stringWithFormat:@"0%@",cal.month];
53 | NSString *day = [cal.day intValue] > 9 ? cal.day:[NSString stringWithFormat:@"0%@",cal.day];
54 | result = [NSString stringWithFormat:@"%@-%@-%@",year,month, day];
55 |
56 | } else if ([cal isMemberOfClass:[IDJChineseCalendar class]]) {//阴历
57 |
58 | IDJChineseCalendar *_cal=(IDJChineseCalendar *)cal;
59 |
60 | NSArray *array=[_cal.month componentsSeparatedByString:@"-"];
61 | NSString *dateStr = @"";
62 | if ([[array objectAtIndex:0]isEqualToString:@"a"]) {
63 | dateStr = [NSString stringWithFormat:@"%@%@",dateStr,[_cal.chineseMonths objectAtIndex:[[array objectAtIndex:1]intValue]-1]];
64 | } else {
65 | dateStr = [NSString stringWithFormat:@"%@闰%@",dateStr,[_cal.chineseMonths objectAtIndex:[[array objectAtIndex:1]intValue]-1]];
66 | }
67 | result = [NSString stringWithFormat:@"%@%@",dateStr, [NSString stringWithFormat:@"%@", [_cal.chineseDays objectAtIndex:[_cal.day intValue]-1]]];
68 | }
69 | [_selectBtn setTitle:result forState:UIControlStateNormal];
70 |
71 | }
72 | @end
73 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/solar_chinese_calendar/ChineseDate.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * ChineseDate.cpp
3 | * @Author Tu Yongce
4 | * @Created 2008-12-13
5 | * @Modified 2008-12-13
6 | * @Version 0.1
7 | */
8 |
9 | #include "ChineseDate.h"
10 | #include "ChineseCalendarDB.h"
11 | #include "SolarDate.h"
12 |
13 |
14 | // 判断是否为有效日期
15 | bool ChineseDate::IsValidDate() const
16 | {
17 | if (m_year < 1901 || m_year > 2050)
18 | return false;
19 |
20 | if (m_month < 1 || m_month > ChineseCalendarDB::GetYearMonths(m_year))
21 | return false;
22 |
23 | if (m_day < 1 || m_day > ChineseCalendarDB::GetMonthDays(m_year, m_month))
24 | return false;
25 |
26 | return true;
27 | }
28 |
29 | // 计算当前日期是该年的第几天
30 | int ChineseDate::YearDay() const
31 | {
32 | int days = 0;
33 |
34 | for (int i = 1; i < m_month; ++i)
35 | days += ChineseCalendarDB::GetMonthDays(m_year, i);
36 | days += m_day;
37 |
38 | return days;
39 | }
40 |
41 | // 计算*this和ref之间相差的天数,要求ref.IsPrior(*this)为真
42 | int ChineseDate::DoDiff(const ChineseDate &ref) const
43 | {
44 | assert(!IsPrior(ref)); // *this >= ref
45 |
46 | int days = 0;
47 |
48 | // 首先计算两个年份的1月1日相差的天数
49 | for (int year = ref.m_year; year < m_year; ++year) {
50 | days += ChineseCalendarDB::GetYearDays(year);
51 | }
52 |
53 | // 处理月和日
54 | days += YearDay();
55 | days -= ref.YearDay();
56 |
57 | return days;
58 | }
59 |
60 | // 从该年的某天计算日期
61 | // 如果无对应日期,则操作失败并返回false;否则返回true
62 | bool ChineseDate::FromYearDay(int days)
63 | {
64 | if (days < 1 && days > ChineseCalendarDB::GetYearDays(m_year))
65 | return false;
66 |
67 | m_month = 1;
68 | int monthDay = ChineseCalendarDB::GetMonthDays(m_year, m_month);
69 |
70 | while (days > monthDay) {
71 | days -= monthDay;
72 | ++m_month;
73 | monthDay = ChineseCalendarDB::GetMonthDays(m_year, m_month);
74 | }
75 |
76 | m_day = days;
77 |
78 | assert(IsValidDate()); // 当ChineseDate对象内部数据变化时确保仍是正确的日期
79 | return true;
80 | }
81 |
82 |
83 | // 向前(未来)调整指定天数(注意:不能调整到农历2050年12月30日之后)
84 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
85 | bool ChineseDate::DoAdjustForward(int days)
86 | {
87 | assert(days > 0);
88 | if (ChineseDate(2050, 12, 30).DoDiff(*this) < days)
89 | return false; // 不能调整到农历2050年12月30日之后
90 |
91 | // 以每年最后一天为参考点进行计算
92 | days += YearDay();
93 | int yearDays = ChineseCalendarDB::GetYearDays(m_year);
94 |
95 | while (days > yearDays) {
96 | days -= yearDays;
97 | ++m_year;
98 | yearDays = ChineseCalendarDB::GetYearDays(m_year);
99 | }
100 |
101 | FromYearDay(days);
102 |
103 | return true;
104 | }
105 |
106 | // 向后(过去)调整指定天数(注意:不能调整到农历1901年1月1日之前)
107 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
108 | bool ChineseDate::DoAdjustBackward(int days)
109 | {
110 | assert(days > 0);
111 | if (this->DoDiff(ChineseDate(1901, 1, 1)) < days)
112 | return false; // 不能调整时间到农历1901年1月1日之前
113 |
114 | // 以每年第一天(1月1日)为参考点进行计算
115 | int yearDays = ChineseCalendarDB::GetYearDays(m_year);
116 | days += yearDays - YearDay();
117 |
118 | while (days > yearDays) {
119 | days -= yearDays;
120 | --m_year;
121 | yearDays = ChineseCalendarDB::GetYearDays(m_year);
122 | }
123 |
124 | FromYearDay(yearDays - days);
125 |
126 | return true;
127 | }
128 |
129 | // 转换为阳历
130 | SolarDate ChineseDate::ToSolarDate() const
131 | {
132 | // 参考日期:农历2000年1月1日就是公元2000年2月5日
133 | ChineseDate refDay(2000, 1, 1);
134 |
135 | // 计算出当前日期与参考日期之间的天数
136 | int days = this->Diff(refDay);
137 |
138 | SolarDate tmp(2000, 2, 5);
139 | tmp.AdjustDays(days);
140 | assert(tmp.Diff(SolarDate(2000, 2, 5)) == days);
141 |
142 | return tmp;
143 | }
144 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/solar_chinese_calendar/ChineseDate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * ChineseDate.h
3 | * @Author Tu Yongce
4 | * @Created 2008-12-13
5 | * @Modified 2008-12-13
6 | * @Version 0.1
7 | */
8 |
9 | #ifndef CHINESE_DATE_H_INCLUDED
10 | #define CHINESE_DATE_H_INCLUDED
11 |
12 | #ifdef _MSC_VER
13 | #pragma once
14 | #endif
15 |
16 | #include
17 | #include "ChineseCalendarDB.h"
18 |
19 | class SolarDate; // 前置声明
20 |
21 | /*
22 | * 农历日期类
23 | * @note: 只能表示农历1901年1月1日到农历2050年12月30日期间的日期
24 | */
25 | class ChineseDate
26 | {
27 | private:
28 | int m_year; // 1901~2050
29 | int m_month; // 1~13
30 | int m_day; // 1~[29|30]
31 |
32 | public:
33 | ChineseDate();
34 | ChineseDate(int year, int month, int day);
35 | //!! 使用编译器生成的拷贝构造函数、拷贝赋值操作符和析构函数
36 |
37 | int GetYear() const;
38 | int GetMonth() const;
39 | int GetDay() const;
40 |
41 | // 判断是否为有效日期
42 | bool IsValidDate() const;
43 |
44 | // 判断是否在指定日期之前
45 | bool IsPrior(const ChineseDate &ref) const;
46 | // 判断是否为同一日期
47 | friend bool operator== (const ChineseDate &lhs, const ChineseDate &rhs);
48 | friend bool operator!= (const ChineseDate &lhs, const ChineseDate &rhs);
49 |
50 | // 计算当前日期是该年的第几天
51 | int YearDay() const;
52 | // 从该年的某天计算日期(如果无对应日期,则操作失败并返回false;否则返回true)
53 | bool FromYearDay(int days);
54 |
55 | // 计算和指定日期相差的天数
56 | // 如果this->IsPrior(ref)为真,则返回负数;否则返回正数
57 | int Diff(const ChineseDate &ref) const;
58 |
59 | // 向前或者向后调整指定天数(有效日期范围:农历1901年1月1日到农历2050年12月30日)
60 | // 如果days大于0,则向前调整(未来);否则向后调整(过去)
61 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
62 | bool AdjustDays(int days);
63 |
64 | // 转换为阳历
65 | SolarDate ToSolarDate() const;
66 |
67 | private:
68 | // 计算*this和ref之间相差的天数,要求!IsPrior(ref)为真
69 | int DoDiff(const ChineseDate &ref) const;
70 |
71 | // 向前(未来)调整指定天数(注意:不能调整到农历2050年12月30日之后)
72 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
73 | bool DoAdjustForward(int days);
74 |
75 | // 向后(过去)调整指定天数(注意:不能调整到农历1901年1月1日之前)
76 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
77 | bool DoAdjustBackward(int days);
78 | };
79 |
80 | inline ChineseDate::ChineseDate(): m_year(1901), m_month(1), m_day(1)
81 | {
82 | }
83 |
84 | inline ChineseDate::ChineseDate(int year, int month, int day): m_year(year), m_month(month), m_day(day)
85 | {
86 | //assert(IsValidDate()); // 当ChineseDate对象内部数据变化时确保仍是正确的日期
87 | }
88 |
89 | inline int ChineseDate::GetYear() const
90 | {
91 | return m_year;
92 | }
93 |
94 | inline int ChineseDate::GetMonth() const
95 | {
96 | return m_month;
97 | }
98 |
99 | inline int ChineseDate::GetDay() const
100 | {
101 | return m_day;
102 | }
103 |
104 | // 判断是否在指定日期之前
105 | inline bool ChineseDate::IsPrior(const ChineseDate &ref) const
106 | {
107 | return m_year < ref.m_year || (m_year == ref.m_year && (m_month < ref.m_month || (m_month == ref.m_month && m_day < ref.m_day)));
108 | }
109 |
110 | // 判断是否为同一日期
111 | inline bool operator== (const ChineseDate &lhs, const ChineseDate &rhs)
112 | {
113 | return lhs.m_year == rhs.m_year && lhs.m_month == rhs.m_month && lhs.m_day == rhs.m_day;
114 | }
115 |
116 | inline bool operator!= (const ChineseDate &lhs, const ChineseDate &rhs)
117 | {
118 | return !(lhs == rhs);
119 | }
120 |
121 | // 计算和指定日期相差的天数
122 | // 如果this->IsPrior(ref)为真,则返回负数;否则返回正数
123 | inline int ChineseDate::Diff(const ChineseDate &ref) const
124 | {
125 | return this->IsPrior(ref) ? -ref.DoDiff(*this) : this->DoDiff(ref);
126 | }
127 |
128 | // 向前或者向后调整指定天数(注意:不能调整到公元1年1月1日之前)
129 | // 如果days大于0,则向前调整(未来);否则向后调整(过去)
130 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
131 | inline bool ChineseDate::AdjustDays(int days)
132 | {
133 | if (days > 0)
134 | return DoAdjustForward(days);
135 | else if (days < 0)
136 | return DoAdjustBackward(-days);
137 |
138 | assert(IsValidDate()); // 当ChineseDate对象内部数据变化时确保仍是正确的日期
139 | return true;
140 | }
141 |
142 |
143 | #endif //CHINESE_DATE_H_INCLUDED
144 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/IDJChineseCalendar.mm:
--------------------------------------------------------------------------------
1 | //
2 | // IDJChineseCalendar.mm
3 | // 本文件使用了C++混编,所以扩展名为.mm
4 | //
5 | // Created by Lihaifeng on 11-11-28, QQ:61673110.
6 | // Copyright (c) 2011年 www.idianjing.com. All rights reserved.
7 | //
8 |
9 | #import "IDJChineseCalendar.h"
10 | #import "SolarDate.h"
11 | #import "ChineseDate.h"
12 | #import "IDJCalendarUtil.h"
13 |
14 | @implementation IDJChineseCalendar
15 | @synthesize chineseYears, chineseMonths, chineseDays, jiazi, animal;
16 |
17 | - (id)initWithYearStart:(NSUInteger)start end:(NSUInteger)end {
18 | self=[super initWithYearStart:start end:end];
19 | if (self) {
20 | //从父类的公历数据创建C++的公历类SolarDate的对象
21 | SolarDate solarDate=SolarDate([self.year intValue], [self.month intValue], [self.day intValue]);
22 | ChineseDate chineseDate;
23 | //从公历对象转为农历对象
24 | solarDate.ToChineseDate(chineseDate);
25 | //获取当年的公历年份对应的农历的年代和甲子年份
26 | std::pair p=ChineseCalendarDB::GetEraAndYearOfLunar(chineseDate.GetYear());
27 |
28 | //设置当前时间的农历日期字段
29 | self.era=[NSString stringWithFormat:@"%d", p.first];
30 | self.year=[NSString stringWithFormat:@"%d", chineseDate.GetYear()];
31 | self.jiazi=[NSString stringWithFormat:@"%d", p.second];
32 | self.animal=[IDJCalendarUtil animalWithJiazi:[self.jiazi intValue]];
33 | //获取当前年份的闰月的月份,没有闰月返回0
34 | self.month=[IDJCalendarUtil monthFromCppToMineWithYear:chineseDate.GetYear() month:chineseDate.GetMonth()];
35 | self.day=[NSString stringWithFormat:@"%d", chineseDate.GetDay()];
36 |
37 | self.chineseYears=[NSArray arrayWithObjects:@"甲子", @"乙丑", @"丙寅", @"丁卯", @"戊辰", @"己巳", @"庚午", @"辛未", @"壬申", @"癸酉",
38 | @"甲戌", @"乙亥", @"丙子", @"丁丑", @"戊寅", @"己卯", @"庚辰", @"辛己", @"壬午", @"癸未",
39 | @"甲申", @"乙酉", @"丙戌", @"丁亥", @"戊子", @"己丑", @"庚寅", @"辛卯", @"壬辰", @"癸巳",
40 | @"甲午", @"乙未", @"丙申", @"丁酉", @"戊戌", @"己亥", @"庚子", @"辛丑", @"壬寅", @"癸丑",
41 | @"甲辰", @"乙巳", @"丙午", @"丁未", @"戊申", @"己酉", @"庚戌", @"辛亥", @"壬子", @"癸丑",
42 | @"甲寅", @"乙卯", @"丙辰", @"丁巳", @"戊午", @"己未", @"庚申", @"辛酉", @"壬戌", @"癸亥", nil];
43 | self.chineseMonths=[NSArray arrayWithObjects:@"正月", @"二月", @"三月", @"四月", @"五月", @"六月", @"七月", @"八月",
44 | @"九月", @"十月", @"冬月", @"腊月", nil];
45 | self.chineseDays=[NSArray arrayWithObjects:@"初一", @"初二", @"初三", @"初四", @"初五", @"初六", @"初七", @"初八", @"初九", @"初十",
46 | @"十一", @"十二", @"十三", @"十四", @"十五", @"十六", @"十七", @"十八", @"十九", @"二十",
47 | @"廿一", @"廿二", @"廿三", @"廿四", @"廿五", @"廿六", @"廿七", @"廿八", @"廿九", @"三十", nil];
48 | }
49 | return self;
50 | }
51 |
52 | - (NSMutableArray *)yearsInRange {
53 | NSMutableArray *array=[[NSMutableArray alloc]initWithCapacity:yearEnd-yearStart+1];
54 | for (int i=yearStart; i<=yearEnd; i++) {
55 | SolarDate solarDate=SolarDate(i, 1, 1);
56 | ChineseDate chineseDate;
57 | solarDate.ToChineseDate(chineseDate);
58 | std::pair p=ChineseCalendarDB::GetEraAndYearOfLunar(i);
59 | //我们要把农历的年份显示为甲寅年这样的文字,所以years容器中应该存储甲子年份,但是农历的甲子年份60年循环一次,无法与公历年份对应,所以我们额外存储年代、公历年份
60 | [array addObject:[NSString stringWithFormat:@"%d-%d-%d", p.first, p.second, i]];
61 | }
62 | return array;
63 | }
64 |
65 | - (NSMutableArray *)monthsInYear:(NSUInteger)_year {
66 | int monthCounts=ChineseCalendarDB::GetYearMonths(_year);
67 | NSMutableArray *myMonths=[[NSMutableArray alloc]initWithCapacity:monthCounts];
68 | for (int i=1; i<=monthCounts; i++) {
69 | [myMonths addObject:[IDJCalendarUtil monthFromCppToMineWithYear:_year month:i]];
70 | }
71 | return myMonths;
72 | }
73 |
74 | - (NSMutableArray *)daysInMonth:(NSString *)_month year:(NSUInteger)_year {
75 | //由于参数_month是a-1、b-5这样的文字,我们需要还原为这个C++算法要求的1 - 13的数字
76 | int month_=[IDJCalendarUtil monthFromMineToCppWithYear:_year month:_month];
77 | int dayCounts=ChineseCalendarDB::GetMonthDays(_year, month_);
78 | NSMutableArray *myDays=[[NSMutableArray alloc]initWithCapacity:DAY_COUNTS_IN_YEAR_CHINESE];
79 | for (int i=1; i<=dayCounts; i++) {
80 | [myDays addObject:[NSString stringWithFormat:@"%d", i]];
81 | }
82 | return myDays;
83 | }
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/solar_chinese_calendar/SolarDate.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * SolarDate.cpp
3 | * @Author Tu Yongce
4 | * @Created 2008-12-13
5 | * @Modified 2008-12-13
6 | * @Version 0.1
7 | */
8 |
9 | #include "SolarDate.h"
10 | #include "ChineseDate.h"
11 |
12 | // 平年中每一个月的天数
13 | const int SolarDate::sm_monthDay[12] = {
14 | 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
15 | };
16 |
17 | // 平年中每一个月之前所有月的天数
18 | const int SolarDate::sm_yearDays[12] = {
19 | 0, 31, 59 , 90, 120, 151, 181, 212, 243, 273, 304, 334
20 | };
21 |
22 |
23 | // 判断是否为有效日期
24 | bool SolarDate::IsValidDate() const
25 | {
26 | if (m_year < 1 || m_month < 1 || m_month > 12 || m_day < 1)
27 | return false;
28 |
29 | if (m_month != 2 && m_day > sm_monthDay[m_month - 1])
30 | return false;
31 |
32 | int feb = (IsLeapYear() ? 29 : 28);
33 | if (m_month == 2 && m_day > feb)
34 | return false;
35 |
36 | return true;
37 | }
38 |
39 | // 从该年的某天计算日期
40 | // 如果无对应日期,则操作失败并返回false;否则返回true
41 | bool SolarDate::FromYearDay(int days)
42 | {
43 | if (days < 1 || days > (IsLeapYear() ? 366 : 365))
44 | return false;
45 |
46 | int m = 11;
47 | for (; m > 0; --m) {
48 | if (sm_yearDays[m] < days)
49 | break;
50 | }
51 |
52 | m_month = m + 1;
53 | m_day = days - sm_yearDays[m];
54 |
55 | if (m_month > 2 && IsLeapYear()) {
56 | // 闰年
57 | if (m_day > 1)
58 | --m_day;
59 | else {
60 | --m_month;
61 | m_day = sm_monthDay[m_month - 1];
62 | }
63 | }
64 |
65 | assert(IsValidDate()); // 当ChineseDate对象内部数据变化时确保仍是正确的日期
66 | return true;
67 | }
68 |
69 | // 计算*this和ref之间相差的天数,要求!IsPrior(ref)为真
70 | int SolarDate::DoDiff(const SolarDate &ref) const
71 | {
72 | assert(!IsPrior(ref)); // *this >= ref
73 |
74 | // 首先计算两个年份的1月1日相差的天数
75 | int days = (m_year - ref.m_year) * 365;
76 |
77 | // 算上闰年的额外天数
78 | days += GetLeapYears(m_year);
79 | days -= GetLeapYears(ref.m_year);
80 |
81 | // 再处理月和日
82 | days += YearDay();
83 | days -= ref.YearDay();
84 |
85 | return days;
86 | }
87 |
88 | // 向前(未来)调整指定天数(始终返回true)
89 | bool SolarDate::DoAdjustForward(int days)
90 | {
91 | assert(days > 0);
92 |
93 | // 以每年最后一天为参考点进行计算
94 | days += YearDay();
95 |
96 | // 400年一个轮回
97 | const int t1 = 400 * 365 + 100 - 3;
98 | m_year += days / t1 * 400;
99 | days -= days / t1 * t1;
100 |
101 | int y = days / 365;
102 | int leapYears = GetLeapYears(m_year + y) - GetLeapYears(m_year);
103 |
104 | days -= y * 365;
105 |
106 | if (days > leapYears) {
107 | m_year += y;
108 | FromYearDay(days - leapYears);
109 | } else {
110 | m_year += y - 1;
111 | int yearDays = GetYearDays();
112 | FromYearDay(days + yearDays - leapYears);
113 | }
114 |
115 | return true;
116 | }
117 |
118 | // 向后(过去)调整指定天数(注意:不能调整到公元1年1月1日之前)
119 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
120 | bool SolarDate::DoAdjustBackward(int days)
121 | {
122 | assert(days > 0);
123 | if (this->DoDiff(SolarDate(1, 1, 1)) < days)
124 | return false; // 不能调整时间到公元前
125 |
126 | // 以每年第一天(1月1日)为参考点进行计算
127 | days += GetYearDays() - YearDay();
128 |
129 | // 400年一个轮回
130 | const int t1 = 400 * 365 + 100 - 3;
131 | m_year -= days / t1 * 400;
132 | days -= days / t1 * t1;
133 |
134 | int y = days / 365;
135 | int leapYears = GetLeapYears(m_year + 1) - GetLeapYears(m_year - y + 1);
136 |
137 | days -= y * 365;
138 |
139 | if (days >= leapYears) {
140 | m_year -= y;
141 | days -= leapYears;
142 | FromYearDay(GetYearDays() - days);
143 | } else {
144 | m_year -= y - 1;
145 | FromYearDay(leapYears - days);
146 | }
147 |
148 | return true;
149 | }
150 |
151 | // 转换为农历(把公元1901年2月19日到公元2051年2月10日期间的公历日期转换为农历日期)
152 | // 如果转换成功,返回true;否则返回false
153 | bool SolarDate::ToChineseDate(ChineseDate &date) const
154 | {
155 | if (this->IsPrior(SolarDate(1901, 12, 19)) || SolarDate(2051, 2, 10).IsPrior(*this))
156 | return false; // 只能转换公元1901年2月19日到公元2051年2月10日期间的公历日期
157 |
158 | // 参考日期:公元2000年2月5日就是农历2000年1月1日
159 | SolarDate refDay(2000, 2, 5);
160 |
161 | // 计算出当前日期与参考日期之间的天数
162 | int days = this->Diff(refDay);
163 |
164 | ChineseDate tmp(2000, 1, 1);
165 | tmp.AdjustDays(days);
166 | date = tmp;
167 | assert(tmp.Diff(ChineseDate(2000, 1, 1)) == days);
168 |
169 | return true;
170 | }
171 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/solar_chinese_calendar/ChineseCalendarDB.h:
--------------------------------------------------------------------------------
1 | /**
2 | * ChineseCalendarDB.h
3 | * @Author Tu Yongce
4 | * @Created 2008-12-13
5 | * @Modified 2011-11-28 Lihaifeng Add funtion GetEraAndYear(), QQ:61673110, Company:www.idianjing.com.
6 | * @Version 0.1
7 | */
8 |
9 | #ifndef CHINESE_CALENDAR_DB_H_INCLUDED
10 | #define CHINESE_CALENDAR_DB_H_INCLUDED
11 |
12 | #ifdef _MSC_VER
13 | #pragma once
14 | #endif
15 |
16 | #include
17 | #include
18 | #include
19 |
20 | class ChineseCalendarDB
21 | {
22 | private:
23 |
24 | static const int YEAR_BASE = 1901; // 阴历数据的起始年
25 | static const int YEAR_NUM = 150; // 阴历数据的年数
26 |
27 | static const uint8_t sm_leapMonth[YEAR_NUM]; // 每年的闰月月份
28 | static const uint16_t sm_monthDay[YEAR_NUM]; // 每年的所有月的月天数
29 | static const uint8_t sm_solarTerm[YEAR_NUM][12]; // 每年的二十四节气数据
30 |
31 | public:
32 | // 当表示参数无效时抛出的异常类型
33 | class InvalidParamter: public std::exception
34 | {
35 | };
36 |
37 | public:
38 | /*
39 | * 查询农历某年的闰月
40 | * @param year: 要查询的年份,有效取值范围1901~2050
41 | * @return: 返回该年的闰月(如果没有闰月则返回0)
42 | * 如果参数year不在有效值范围内,则抛出异常ChineseCalendarDB::InvalidParamter
43 | */
44 | static int GetLeapMonth(int year)
45 | {
46 | if (year < YEAR_BASE || year >= YEAR_BASE + YEAR_NUM)
47 | throw InvalidParamter(); // 没有该年的数据
48 | return sm_leapMonth[year - YEAR_BASE];
49 | }
50 |
51 | /*
52 | * 查询农历某年的月数
53 | * @param year: 要查询的年份,有效取值范围1901~2050
54 | * @return: 返回该年的月数(如果没有闰月则返回12,有闰月返回13)
55 | * 如果参数year不在有效值范围内,则抛出异常ChineseCalendarDB::InvalidParamter
56 | */
57 | static int GetYearMonths(int year)
58 | {
59 | if (year < YEAR_BASE || year >= YEAR_BASE + YEAR_NUM)
60 | throw InvalidParamter(); // 没有该年的数据
61 | return sm_leapMonth[year - YEAR_BASE] ? 13 : 12;
62 | }
63 |
64 | /*
65 | * 查询农历某年某月的天数
66 | * @param year: 要查询的年份,有效取值范围1901~2050
67 | * @param month: 要查询的月份,有效取值范围为1~12或1~13(有闰月)
68 | * @return: 返回该月的天数(30或29)
69 | * 如果参数year或month不在有效值范围内,则抛出异常ChineseCalendarDB::InvalidParamter
70 | */
71 | static int GetMonthDays(int year, int month)
72 | {
73 | if (year < YEAR_BASE || year >= YEAR_BASE + YEAR_NUM)
74 | throw InvalidParamter(); // 没有该年的数据
75 |
76 | int num = 12 + (sm_leapMonth[year - YEAR_BASE] ? 1 : 0);
77 | if (month < 1 || month > num)
78 | throw InvalidParamter(); // 没有该年的数据
79 |
80 | return (sm_monthDay[year - YEAR_BASE] & (1 << (month - 1))) ? 30 : 29;
81 | }
82 |
83 | /*
84 | * 查询农历某年的天数
85 | * @param year: 要查询的年份,有效取值范围1901~2050
86 | * @return: 返回该年的天数
87 | * 如果参数year不在有效值范围内,则抛出异常ChineseCalendarDB::InvalidParamter
88 | */
89 | static int GetYearDays(int year)
90 | {
91 | // 实现注记:以后可以考虑把每年的天数保存起来,直接查找
92 | if (year < YEAR_BASE || year >= YEAR_BASE + YEAR_NUM)
93 | throw InvalidParamter(); // 没有该年的数据
94 |
95 | uint16_t num = sm_monthDay[year - YEAR_BASE];
96 |
97 | // 计算num的二进制位中“1”的个数
98 | num = ((num >> 1) & 0x5555) + (num & 0x5555);
99 | num = ((num >> 2) & 0x3333) + (num & 0x3333);
100 | num = ((num >> 4) & 0x0F0F) + (num & 0x0F0F);
101 | num = ((num >> 8) & 0x00FF) + (num & 0x00FF);
102 |
103 | int monthNum = 12 + (sm_leapMonth[year - YEAR_BASE] ? 1 : 0);
104 | return monthNum * 29 + num;
105 | }
106 |
107 | /*
108 | * 查询节气日期(返回的是公历日期)
109 | * @param year: 要查询的年份,有效取值范围1901~2050
110 | * @param index: 要查询的节气,有效取值范围1~24
111 | * @return: 返回该节气的日期(公历日期)
112 | * 如果参数year或index不在有效值范围内,则抛出异常ChineseCalendarDB::InvalidParamter
113 | */
114 | static int GetSolarTerm(int year, int index)
115 | {
116 | if (year < YEAR_BASE || year >= YEAR_BASE + YEAR_NUM)
117 | throw InvalidParamter(); // 没有该年的数据
118 |
119 | if (index < 1 || index > 24)
120 | throw InvalidParamter(); // 没有该年的数据
121 |
122 | --index; // 把取值范围转换为[0, 23]
123 | uint8_t data = sm_solarTerm[year - YEAR_BASE][index / 2];
124 | return (index % 2) ? ((data & 0x0F) + 15) : (data >> 4);
125 | }
126 |
127 | /*
128 | * 查询指定年份的农历年代和农历甲子 Add By Lihaifeng 2011-11-28
129 | * @param year: 要查询的年份,有效取值范围1901-2050
130 | * @return: 返回农历的年代和甲子
131 | * 如果参数year不在有效值范围内,则抛出异常ChineseCalendarDB::InvalidParamter
132 | */
133 | static std::pair GetEraAndYearOfLunar(int year)
134 | {
135 | if (year < YEAR_BASE || year >= YEAR_BASE + YEAR_NUM)
136 | throw InvalidParamter(); // 没有该年的数据
137 | static int era_1901=76;//设定起始年份的年代
138 | static int year_1901=38;//设定起始年份的甲子年份
139 | int diff_year=year-(YEAR_BASE-year_1901);
140 | int times=diff_year/60;
141 | int modes=diff_year%60;
142 | if (modes==0) {
143 | modes=60;
144 | }
145 | if (times==0) {
146 | return std::make_pair(era_1901, modes);
147 | } else {
148 | return std::make_pair(era_1901+(modes==60?times-1:times), modes);
149 | }
150 | }
151 | };
152 |
153 | #endif //CHINESE_CALENDAR_DB_H_INCLUDED
154 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/IDJCalendarUtil.mm:
--------------------------------------------------------------------------------
1 | //
2 | // IDJCalendarUtil.mm
3 | // 本文件使用了C++混编,所以扩展名为.mm
4 | //
5 | // Created by lihaifeng on 11-11-30, QQ:61673110.
6 | // Copyright (c) 2011年 www.idianjing.com. All rights reserved.
7 | //
8 |
9 | #import "IDJCalendarUtil.h"
10 | #import "SolarDate.h"
11 | #import "ChineseDate.h"
12 |
13 | @implementation IDJCalendarUtil
14 | + (NSDateComponents *)toSolarDateWithYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day {
15 | ChineseDate chineseDate=ChineseDate(_year, [IDJCalendarUtil monthFromMineToCppWithYear:_year month:_month], _day);
16 | SolarDate solarDate=chineseDate.ToSolarDate();
17 | NSDateComponents *dc=[[NSDateComponents alloc]init];
18 | dc.year=solarDate.GetYear();
19 | dc.month=solarDate.GetMonth();
20 | dc.day=solarDate.GetDay();
21 | return dc;
22 | }
23 |
24 | + (NSDateComponents *)toChineseDateWithYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day {
25 | SolarDate solarDate=SolarDate(_year, [_month intValue], _day);
26 | ChineseDate chineseDate;
27 | solarDate.ToChineseDate(chineseDate);
28 | NSDateComponents *dc=[[NSDateComponents alloc]init];
29 | dc.year=chineseDate.GetYear();
30 | dc.month=chineseDate.GetMonth();
31 | dc.day=chineseDate.GetDay();
32 | return dc;
33 | }
34 |
35 | + (int)weekDayWithSolarYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day {
36 | SolarDate solarDate=SolarDate(_year, [_month intValue], _day);
37 | return solarDate.ToWeek();
38 | }
39 |
40 | + (int)weekDayWithChineseYear:(NSUInteger)_year month:(NSString *)_month day:(NSUInteger)_day {
41 | NSDateComponents *dc=[IDJCalendarUtil toSolarDateWithYear:_year month:_month day:_day];
42 | return [IDJCalendarUtil weekDayWithSolarYear:dc.year month:[NSString stringWithFormat:@"%d", dc.month] day:dc.day];
43 | }
44 |
45 | + (NSUInteger)monthFromMineToCppWithYear:(NSUInteger)_year month:(NSString *)_month {
46 | int runMonth=ChineseCalendarDB::GetLeapMonth(_year);
47 | NSArray *array=[_month componentsSeparatedByString:@"-"];
48 | int month_=0;
49 | if ([[array objectAtIndex:0]isEqualToString:CHINESE_MONTH_LUNAR]) {
50 | month_=[[array objectAtIndex:1]intValue]+1;
51 | } else {
52 | if (runMonth!=0&&[[array objectAtIndex:1]intValue]>runMonth)
53 | month_=[[array objectAtIndex:1]intValue]+1;
54 | else
55 | month_=[[array objectAtIndex:1]intValue];
56 | }
57 | return month_;
58 | }
59 |
60 | + (NSString *)monthFromCppToMineWithYear:(NSUInteger)_year month:(NSUInteger)_month {
61 | int run=ChineseCalendarDB::GetLeapMonth(_year);
62 | if (run==0) {
63 | return [NSString stringWithFormat:@"%@-%d", CHINESE_MONTH_NORMAL, _month];
64 | } else {
65 | if (_month==run+1) {
66 | return [NSString stringWithFormat:@"%@-%d", CHINESE_MONTH_LUNAR, _month-1];
67 | } else if(_month<=run) {
68 | return [NSString stringWithFormat:@"%@-%d", CHINESE_MONTH_NORMAL, _month];
69 | } else {
70 | return [NSString stringWithFormat:@"%@-%d", CHINESE_MONTH_NORMAL, _month-1];
71 | }
72 | }
73 | }
74 |
75 | + (NSString *)animalWithJiazi:(NSUInteger)jiazi {
76 | NSString *animal=nil;
77 | switch (jiazi%12) {
78 | case 1:{
79 | animal=@"鼠";
80 | break;
81 | }
82 | case 2:{
83 | animal=@"牛";
84 | break;
85 | }
86 | case 3:{
87 | animal=@"虎";
88 | break;
89 | }
90 | case 4:{
91 | animal=@"兔";
92 | break;
93 | }
94 | case 5:{
95 | animal=@"龙";
96 | break;
97 | }
98 | case 6:{
99 | animal=@"蛇";
100 | break;
101 | }
102 | case 7:{
103 | animal=@"马";
104 | break;
105 | }
106 | case 8:{
107 | animal=@"羊";
108 | break;
109 | }
110 | case 9:{
111 | animal=@"猴";
112 | break;
113 | }
114 | case 10:{
115 | animal=@"鸡";
116 | break;
117 | }
118 | case 11:{
119 | animal=@"狗";
120 | break;
121 | }
122 | case 0:{
123 | animal=@"猪";
124 | break;
125 | }
126 | default:
127 | break;
128 | }
129 | return animal;
130 | }
131 |
132 | + (void)jiaziWithYear:(NSUInteger)_year outEra:(int *)era outJiazi:(int *)jiazi {
133 | std::pair p=ChineseCalendarDB::GetEraAndYearOfLunar(_year);
134 | *era=p.first;
135 | *jiazi=p.second;
136 | }
137 |
138 | + (NSMutableDictionary *)jieqiWithYear:(NSUInteger)_year {
139 | NSArray *arrayJieqi=[NSArray arrayWithObjects:@"小寒", @"大寒", @"立春", @"雨水", @"惊蛰", @"春分", @"清明", @"谷雨", @"立夏", @"小满", @"芒种", @"夏至", @"小暑", @"大暑", @"立秋", @"处暑", @"白露", @"秋分", @"寒露", @"霜降", @"立冬", @"小雪", @"大雪", @"冬至", nil];
140 | NSMutableDictionary * dic=[[NSMutableDictionary alloc]initWithCapacity:24];
141 | for (int i=1; i<=24; i++) {
142 | int day=ChineseCalendarDB::GetSolarTerm(_year, i);
143 | div_t dt=div(i, 2);
144 | NSDateComponents *dc=[IDJCalendarUtil toChineseDateWithYear:_year month:[NSString stringWithFormat:@"%d", dt.rem+dt.quot] day:day];
145 | NSString *month=[IDJCalendarUtil monthFromCppToMineWithYear:dc.year month:dc.month];
146 | [dic setObject:[arrayJieqi objectAtIndex:i-1] forKey:[NSString stringWithFormat:@"%@-%d", month, dc.day]];
147 | }
148 | return dic;
149 | }
150 |
151 | @end
152 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/solar_chinese_calendar/SolarDate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * SolarDate.h
3 | * @Author Tu Yongce
4 | * @Created 2008-12-13
5 | * @Modified 2008-12-13
6 | * @Version 0.1
7 | */
8 |
9 | #ifndef SOLAR_DATE_H_INCLUDED
10 | #define SOLAR_DATE_H_INCLUDED
11 |
12 | #ifdef _MSC_VER
13 | #pragma once
14 | #endif
15 |
16 | #include
17 |
18 | class ChineseDate; // 前置声明
19 |
20 | /*
21 | * 阳历日期类
22 | * @note: 能够表示从公元1年1月1日开始的任何一天
23 | */
24 | class SolarDate
25 | {
26 | private:
27 | int m_year; // 1~?
28 | int m_month; // 1~12
29 | int m_day; // 1~[28|29|30|31]
30 |
31 | static const int sm_monthDay[12]; // 平年中每一个月的天数
32 | static const int sm_yearDays[12]; // 平年中每一个月之前所有月的天数
33 |
34 | public:
35 | SolarDate();
36 | SolarDate(int year, int month, int day);
37 | //!! 使用编译器生成的拷贝构造函数、拷贝赋值操作符和析构函数
38 |
39 | int GetYear() const;
40 | int GetMonth() const;
41 | int GetDay() const;
42 |
43 | // 判断是否为有效日期
44 | bool IsValidDate() const;
45 | // 判断是否为闰年
46 | bool IsLeapYear() const;
47 |
48 | // 判断是否在指定日期之前
49 | bool IsPrior(const SolarDate &ref) const;
50 | // 判断是否为同一日期
51 | friend bool operator== (const SolarDate &lhs, const SolarDate &rhs);
52 | friend bool operator!= (const SolarDate &lhs, const SolarDate &rhs);
53 |
54 | // 计算某年的全年天数
55 | int GetYearDays() const;
56 | // 计算是该年中的第几天
57 | int YearDay() const;
58 | // 从该年的某天计算日期(如果无对应日期,则操作失败并返回false;否则返回true)
59 | bool FromYearDay(int days);
60 |
61 | // 转换为星期,返回0~6,分别代表星期日~星期六
62 | int ToWeek() const;
63 |
64 | // 计算和指定日期相差的天数
65 | // 如果this->IsPrior(ref)为真,则返回负数;否则返回正数
66 | int Diff(const SolarDate &ref) const;
67 |
68 | // 向前或者向后调整指定天数(注意:不能调整到公元1年1月1日之前)
69 | // 如果days大于0,则向前调整(未来);否则向后调整(过去)
70 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
71 | bool AdjustDays(int days);
72 |
73 | // 转换为农历(把公元1901年2月19日到公元2051年2月29日期间的公历日期转换为农历日期)
74 | // 如果转换成功,返回true;否则返回false
75 | bool ToChineseDate(ChineseDate &date) const;
76 |
77 | private:
78 | // 计算某年之前的闰年数
79 | static int GetLeapYears(int year);
80 |
81 | // 计算*this和ref之间相差的天数,要求!IsPrior(ref)为真
82 | int DoDiff(const SolarDate &ref) const;
83 |
84 | // 向前(未来)调整指定天数(始终返回true)
85 | bool DoAdjustForward(int days);
86 |
87 | // 向后(过去)调整指定天数(注意:不能调整到公元1年1月1日之前)
88 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
89 | bool DoAdjustBackward(int days);
90 | };
91 |
92 | inline SolarDate::SolarDate(): m_year(1), m_month(1), m_day(1)
93 | {
94 | }
95 |
96 | inline SolarDate::SolarDate(int year, int month, int day): m_year(year), m_month(month), m_day(day)
97 | {
98 | //assert(IsValidDate()); // 当ChineseDate对象内部数据变化时确保仍是正确的日期
99 | }
100 |
101 | inline int SolarDate::GetYear() const
102 | {
103 | return m_year;
104 | }
105 |
106 | inline int SolarDate::GetMonth() const
107 | {
108 | return m_month;
109 | }
110 |
111 | inline int SolarDate::GetDay() const
112 | {
113 | return m_day;
114 | }
115 |
116 | // 判断是否为闰年
117 | inline bool SolarDate::IsLeapYear() const
118 | {
119 | return (!(m_year % 4) && (m_year % 100)) || !(m_year % 400);
120 | }
121 |
122 | // 判断是否在指定日期之前
123 | inline bool SolarDate::IsPrior(const SolarDate &ref) const
124 | {
125 | return m_year < ref.m_year ||
126 | ((m_year == ref.m_year && (m_month < ref.m_month || (m_month == ref.m_month && m_day < ref.m_day))));
127 | }
128 |
129 | // 判断是否为同一日期
130 | inline bool operator== (const SolarDate &lhs, const SolarDate &rhs)
131 | {
132 | return lhs.m_year == rhs.m_year && lhs.m_month == rhs.m_month && lhs.m_day == rhs.m_day;
133 | }
134 |
135 | inline bool operator!= (const SolarDate &lhs, const SolarDate &rhs)
136 | {
137 | return !(lhs == rhs);
138 | }
139 |
140 | // 计算某年的全年天数
141 | inline int SolarDate::GetYearDays() const
142 | {
143 | return IsLeapYear() ? 366 : 365;
144 | }
145 |
146 | // 计算是该年中的第几天
147 | inline int SolarDate::YearDay() const
148 | {
149 | size_t days = sm_yearDays[m_month - 1] + m_day;
150 | if (m_month > 2 && IsLeapYear())
151 | ++days;
152 | return (int)days;
153 | }
154 |
155 | // 计算某年之前的闰年数
156 | inline int SolarDate::GetLeapYears(int year)
157 | {
158 | if (year == 0)
159 | return 0;
160 |
161 | int y = year - 1;
162 | return y / 4 - y / 100 + y / 400;
163 | }
164 |
165 | // 转换为星期,返回0~6,分别代表星期日~星期六
166 | inline int SolarDate::ToWeek() const
167 | {
168 | // 公式:W = [Y-1] + [(Y-1)/4] - [(Y-1)/100] + [(Y-1)/400] + D
169 | // Y是年份数,D是这一天在这一年中是第几天。
170 | // 算出来的W除以7,余数是几就是星期几。如果余数是0,则为星期日。
171 | // 注:365 = 52 * 7 + 1,公元元年1月1日为星期一
172 | return (m_year - 1 + GetLeapYears(m_year) + YearDay()) % 7;
173 | }
174 |
175 | // 计算和指定日期相差的天数
176 | // 如果this->IsPrior(ref)为真,则返回负数;否则返回正数
177 | inline int SolarDate::Diff(const SolarDate &ref) const
178 | {
179 | return this->IsPrior(ref) ? -ref.DoDiff(*this) : this->DoDiff(ref);
180 | }
181 |
182 | // 向前或者向后调整指定天数(注意:不能调整到公元1年1月1日之前)
183 | // 如果days大于0,则向前调整(未来);否则向后调整(过去)
184 | // 如果调整成功,则返回true;否则返回false(此时*this在调用前后不会发生改变)
185 | inline bool SolarDate::AdjustDays(int days)
186 | {
187 | if (days > 0)
188 | return DoAdjustForward(days);
189 | else if (days < 0)
190 | return DoAdjustBackward(-days);
191 |
192 | assert(IsValidDate()); // 当ChineseDate对象内部数据变化时确保仍是正确的日期
193 | return true;
194 | }
195 |
196 | #endif // SOLAR_DATE_H_INCLUDED
197 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/GYZCustomCalendarPickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // GYZCustomCalendarPickerView.m
3 | // GYZCalendarPicker
4 | //
5 | // Created by GYZ on 16/6/22.
6 | // Copyright © 2016年 GYZ. All rights reserved.
7 | //
8 |
9 | #import "GYZCustomCalendarPickerView.h"
10 |
11 | @interface GYZCustomCalendarPickerView (Private)
12 | - (void)_setYears;
13 | - (void)_setMonthsInYear:(NSUInteger)_year;
14 | - (void)_setDaysInMonth:(NSString *)_month year:(NSUInteger)_year;
15 | - (void)changeMonths;
16 | - (void)changeDays;
17 | @end
18 |
19 | @implementation GYZCustomCalendarPickerView{
20 | UIPickerView *_pickerView;
21 | UILabel *_titleLabel;
22 | UIView *_datePickerView;//datePicker背景
23 | UIButton *_calendarBtn;
24 |
25 | NSMutableArray *years;//第一列的数据容器
26 | NSMutableArray *months;//第二列的数据容器
27 | NSMutableArray *days;//第三列的数据容器
28 | IDJCalendar *cal;//日期类
29 | }
30 |
31 | - (instancetype)initWithTitle:(NSString *)title
32 | {
33 | self = [super initWithFrame:CGRectZero];
34 |
35 | if (self)
36 | {
37 |
38 | self.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
39 | self.backgroundColor = kColor(0, 0, 0, 0.4);
40 | self.userInteractionEnabled = YES;
41 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
42 | [self addGestureRecognizer:tapGesture];
43 |
44 | [self createView:title];
45 |
46 | }
47 |
48 | return self;
49 | }
50 | -(void)createView:(NSString *)title{
51 | //生成日期选择器
52 | _datePickerView=[[UIView alloc] initWithFrame:CGRectMake(0,HEIGHT(self)-306,WIDTH(self),305)];
53 | _datePickerView.backgroundColor=[UIColor whiteColor];
54 | _datePickerView.userInteractionEnabled = YES;
55 | [self addSubview:_datePickerView];
56 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerViewClick)];
57 | [_datePickerView addGestureRecognizer:tapGesture];
58 |
59 | UIButton *dateCancleButton=[[UIButton alloc] initWithFrame:CGRectMake(PADDING,0,44,44)];
60 | [dateCancleButton addTarget:self action:@selector(dateCancleClick) forControlEvents:UIControlEventTouchUpInside];
61 | [dateCancleButton setTitle:@"取消" forState:UIControlStateNormal];
62 | [dateCancleButton.titleLabel setFont:k15Font];
63 | [dateCancleButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
64 | // [dateCancleButton setImage:IMAGE(@"icon_x_cancle") forState:UIControlStateNormal];
65 | // [dateCancleButton setImageEdgeInsets:UIEdgeInsetsMake(12, 12, 12,12)];
66 | [_datePickerView addSubview:dateCancleButton];
67 |
68 | UIButton *dateConfirmButton=[[UIButton alloc] initWithFrame:CGRectMake(WIDTH(self)-44 - PADDING,Y(dateCancleButton),WIDTH(dateCancleButton),HEIGHT(dateCancleButton))];
69 | [dateConfirmButton addTarget:self action:@selector(dateConfirmClick) forControlEvents:UIControlEventTouchUpInside];
70 | [dateConfirmButton.titleLabel setFont:k15Font];
71 | [dateConfirmButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
72 | [dateConfirmButton setTitle:@"确定" forState:UIControlStateNormal];
73 | [_datePickerView addSubview:dateConfirmButton];
74 |
75 | _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(MaxX(dateCancleButton), Y(dateCancleButton), kScreenWidth - MaxX(dateCancleButton)*2, HEIGHT(dateCancleButton))];
76 | _titleLabel.font = k12Font;
77 | _titleLabel.text = title;
78 | _titleLabel.textColor = [UIColor grayColor];
79 | _titleLabel.textAlignment = NSTextAlignmentCenter;
80 | [_datePickerView addSubview:_titleLabel];
81 |
82 | UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, MaxY(dateCancleButton), WIDTH(self), kLineHeight)];
83 | lineView.backgroundColor = UIColorFromRGB(0xe5e5e5);
84 | [_datePickerView addSubview:lineView];
85 |
86 | _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, MaxY(lineView) , WIDTH(lineView), 216)];
87 | _pickerView.backgroundColor = [UIColor whiteColor];
88 | [_pickerView setShowsSelectionIndicator:YES];
89 | [_pickerView setDelegate:self];
90 | [_pickerView setDataSource:self];
91 | [_datePickerView addSubview:_pickerView];
92 |
93 | UIView *lineView1 = [[UIView alloc]initWithFrame:CGRectMake(0, MaxY(_pickerView), WIDTH(lineView), kLineHeight)];
94 | lineView1.backgroundColor = UIColorFromRGB(0xe5e5e5);
95 | [_datePickerView addSubview:lineView1];
96 |
97 | _calendarBtn = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH(self)*0.75, MaxY(lineView1), WIDTH(self)*0.25, HEIGHT(dateCancleButton))];
98 | [_calendarBtn setTitle:@"农历" forState:UIControlStateNormal];
99 | [_calendarBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
100 | [_calendarBtn setTitleColor:[UIColor greenColor] forState:UIControlStateSelected];
101 | [_calendarBtn setImage:IMAGE(@"icon_xyk") forState:UIControlStateNormal];
102 | [_calendarBtn setImage:IMAGE(@"icon_xyk_selected") forState:UIControlStateSelected];
103 | [_calendarBtn.titleLabel setFont:k15Font];
104 | [_datePickerView addSubview:_calendarBtn];
105 |
106 | [_calendarBtn addTarget:self action:@selector(selectCalendarClick:) forControlEvents:UIControlEventTouchUpInside];
107 | }
108 |
109 | -(void)setCalendarType:(CalendarType)calendarType{
110 | _calendarType = calendarType;
111 |
112 | if (calendarType == GregorianCalendar) {
113 | cal=[[IDJCalendar alloc]initWithYearStart:YEAR_START end:YEAR_END];
114 | } else if (calendarType == ChineseCalendar){
115 | cal=[[IDJChineseCalendar alloc]initWithYearStart:YEAR_START end:YEAR_END];
116 | }
117 | [self _setYears];
118 | [self _setMonthsInYear:[cal.year intValue]];
119 | [self _setDaysInMonth:cal.month year:[cal.year intValue]];
120 |
121 | [_pickerView reloadAllComponents];
122 |
123 | if (calendarType == GregorianCalendar) {
124 | [_pickerView selectRow:[years indexOfObject:cal.year] inComponent:0 animated:YES];
125 |
126 | } else if (calendarType == ChineseCalendar) {
127 |
128 | [_pickerView selectRow:[years indexOfObject:[NSString stringWithFormat:@"%@-%@-%@", cal.era, ((IDJChineseCalendar *)cal).jiazi, cal.year]] inComponent:0 animated:YES];
129 | }
130 | [_pickerView selectRow:[months indexOfObject:cal.month] inComponent:1 animated:YES];
131 | [_pickerView selectRow:[days indexOfObject:cal.day] inComponent:2 animated:YES];
132 | }
133 | #pragma mark - pickerview
134 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
135 | {
136 |
137 | return 3;
138 | }
139 |
140 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
141 | {
142 |
143 | switch (component) {
144 | case 0:
145 | return years.count;
146 | break;
147 | case 1:
148 | return months.count;
149 | break;
150 | case 2:
151 | return days.count;
152 | break;
153 | default:
154 | return 0;
155 | break;
156 | }
157 |
158 | }
159 | -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
160 | {
161 | UILabel *mycom1 = [[UILabel alloc] init];
162 | mycom1.textAlignment = NSTextAlignmentCenter;
163 | mycom1.backgroundColor = [UIColor clearColor];
164 | // mycom1.frame = CGRectMake(0, 0, 90, 50);
165 | [mycom1 setFont:[UIFont boldSystemFontOfSize:18]];
166 | switch (component) {
167 | case 0:{
168 | NSString *str=[years objectAtIndex:row];
169 | if (self.calendarType == ChineseCalendar) {
170 | NSArray *array=[str componentsSeparatedByString:@"-"];
171 | str=[NSString stringWithFormat:@"%@/%@", [((IDJChineseCalendar *)cal).chineseYears objectAtIndex:[[array objectAtIndex:1]intValue]-1], [array objectAtIndex:2]];
172 | }
173 | mycom1.text=[NSString stringWithFormat:@"%@", str];
174 | break;
175 | }
176 | case 1:{
177 | NSString *str=[NSString stringWithFormat:@"%@", [months objectAtIndex:row]];
178 | if (self.calendarType == ChineseCalendar) {
179 | NSArray *array=[str componentsSeparatedByString:@"-"];
180 | if ([[array objectAtIndex:0]isEqualToString:@"a"]) {
181 | mycom1.text=[((IDJChineseCalendar *)cal).chineseMonths objectAtIndex:[[array objectAtIndex:1]intValue]-1];
182 | } else {
183 | mycom1.text=[NSString stringWithFormat:@"%@%@", @"闰", [((IDJChineseCalendar *)cal).chineseMonths objectAtIndex:[[array objectAtIndex:1]intValue]-1]];
184 | }
185 | } else {
186 | mycom1.text=[NSString stringWithFormat:@"%@%@", str, @"月"];
187 | }
188 | break;
189 | }
190 | case 2:{
191 | if (self.calendarType == GregorianCalendar) {
192 | int day=[[days objectAtIndex:row]intValue];
193 | int weekday=[IDJCalendarUtil weekDayWithSolarYear:[cal.year intValue] month:cal.month day:day];
194 | mycom1.text=[NSString stringWithFormat:@"%d %@", day, [cal.weekdays objectAtIndex:weekday]];
195 | } else {
196 | NSString *jieqi=[[IDJCalendarUtil jieqiWithYear:[cal.year intValue]]objectForKey:[NSString stringWithFormat:@"%@-%d", cal.month, [[days objectAtIndex:row]intValue]]];
197 | if (!jieqi) {
198 | mycom1.text=[NSString stringWithFormat:@"%@", [((IDJChineseCalendar *)cal).chineseDays objectAtIndex:[[days objectAtIndex:row]intValue]-1]];
199 | } else {
200 | //NSLog(@"%@-%d-%@", cal.month, [[days objectAtIndex:cell]intValue], jieqi);
201 | mycom1.text=[NSString stringWithFormat:@"%@", jieqi];
202 | }
203 | }
204 | break;
205 | }
206 | default:
207 | break;
208 | }
209 | return mycom1;
210 | }
211 | -(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
212 | {
213 | switch (component) {
214 | case 0:
215 | return 90;
216 | break;
217 | case 1:
218 | return 50;
219 | break;
220 | case 2:
221 | return 70;
222 | break;
223 |
224 | default:
225 | return 90;
226 | break;
227 | }
228 | }
229 |
230 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
231 | {
232 | switch (component) {
233 | case 0:{
234 | NSString *str=[years objectAtIndex:row];
235 | if (self.calendarType == ChineseCalendar) {
236 | NSArray *array=[str componentsSeparatedByString:@"-"];
237 | str=[array objectAtIndex:2];
238 | NSString *pYear=[cal.year copy];
239 | cal.era=[array objectAtIndex:0];
240 | ((IDJChineseCalendar *)cal).jiazi=[array objectAtIndex:1];
241 | cal.year=str;
242 | //因为用户可能从2011年滚动,最后放手的时候,滚回了2011年,所以需要判断与上一次选中的年份是否不同,再联动月份的滚轮
243 | if (![pYear isEqualToString:cal.year]) {
244 | [self changeMonths];
245 | }
246 | } else {
247 | cal.year=str;
248 | //因为公历的每年都是12个月,所以当年份变化的时候,只需要后面的天数联动
249 | [self changeDays];
250 | }
251 | break;
252 | }
253 | case 1:{
254 | NSString *pMonth=[cal.month copy];
255 | NSString *str=[months objectAtIndex:row];
256 | cal.month=str;
257 | if (![pMonth isEqualToString:cal.month]) {
258 | //联动天数的滚轮
259 | [self changeDays];
260 | }
261 | break;
262 | }
263 | case 2:{
264 | cal.day=[days objectAtIndex:row];
265 | break;
266 | }
267 | default:
268 | break;
269 | }
270 |
271 | if (self.calendarType == GregorianCalendar) {
272 | cal.weekday=[NSString stringWithFormat:@"%d", [IDJCalendarUtil weekDayWithSolarYear:[cal.year intValue] month:cal.month day:[cal.day intValue]]];
273 | } else {
274 | cal.weekday=[NSString stringWithFormat:@"%d", [IDJCalendarUtil weekDayWithChineseYear:[cal.year intValue] month:cal.month day:[cal.day intValue]]];
275 | ((IDJChineseCalendar *)cal).animal=[IDJCalendarUtil animalWithJiazi:[((IDJChineseCalendar *)cal).jiazi intValue]];
276 | }
277 | }
278 |
279 | #pragma mark -Calendar Data Handle-
280 | //动态改变农历月份列表,因为公历的月份只有12个月,不需要跟随年份滚轮联动
281 | - (void)changeMonths{
282 | if (self.calendarType == ChineseCalendar) {
283 | [self _setMonthsInYear:[cal.year intValue]];
284 | [_pickerView reloadComponent:1];
285 | int cell=[months indexOfObject:cal.month];
286 | if (cell==NSNotFound) {
287 | cell=0;
288 | cal.month=[months objectAtIndex:0];
289 | }
290 | [_pickerView selectRow:cell inComponent:1 animated:YES];
291 | //月份改变之后,天数进行联动
292 | [self changeDays];
293 | }
294 | }
295 |
296 | //动态改变日期列表
297 | - (void)changeDays{
298 | [self _setDaysInMonth:cal.month year:[cal.year intValue]];
299 | [_pickerView reloadComponent:2];
300 | int cell=[days indexOfObject:cal.day];
301 | //假如用户上次选择的是1月31日,当月份变为2月的时候,第三列的滚轮不可能再选中31日,我们设置默认的值为第一个。
302 | if (cell==NSNotFound) {
303 | cell=0;
304 | cal.day=[days objectAtIndex:0];
305 | }
306 | [_pickerView selectRow:cell inComponent:2 animated:YES];
307 | }
308 |
309 |
310 | #pragma mark -Fill init Data-
311 | //填充年份
312 | - (void)_setYears {
313 | years = [[NSMutableArray alloc]init];
314 | years=[cal yearsInRange];
315 | }
316 |
317 | //填充月份
318 | - (void)_setMonthsInYear:(NSUInteger)_year {
319 | months = [[NSMutableArray alloc]init];
320 | months=[cal monthsInYear:_year];
321 | }
322 |
323 | //填充天数
324 | - (void)_setDaysInMonth:(NSString *)_month year:(NSUInteger)_year {
325 | days = [[NSMutableArray alloc]init];
326 | days=[cal daysInMonth:_month year:_year];
327 | }
328 |
329 | - (void)selectCalendarClick:(UIButton *)sender {
330 |
331 | sender.selected = !sender.selected;
332 | if (sender.selected) {
333 | self.calendarType = ChineseCalendar;
334 | } else {
335 | self.calendarType = GregorianCalendar;
336 | }
337 | }
338 |
339 |
340 | - (void)show {
341 | UIWindow *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
342 | [window addSubview:self];
343 | [self addAnimation];
344 | }
345 |
346 | - (void)hide {
347 | [self removeAnimation];
348 | }
349 |
350 | - (void)addAnimation {
351 | [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
352 | [_datePickerView setFrame:CGRectMake(0, self.frame.size.height - _datePickerView.frame.size.height, kScreenWidth, _datePickerView.frame.size.height)];
353 | // self.alpha = 0.7;
354 | } completion:^(BOOL finished) {
355 | }];
356 | }
357 |
358 | - (void)removeAnimation {
359 | [UIView animateWithDuration:0.2 animations:^{
360 | [_datePickerView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, 0)];
361 | self.alpha = 0;
362 | } completion:^(BOOL finished) {
363 | if (finished) {
364 | [self removeFromSuperview];
365 | }
366 | }];
367 | }
368 |
369 | //确定选择
370 | -(void)dateConfirmClick{
371 |
372 | if (self.delegate) {
373 | if ([self.delegate respondsToSelector:@selector(notifyNewCalendar:)] == YES) {
374 | [self.delegate notifyNewCalendar:cal];
375 | }
376 | }
377 |
378 | [self removeAnimation];
379 | }
380 | //取消选择
381 | -(void)dateCancleClick{
382 | [self removeAnimation];
383 | }
384 |
385 | -(void)pickerViewClick{
386 |
387 | }
388 |
389 | @end
390 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/CustomCalendar/solar_chinese_calendar/ChineseCalendarDB.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * ChineseCalendarDB.cpp
3 | * @Author Tu Yongce
4 | * @Created 2008-12-13
5 | * @Modified 2008-12-13
6 | * @Version 0.1
7 | */
8 |
9 | #include "ChineseCalendarDB.h"
10 |
11 | // 数组中每一个元素存放1901~2050期间每一年的闰月月份,取值范围0~12(0表示该年没有闰月)
12 | // (注:其实每个字节可以存放2年的数据,可以节约75个字节,但运行起来会慢点)
13 | const uint8_t ChineseCalendarDB::sm_leapMonth[YEAR_NUM] = {
14 | 0x00, 0x00, 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, //1910
15 | 0x06, 0x00, 0x00, 0x05, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, //1920
16 | 0x00, 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x06, //1930
17 | 0x00, 0x00, 0x05, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, //1940
18 | 0x06, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, //1950
19 | 0x00, 0x05, 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x06, //1960
20 | 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, //1970
21 | 0x05, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x06, 0x00, //1980
22 | 0x00, 0x04, 0x00, 0x0A, 0x00, 0x00, 0x06, 0x00, 0x00, 0x05, //1990
23 | 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00, 0x00, //2000
24 | 0x04, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x05, 0x00, //2010
25 | 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x06, 0x00, 0x00, 0x04, //2020
26 | 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x05, 0x00, 0x00, //2030
27 | 0x03, 0x00, 0x0B, 0x00, 0x00, 0x06, 0x00, 0x00, 0x05, 0x00, //2040
28 | 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x05, 0x00, 0x00, 0x03, //2050
29 | };
30 |
31 | // 数组中每一个元素存放1901~2050期间每一年的12个月或13个月(有闰月)的月天数
32 | // 数组元素的低12位或13位(有闰月)分别对应着这12个月或13个月(有闰月),最低位对应着最小月(1月)
33 | // 如果月份对应的位为1则表示该月有30天,否则表示该月有29天。
34 | // (注:农历中每个月的天数只有29天或者30天)
35 | const uint16_t ChineseCalendarDB::sm_monthDay[YEAR_NUM] = {
36 | 0x0752, 0x0EA5, 0x164A, 0x064B, 0x0A9B, 0x1556, 0x056A, 0x0B59, 0x1752, 0x0752, //1910
37 | 0x1B25, 0x0B25, 0x0A4B, 0x12AB, 0x0AAD, 0x056A, 0x0B69, 0x0DA9, 0x1D92, 0x0D92, //1920
38 | 0x0D25, 0x1A4D, 0x0A56, 0x02B6, 0x15B5, 0x06D4, 0x0EA9, 0x1E92, 0x0E92, 0x0D26, //1930
39 | 0x052B, 0x0A57, 0x12B6, 0x0B5A, 0x06D4, 0x0EC9, 0x0749, 0x1693, 0x0A93, 0x052B, //1940
40 | 0x0A5B, 0x0AAD, 0x056A, 0x1B55, 0x0BA4, 0x0B49, 0x1A93, 0x0A95, 0x152D, 0x0536, //1950
41 | 0x0AAD, 0x15AA, 0x05B2, 0x0DA5, 0x1D4A, 0x0D4A, 0x0A95, 0x0A97, 0x0556, 0x0AB5, //1960
42 | 0x0AD5, 0x06D2, 0x0EA5, 0x0EA5, 0x064A, 0x0C97, 0x0A9B, 0x155A, 0x056A, 0x0B69, //1970
43 | 0x1752, 0x0B52, 0x0B25, 0x164B, 0x0A4B, 0x14AB, 0x02AD, 0x056D, 0x0B69, 0x0DA9, //1980
44 | 0x0D92, 0x1D25, 0x0D25, 0x1A4D, 0x0A56, 0x02B6, 0x05B5, 0x06D5, 0x0EC9, 0x1E92, //1990
45 | 0x0E92, 0x0D26, 0x0A56, 0x0A57, 0x14D6, 0x035A, 0x06D5, 0x16C9, 0x0749, 0x0693, //2000
46 | 0x152B, 0x052B, 0x0A5B, 0x155A, 0x056A, 0x1B55, 0x0BA4, 0x0B49, 0x1A93, 0x0A95, //2010
47 | 0x052D, 0x0AAD, 0x0AAD, 0x15AA, 0x05D2, 0x0DA5, 0x1D4A, 0x0D4A, 0x0C95, 0x152E, //2020
48 | 0x0556, 0x0AB5, 0x15B2, 0x06D2, 0x0EA9, 0x0725, 0x064B, 0x0C97, 0x0CAB, 0x055A, //2030
49 | 0x0AD6, 0x0B69, 0x1752, 0x0B52, 0x0B25, 0x1A4B, 0x0A4B, 0x04AB, 0x055B, 0x05AD, //2040
50 | 0x0B6A, 0x1B52, 0x0D92, 0x1D25, 0x0D25, 0x0A55, 0x14AD, 0x04B6, 0x05B5, 0x0DAA, //2050
51 | };
52 |
53 | // 二十四节气数据(注:这里是公历日期)
54 | // 1901~2050期间的二十四节气的公历日期满足如下规律:
55 | // 1月 小寒(5~7) 大寒(19~21)
56 | // 2月 立春(3~5) 雨水(18~20)
57 | // 3月 惊蛰(5~7) 春分(20~22)
58 | // 4月 清明(4~6) 谷雨(19~21)
59 | // 5月 立夏(5~7) 小满(20~22)
60 | // 6月 芒种(5~7) 夏至(20~22)
61 | // 7月 小暑(6~8) 大暑(22~24)
62 | // 8月 立秋(7~9) 处暑(22~24)
63 | // 9月 白露(7~9) 秋分(22~24)
64 | // 10月 寒露(7~9) 霜降(23~24)
65 | // 11月 立冬(7~8) 小雪(21~23)
66 | // 12月 大雪(6~8) 冬至(21~23)
67 | // 可以看出,如果把每月的第二个节气的日期减去15将得到与第一个节气相近的日期,且都在3~9范围内
68 | // 因此,可以使用一个字节来保存每个月两个节气的日期
69 | // 另外,也可以看出,每个节气都在3天的波动范围内,因此还可以近一步把四个节气压缩在一个字节内
70 | // 但那样做使用起来太复杂,因此这里还是把两个节气保存在一个字节中
71 | //
72 | // 数据格式:每个字节的高四位存放每个月的第一个节气的日期,低四位存放该月的第二个
73 | // 节气日期减去15之后的日期
74 | const uint8_t ChineseCalendarDB::sm_solarTerm[YEAR_NUM][12] = {
75 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1901
76 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x77, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1902
77 | 0x66, 0x55, 0x77, 0x66, 0x77, 0x77, 0x89, 0x99, 0x99, 0x99, 0x88, 0x88, //1903
78 | 0x76, 0x55, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x88, 0x77, //1904
79 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1905
80 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1906
81 | 0x66, 0x55, 0x77, 0x66, 0x77, 0x77, 0x89, 0x99, 0x99, 0x99, 0x88, 0x88, //1907
82 | 0x76, 0x55, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1908
83 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1909
84 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1910
85 | 0x66, 0x55, 0x77, 0x66, 0x77, 0x77, 0x89, 0x99, 0x99, 0x99, 0x88, 0x88, //1911
86 | 0x76, 0x55, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1912
87 | 0x65, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1913
88 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1914
89 | 0x66, 0x55, 0x67, 0x66, 0x67, 0x77, 0x89, 0x89, 0x99, 0x99, 0x88, 0x88, //1915
90 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1916
91 | 0x65, 0x44, 0x66, 0x56, 0x66, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x77, //1917
92 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x87, //1918
93 | 0x66, 0x55, 0x67, 0x66, 0x67, 0x77, 0x89, 0x89, 0x99, 0x99, 0x88, 0x88, //1919
94 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1920
95 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x77, //1921
96 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x87, //1922
97 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x77, 0x89, 0x89, 0x99, 0x99, 0x88, 0x88, //1923
98 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1924
99 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x77, //1925
100 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1926
101 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x77, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1927
102 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1928
103 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1929
104 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1930
105 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x77, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1931
106 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1932
107 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1933
108 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1934
109 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1935
110 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1936
111 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1937
112 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1938
113 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1939
114 | 0x66, 0x55, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1940
115 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1941
116 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1942
117 | 0x66, 0x54, 0x66, 0x66, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1943
118 | 0x66, 0x55, 0x66, 0x55, 0x56, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1944
119 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1945
120 | 0x65, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x87, //1946
121 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1947
122 | 0x66, 0x55, 0x56, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //1948
123 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x89, 0x88, 0x89, 0x87, 0x77, //1949
124 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x87, //1950
125 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x89, 0x89, 0x89, 0x99, 0x88, 0x88, //1951
126 | 0x66, 0x55, 0x56, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //1952
127 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1953
128 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x88, 0x89, 0x88, 0x98, 0x88, 0x77, //1954
129 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1955
130 | 0x66, 0x55, 0x55, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //1956
131 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1957
132 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1958
133 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1959
134 | 0x66, 0x54, 0x55, 0x55, 0x56, 0x66, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1960
135 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1961
136 | 0x66, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1962
137 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1963
138 | 0x66, 0x54, 0x55, 0x55, 0x56, 0x66, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1964
139 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1965
140 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1966
141 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1967
142 | 0x66, 0x54, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1968
143 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1969
144 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1970
145 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x89, 0x99, 0x88, 0x87, //1971
146 | 0x66, 0x54, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1972
147 | 0x55, 0x45, 0x66, 0x55, 0x56, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1973
148 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1974
149 | 0x66, 0x44, 0x66, 0x56, 0x67, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x87, //1975
150 | 0x66, 0x54, 0x55, 0x45, 0x56, 0x56, 0x78, 0x79, 0x78, 0x88, 0x77, 0x77, //1976
151 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //1977
152 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x88, 0x77, //1978
153 | 0x66, 0x44, 0x66, 0x56, 0x66, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x87, //1979
154 | 0x66, 0x54, 0x55, 0x45, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1980
155 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x87, 0x77, //1981
156 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1982
157 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x88, 0x89, 0x88, 0x99, 0x88, 0x87, //1983
158 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x77, //1984
159 | 0x55, 0x44, 0x56, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //1985
160 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1986
161 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x89, 0x88, 0x99, 0x88, 0x77, //1987
162 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //1988
163 | 0x55, 0x44, 0x55, 0x55, 0x56, 0x66, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1989
164 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //1990
165 | 0x65, 0x44, 0x66, 0x55, 0x76, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1991
166 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //1992
167 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x66, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1993
168 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1994
169 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x86, 0x88, 0x99, 0x88, 0x77, //1995
170 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //1996
171 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //1997
172 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //1998
173 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //1999
174 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //2000
175 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2001
176 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //2002
177 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //2003
178 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //2004
179 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2005
180 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2006
181 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x99, 0x88, 0x77, //2007
182 | 0x66, 0x44, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x77, 0x88, 0x77, 0x76, //2008
183 | 0x55, 0x43, 0x55, 0x45, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2009
184 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2010
185 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x88, 0x77, //2011
186 | 0x66, 0x44, 0x55, 0x45, 0x55, 0x56, 0x77, 0x78, 0x77, 0x88, 0x77, 0x76, //2012
187 | 0x55, 0x43, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x77, //2013
188 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2014
189 | 0x65, 0x44, 0x66, 0x55, 0x66, 0x67, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //2015
190 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x77, 0x78, 0x77, 0x88, 0x77, 0x76, //2016
191 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x77, //2017
192 | 0x55, 0x44, 0x56, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2018
193 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //2019
194 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x76, //2020
195 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //2021
196 | 0x55, 0x44, 0x55, 0x55, 0x56, 0x66, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2022
197 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x89, 0x87, 0x77, //2023
198 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x66, //2024
199 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //2025
200 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2026
201 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //2027
202 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x66, //2028
203 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //2029
204 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2030
205 | 0x55, 0x44, 0x66, 0x55, 0x66, 0x66, 0x78, 0x88, 0x88, 0x88, 0x77, 0x77, //2031
206 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x66, //2032
207 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x76, //2033
208 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x88, 0x78, 0x88, 0x77, 0x77, //2034
209 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2035
210 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x66, //2036
211 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x76, //2037
212 | 0x55, 0x43, 0x55, 0x55, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2038
213 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2039
214 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x66, //2040
215 | 0x55, 0x33, 0x55, 0x45, 0x55, 0x56, 0x77, 0x78, 0x77, 0x88, 0x77, 0x76, //2041
216 | 0x55, 0x43, 0x55, 0x45, 0x56, 0x56, 0x78, 0x78, 0x78, 0x88, 0x77, 0x77, //2042
217 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2043
218 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x56, 0x67, 0x77, 0x77, 0x78, 0x77, 0x66, //2044
219 | 0x55, 0x33, 0x55, 0x44, 0x55, 0x56, 0x77, 0x78, 0x77, 0x88, 0x77, 0x76, //2045
220 | 0x55, 0x43, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x78, 0x88, 0x77, 0x77, //2046
221 | 0x55, 0x44, 0x66, 0x55, 0x56, 0x66, 0x78, 0x78, 0x88, 0x88, 0x77, 0x77, //2047
222 | 0x65, 0x44, 0x55, 0x44, 0x55, 0x55, 0x67, 0x77, 0x77, 0x78, 0x76, 0x66, //2048
223 | 0x54, 0x33, 0x55, 0x55, 0x55, 0x56, 0x67, 0x77, 0x77, 0x88, 0x77, 0x76, //2049
224 | 0x55, 0x33, 0x55, 0x45, 0x56, 0x56, 0x77, 0x78, 0x88, 0x88, 0x77, 0x77, //2050
225 | };
226 |
--------------------------------------------------------------------------------
/GYZCalendarPicker/GYZCalendarPicker.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 043816481D1A1EBE00D6F1E4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 043816471D1A1EBE00D6F1E4 /* main.m */; };
11 | 0438164B1D1A1EBE00D6F1E4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0438164A1D1A1EBE00D6F1E4 /* AppDelegate.m */; };
12 | 0438164E1D1A1EBE00D6F1E4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0438164D1D1A1EBE00D6F1E4 /* ViewController.m */; };
13 | 043816511D1A1EBE00D6F1E4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0438164F1D1A1EBE00D6F1E4 /* Main.storyboard */; };
14 | 043816531D1A1EBE00D6F1E4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 043816521D1A1EBE00D6F1E4 /* Assets.xcassets */; };
15 | 043816561D1A1EBE00D6F1E4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 043816541D1A1EBE00D6F1E4 /* LaunchScreen.storyboard */; };
16 | 043816611D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 043816601D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.m */; };
17 | 0438166C1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0438166B1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.m */; };
18 | 043816891D1A1F3D00D6F1E4 /* IDJCalendar.m in Sources */ = {isa = PBXBuildFile; fileRef = 0438167B1D1A1F3D00D6F1E4 /* IDJCalendar.m */; };
19 | 0438168A1D1A1F3D00D6F1E4 /* IDJCalendarUtil.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0438167D1D1A1F3D00D6F1E4 /* IDJCalendarUtil.mm */; };
20 | 0438168B1D1A1F3D00D6F1E4 /* IDJChineseCalendar.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0438167F1D1A1F3D00D6F1E4 /* IDJChineseCalendar.mm */; };
21 | 0438168D1D1A1F3D00D6F1E4 /* ChineseCalendarDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 043816831D1A1F3D00D6F1E4 /* ChineseCalendarDB.cpp */; };
22 | 0438168E1D1A1F3D00D6F1E4 /* ChineseDate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 043816851D1A1F3D00D6F1E4 /* ChineseDate.cpp */; };
23 | 0438168F1D1A1F3D00D6F1E4 /* SolarDate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 043816871D1A1F3D00D6F1E4 /* SolarDate.cpp */; };
24 | 043816921D1A200100D6F1E4 /* GYZCustomCalendarPickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 043816911D1A200100D6F1E4 /* GYZCustomCalendarPickerView.m */; };
25 | /* End PBXBuildFile section */
26 |
27 | /* Begin PBXContainerItemProxy section */
28 | 0438165D1D1A1EBE00D6F1E4 /* PBXContainerItemProxy */ = {
29 | isa = PBXContainerItemProxy;
30 | containerPortal = 0438163B1D1A1EBE00D6F1E4 /* Project object */;
31 | proxyType = 1;
32 | remoteGlobalIDString = 043816421D1A1EBE00D6F1E4;
33 | remoteInfo = GYZCalendarPicker;
34 | };
35 | 043816681D1A1EBE00D6F1E4 /* PBXContainerItemProxy */ = {
36 | isa = PBXContainerItemProxy;
37 | containerPortal = 0438163B1D1A1EBE00D6F1E4 /* Project object */;
38 | proxyType = 1;
39 | remoteGlobalIDString = 043816421D1A1EBE00D6F1E4;
40 | remoteInfo = GYZCalendarPicker;
41 | };
42 | /* End PBXContainerItemProxy section */
43 |
44 | /* Begin PBXFileReference section */
45 | 043816431D1A1EBE00D6F1E4 /* GYZCalendarPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GYZCalendarPicker.app; sourceTree = BUILT_PRODUCTS_DIR; };
46 | 043816471D1A1EBE00D6F1E4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
47 | 043816491D1A1EBE00D6F1E4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
48 | 0438164A1D1A1EBE00D6F1E4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
49 | 0438164C1D1A1EBE00D6F1E4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
50 | 0438164D1D1A1EBE00D6F1E4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
51 | 043816501D1A1EBE00D6F1E4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
52 | 043816521D1A1EBE00D6F1E4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
53 | 043816551D1A1EBE00D6F1E4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
54 | 043816571D1A1EBE00D6F1E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
55 | 0438165C1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GYZCalendarPickerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56 | 043816601D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYZCalendarPickerTests.m; sourceTree = ""; };
57 | 043816621D1A1EBE00D6F1E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
58 | 043816671D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GYZCalendarPickerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
59 | 0438166B1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYZCalendarPickerUITests.m; sourceTree = ""; };
60 | 0438166D1D1A1EBE00D6F1E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
61 | 0438167A1D1A1F3D00D6F1E4 /* IDJCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDJCalendar.h; sourceTree = ""; };
62 | 0438167B1D1A1F3D00D6F1E4 /* IDJCalendar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IDJCalendar.m; sourceTree = ""; };
63 | 0438167C1D1A1F3D00D6F1E4 /* IDJCalendarUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDJCalendarUtil.h; sourceTree = ""; };
64 | 0438167D1D1A1F3D00D6F1E4 /* IDJCalendarUtil.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IDJCalendarUtil.mm; sourceTree = ""; };
65 | 0438167E1D1A1F3D00D6F1E4 /* IDJChineseCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDJChineseCalendar.h; sourceTree = ""; };
66 | 0438167F1D1A1F3D00D6F1E4 /* IDJChineseCalendar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IDJChineseCalendar.mm; sourceTree = ""; };
67 | 043816831D1A1F3D00D6F1E4 /* ChineseCalendarDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChineseCalendarDB.cpp; sourceTree = ""; };
68 | 043816841D1A1F3D00D6F1E4 /* ChineseCalendarDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChineseCalendarDB.h; sourceTree = ""; };
69 | 043816851D1A1F3D00D6F1E4 /* ChineseDate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChineseDate.cpp; sourceTree = ""; };
70 | 043816861D1A1F3D00D6F1E4 /* ChineseDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChineseDate.h; sourceTree = ""; };
71 | 043816871D1A1F3D00D6F1E4 /* SolarDate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SolarDate.cpp; sourceTree = ""; };
72 | 043816881D1A1F3D00D6F1E4 /* SolarDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SolarDate.h; sourceTree = ""; };
73 | 043816901D1A200100D6F1E4 /* GYZCustomCalendarPickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYZCustomCalendarPickerView.h; sourceTree = ""; };
74 | 043816911D1A200100D6F1E4 /* GYZCustomCalendarPickerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYZCustomCalendarPickerView.m; sourceTree = ""; };
75 | 043816931D1A211200D6F1E4 /* GYZCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYZCommon.h; sourceTree = ""; };
76 | /* End PBXFileReference section */
77 |
78 | /* Begin PBXFrameworksBuildPhase section */
79 | 043816401D1A1EBE00D6F1E4 /* Frameworks */ = {
80 | isa = PBXFrameworksBuildPhase;
81 | buildActionMask = 2147483647;
82 | files = (
83 | );
84 | runOnlyForDeploymentPostprocessing = 0;
85 | };
86 | 043816591D1A1EBE00D6F1E4 /* Frameworks */ = {
87 | isa = PBXFrameworksBuildPhase;
88 | buildActionMask = 2147483647;
89 | files = (
90 | );
91 | runOnlyForDeploymentPostprocessing = 0;
92 | };
93 | 043816641D1A1EBE00D6F1E4 /* Frameworks */ = {
94 | isa = PBXFrameworksBuildPhase;
95 | buildActionMask = 2147483647;
96 | files = (
97 | );
98 | runOnlyForDeploymentPostprocessing = 0;
99 | };
100 | /* End PBXFrameworksBuildPhase section */
101 |
102 | /* Begin PBXGroup section */
103 | 0438163A1D1A1EBE00D6F1E4 = {
104 | isa = PBXGroup;
105 | children = (
106 | 043816791D1A1F3D00D6F1E4 /* CustomCalendar */,
107 | 043816451D1A1EBE00D6F1E4 /* GYZCalendarPicker */,
108 | 0438165F1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests */,
109 | 0438166A1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests */,
110 | 043816441D1A1EBE00D6F1E4 /* Products */,
111 | );
112 | sourceTree = "";
113 | };
114 | 043816441D1A1EBE00D6F1E4 /* Products */ = {
115 | isa = PBXGroup;
116 | children = (
117 | 043816431D1A1EBE00D6F1E4 /* GYZCalendarPicker.app */,
118 | 0438165C1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.xctest */,
119 | 043816671D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.xctest */,
120 | );
121 | name = Products;
122 | sourceTree = "";
123 | };
124 | 043816451D1A1EBE00D6F1E4 /* GYZCalendarPicker */ = {
125 | isa = PBXGroup;
126 | children = (
127 | 043816491D1A1EBE00D6F1E4 /* AppDelegate.h */,
128 | 0438164A1D1A1EBE00D6F1E4 /* AppDelegate.m */,
129 | 0438164C1D1A1EBE00D6F1E4 /* ViewController.h */,
130 | 0438164D1D1A1EBE00D6F1E4 /* ViewController.m */,
131 | 0438164F1D1A1EBE00D6F1E4 /* Main.storyboard */,
132 | 043816521D1A1EBE00D6F1E4 /* Assets.xcassets */,
133 | 043816541D1A1EBE00D6F1E4 /* LaunchScreen.storyboard */,
134 | 043816571D1A1EBE00D6F1E4 /* Info.plist */,
135 | 043816461D1A1EBE00D6F1E4 /* Supporting Files */,
136 | );
137 | path = GYZCalendarPicker;
138 | sourceTree = "";
139 | };
140 | 043816461D1A1EBE00D6F1E4 /* Supporting Files */ = {
141 | isa = PBXGroup;
142 | children = (
143 | 043816471D1A1EBE00D6F1E4 /* main.m */,
144 | );
145 | name = "Supporting Files";
146 | sourceTree = "";
147 | };
148 | 0438165F1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests */ = {
149 | isa = PBXGroup;
150 | children = (
151 | 043816601D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.m */,
152 | 043816621D1A1EBE00D6F1E4 /* Info.plist */,
153 | );
154 | path = GYZCalendarPickerTests;
155 | sourceTree = "";
156 | };
157 | 0438166A1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests */ = {
158 | isa = PBXGroup;
159 | children = (
160 | 0438166B1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.m */,
161 | 0438166D1D1A1EBE00D6F1E4 /* Info.plist */,
162 | );
163 | path = GYZCalendarPickerUITests;
164 | sourceTree = "";
165 | };
166 | 043816791D1A1F3D00D6F1E4 /* CustomCalendar */ = {
167 | isa = PBXGroup;
168 | children = (
169 | 043816931D1A211200D6F1E4 /* GYZCommon.h */,
170 | 0438167A1D1A1F3D00D6F1E4 /* IDJCalendar.h */,
171 | 0438167B1D1A1F3D00D6F1E4 /* IDJCalendar.m */,
172 | 0438167C1D1A1F3D00D6F1E4 /* IDJCalendarUtil.h */,
173 | 0438167D1D1A1F3D00D6F1E4 /* IDJCalendarUtil.mm */,
174 | 0438167E1D1A1F3D00D6F1E4 /* IDJChineseCalendar.h */,
175 | 0438167F1D1A1F3D00D6F1E4 /* IDJChineseCalendar.mm */,
176 | 043816901D1A200100D6F1E4 /* GYZCustomCalendarPickerView.h */,
177 | 043816911D1A200100D6F1E4 /* GYZCustomCalendarPickerView.m */,
178 | 043816821D1A1F3D00D6F1E4 /* solar_chinese_calendar */,
179 | );
180 | path = CustomCalendar;
181 | sourceTree = "";
182 | };
183 | 043816821D1A1F3D00D6F1E4 /* solar_chinese_calendar */ = {
184 | isa = PBXGroup;
185 | children = (
186 | 043816831D1A1F3D00D6F1E4 /* ChineseCalendarDB.cpp */,
187 | 043816841D1A1F3D00D6F1E4 /* ChineseCalendarDB.h */,
188 | 043816851D1A1F3D00D6F1E4 /* ChineseDate.cpp */,
189 | 043816861D1A1F3D00D6F1E4 /* ChineseDate.h */,
190 | 043816871D1A1F3D00D6F1E4 /* SolarDate.cpp */,
191 | 043816881D1A1F3D00D6F1E4 /* SolarDate.h */,
192 | );
193 | path = solar_chinese_calendar;
194 | sourceTree = "";
195 | };
196 | /* End PBXGroup section */
197 |
198 | /* Begin PBXNativeTarget section */
199 | 043816421D1A1EBE00D6F1E4 /* GYZCalendarPicker */ = {
200 | isa = PBXNativeTarget;
201 | buildConfigurationList = 043816701D1A1EBE00D6F1E4 /* Build configuration list for PBXNativeTarget "GYZCalendarPicker" */;
202 | buildPhases = (
203 | 0438163F1D1A1EBE00D6F1E4 /* Sources */,
204 | 043816401D1A1EBE00D6F1E4 /* Frameworks */,
205 | 043816411D1A1EBE00D6F1E4 /* Resources */,
206 | );
207 | buildRules = (
208 | );
209 | dependencies = (
210 | );
211 | name = GYZCalendarPicker;
212 | productName = GYZCalendarPicker;
213 | productReference = 043816431D1A1EBE00D6F1E4 /* GYZCalendarPicker.app */;
214 | productType = "com.apple.product-type.application";
215 | };
216 | 0438165B1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests */ = {
217 | isa = PBXNativeTarget;
218 | buildConfigurationList = 043816731D1A1EBE00D6F1E4 /* Build configuration list for PBXNativeTarget "GYZCalendarPickerTests" */;
219 | buildPhases = (
220 | 043816581D1A1EBE00D6F1E4 /* Sources */,
221 | 043816591D1A1EBE00D6F1E4 /* Frameworks */,
222 | 0438165A1D1A1EBE00D6F1E4 /* Resources */,
223 | );
224 | buildRules = (
225 | );
226 | dependencies = (
227 | 0438165E1D1A1EBE00D6F1E4 /* PBXTargetDependency */,
228 | );
229 | name = GYZCalendarPickerTests;
230 | productName = GYZCalendarPickerTests;
231 | productReference = 0438165C1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.xctest */;
232 | productType = "com.apple.product-type.bundle.unit-test";
233 | };
234 | 043816661D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests */ = {
235 | isa = PBXNativeTarget;
236 | buildConfigurationList = 043816761D1A1EBE00D6F1E4 /* Build configuration list for PBXNativeTarget "GYZCalendarPickerUITests" */;
237 | buildPhases = (
238 | 043816631D1A1EBE00D6F1E4 /* Sources */,
239 | 043816641D1A1EBE00D6F1E4 /* Frameworks */,
240 | 043816651D1A1EBE00D6F1E4 /* Resources */,
241 | );
242 | buildRules = (
243 | );
244 | dependencies = (
245 | 043816691D1A1EBE00D6F1E4 /* PBXTargetDependency */,
246 | );
247 | name = GYZCalendarPickerUITests;
248 | productName = GYZCalendarPickerUITests;
249 | productReference = 043816671D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.xctest */;
250 | productType = "com.apple.product-type.bundle.ui-testing";
251 | };
252 | /* End PBXNativeTarget section */
253 |
254 | /* Begin PBXProject section */
255 | 0438163B1D1A1EBE00D6F1E4 /* Project object */ = {
256 | isa = PBXProject;
257 | attributes = {
258 | CLASSPREFIX = GYZ;
259 | LastUpgradeCheck = 0730;
260 | ORGANIZATIONNAME = GYZ;
261 | TargetAttributes = {
262 | 043816421D1A1EBE00D6F1E4 = {
263 | CreatedOnToolsVersion = 7.3;
264 | };
265 | 0438165B1D1A1EBE00D6F1E4 = {
266 | CreatedOnToolsVersion = 7.3;
267 | TestTargetID = 043816421D1A1EBE00D6F1E4;
268 | };
269 | 043816661D1A1EBE00D6F1E4 = {
270 | CreatedOnToolsVersion = 7.3;
271 | TestTargetID = 043816421D1A1EBE00D6F1E4;
272 | };
273 | };
274 | };
275 | buildConfigurationList = 0438163E1D1A1EBE00D6F1E4 /* Build configuration list for PBXProject "GYZCalendarPicker" */;
276 | compatibilityVersion = "Xcode 3.2";
277 | developmentRegion = English;
278 | hasScannedForEncodings = 0;
279 | knownRegions = (
280 | en,
281 | Base,
282 | );
283 | mainGroup = 0438163A1D1A1EBE00D6F1E4;
284 | productRefGroup = 043816441D1A1EBE00D6F1E4 /* Products */;
285 | projectDirPath = "";
286 | projectRoot = "";
287 | targets = (
288 | 043816421D1A1EBE00D6F1E4 /* GYZCalendarPicker */,
289 | 0438165B1D1A1EBE00D6F1E4 /* GYZCalendarPickerTests */,
290 | 043816661D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests */,
291 | );
292 | };
293 | /* End PBXProject section */
294 |
295 | /* Begin PBXResourcesBuildPhase section */
296 | 043816411D1A1EBE00D6F1E4 /* Resources */ = {
297 | isa = PBXResourcesBuildPhase;
298 | buildActionMask = 2147483647;
299 | files = (
300 | 043816561D1A1EBE00D6F1E4 /* LaunchScreen.storyboard in Resources */,
301 | 043816531D1A1EBE00D6F1E4 /* Assets.xcassets in Resources */,
302 | 043816511D1A1EBE00D6F1E4 /* Main.storyboard in Resources */,
303 | );
304 | runOnlyForDeploymentPostprocessing = 0;
305 | };
306 | 0438165A1D1A1EBE00D6F1E4 /* Resources */ = {
307 | isa = PBXResourcesBuildPhase;
308 | buildActionMask = 2147483647;
309 | files = (
310 | );
311 | runOnlyForDeploymentPostprocessing = 0;
312 | };
313 | 043816651D1A1EBE00D6F1E4 /* Resources */ = {
314 | isa = PBXResourcesBuildPhase;
315 | buildActionMask = 2147483647;
316 | files = (
317 | );
318 | runOnlyForDeploymentPostprocessing = 0;
319 | };
320 | /* End PBXResourcesBuildPhase section */
321 |
322 | /* Begin PBXSourcesBuildPhase section */
323 | 0438163F1D1A1EBE00D6F1E4 /* Sources */ = {
324 | isa = PBXSourcesBuildPhase;
325 | buildActionMask = 2147483647;
326 | files = (
327 | 0438164E1D1A1EBE00D6F1E4 /* ViewController.m in Sources */,
328 | 0438168A1D1A1F3D00D6F1E4 /* IDJCalendarUtil.mm in Sources */,
329 | 043816891D1A1F3D00D6F1E4 /* IDJCalendar.m in Sources */,
330 | 0438168F1D1A1F3D00D6F1E4 /* SolarDate.cpp in Sources */,
331 | 0438168E1D1A1F3D00D6F1E4 /* ChineseDate.cpp in Sources */,
332 | 0438164B1D1A1EBE00D6F1E4 /* AppDelegate.m in Sources */,
333 | 0438168D1D1A1F3D00D6F1E4 /* ChineseCalendarDB.cpp in Sources */,
334 | 043816481D1A1EBE00D6F1E4 /* main.m in Sources */,
335 | 043816921D1A200100D6F1E4 /* GYZCustomCalendarPickerView.m in Sources */,
336 | 0438168B1D1A1F3D00D6F1E4 /* IDJChineseCalendar.mm in Sources */,
337 | );
338 | runOnlyForDeploymentPostprocessing = 0;
339 | };
340 | 043816581D1A1EBE00D6F1E4 /* Sources */ = {
341 | isa = PBXSourcesBuildPhase;
342 | buildActionMask = 2147483647;
343 | files = (
344 | 043816611D1A1EBE00D6F1E4 /* GYZCalendarPickerTests.m in Sources */,
345 | );
346 | runOnlyForDeploymentPostprocessing = 0;
347 | };
348 | 043816631D1A1EBE00D6F1E4 /* Sources */ = {
349 | isa = PBXSourcesBuildPhase;
350 | buildActionMask = 2147483647;
351 | files = (
352 | 0438166C1D1A1EBE00D6F1E4 /* GYZCalendarPickerUITests.m in Sources */,
353 | );
354 | runOnlyForDeploymentPostprocessing = 0;
355 | };
356 | /* End PBXSourcesBuildPhase section */
357 |
358 | /* Begin PBXTargetDependency section */
359 | 0438165E1D1A1EBE00D6F1E4 /* PBXTargetDependency */ = {
360 | isa = PBXTargetDependency;
361 | target = 043816421D1A1EBE00D6F1E4 /* GYZCalendarPicker */;
362 | targetProxy = 0438165D1D1A1EBE00D6F1E4 /* PBXContainerItemProxy */;
363 | };
364 | 043816691D1A1EBE00D6F1E4 /* PBXTargetDependency */ = {
365 | isa = PBXTargetDependency;
366 | target = 043816421D1A1EBE00D6F1E4 /* GYZCalendarPicker */;
367 | targetProxy = 043816681D1A1EBE00D6F1E4 /* PBXContainerItemProxy */;
368 | };
369 | /* End PBXTargetDependency section */
370 |
371 | /* Begin PBXVariantGroup section */
372 | 0438164F1D1A1EBE00D6F1E4 /* Main.storyboard */ = {
373 | isa = PBXVariantGroup;
374 | children = (
375 | 043816501D1A1EBE00D6F1E4 /* Base */,
376 | );
377 | name = Main.storyboard;
378 | sourceTree = "";
379 | };
380 | 043816541D1A1EBE00D6F1E4 /* LaunchScreen.storyboard */ = {
381 | isa = PBXVariantGroup;
382 | children = (
383 | 043816551D1A1EBE00D6F1E4 /* Base */,
384 | );
385 | name = LaunchScreen.storyboard;
386 | sourceTree = "";
387 | };
388 | /* End PBXVariantGroup section */
389 |
390 | /* Begin XCBuildConfiguration section */
391 | 0438166E1D1A1EBE00D6F1E4 /* Debug */ = {
392 | isa = XCBuildConfiguration;
393 | buildSettings = {
394 | ALWAYS_SEARCH_USER_PATHS = NO;
395 | CLANG_ANALYZER_NONNULL = YES;
396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
397 | CLANG_CXX_LIBRARY = "libc++";
398 | CLANG_ENABLE_MODULES = YES;
399 | CLANG_ENABLE_OBJC_ARC = YES;
400 | CLANG_WARN_BOOL_CONVERSION = YES;
401 | CLANG_WARN_CONSTANT_CONVERSION = YES;
402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
403 | CLANG_WARN_EMPTY_BODY = YES;
404 | CLANG_WARN_ENUM_CONVERSION = YES;
405 | CLANG_WARN_INT_CONVERSION = YES;
406 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
407 | CLANG_WARN_UNREACHABLE_CODE = YES;
408 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
409 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
410 | COPY_PHASE_STRIP = NO;
411 | DEBUG_INFORMATION_FORMAT = dwarf;
412 | ENABLE_STRICT_OBJC_MSGSEND = YES;
413 | ENABLE_TESTABILITY = YES;
414 | GCC_C_LANGUAGE_STANDARD = gnu99;
415 | GCC_DYNAMIC_NO_PIC = NO;
416 | GCC_NO_COMMON_BLOCKS = YES;
417 | GCC_OPTIMIZATION_LEVEL = 0;
418 | GCC_PREPROCESSOR_DEFINITIONS = (
419 | "DEBUG=1",
420 | "$(inherited)",
421 | );
422 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
423 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
424 | GCC_WARN_UNDECLARED_SELECTOR = YES;
425 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
426 | GCC_WARN_UNUSED_FUNCTION = YES;
427 | GCC_WARN_UNUSED_VARIABLE = YES;
428 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
429 | MTL_ENABLE_DEBUG_INFO = YES;
430 | ONLY_ACTIVE_ARCH = YES;
431 | SDKROOT = iphoneos;
432 | };
433 | name = Debug;
434 | };
435 | 0438166F1D1A1EBE00D6F1E4 /* Release */ = {
436 | isa = XCBuildConfiguration;
437 | buildSettings = {
438 | ALWAYS_SEARCH_USER_PATHS = NO;
439 | CLANG_ANALYZER_NONNULL = YES;
440 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
441 | CLANG_CXX_LIBRARY = "libc++";
442 | CLANG_ENABLE_MODULES = YES;
443 | CLANG_ENABLE_OBJC_ARC = YES;
444 | CLANG_WARN_BOOL_CONVERSION = YES;
445 | CLANG_WARN_CONSTANT_CONVERSION = YES;
446 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
447 | CLANG_WARN_EMPTY_BODY = YES;
448 | CLANG_WARN_ENUM_CONVERSION = YES;
449 | CLANG_WARN_INT_CONVERSION = YES;
450 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
451 | CLANG_WARN_UNREACHABLE_CODE = YES;
452 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
453 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
454 | COPY_PHASE_STRIP = NO;
455 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
456 | ENABLE_NS_ASSERTIONS = NO;
457 | ENABLE_STRICT_OBJC_MSGSEND = YES;
458 | GCC_C_LANGUAGE_STANDARD = gnu99;
459 | GCC_NO_COMMON_BLOCKS = YES;
460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
461 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
462 | GCC_WARN_UNDECLARED_SELECTOR = YES;
463 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
464 | GCC_WARN_UNUSED_FUNCTION = YES;
465 | GCC_WARN_UNUSED_VARIABLE = YES;
466 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
467 | MTL_ENABLE_DEBUG_INFO = NO;
468 | SDKROOT = iphoneos;
469 | VALIDATE_PRODUCT = YES;
470 | };
471 | name = Release;
472 | };
473 | 043816711D1A1EBE00D6F1E4 /* Debug */ = {
474 | isa = XCBuildConfiguration;
475 | buildSettings = {
476 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
477 | INFOPLIST_FILE = GYZCalendarPicker/Info.plist;
478 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
480 | PRODUCT_BUNDLE_IDENTIFIER = com.GYZ.GYZCalendarPicker;
481 | PRODUCT_NAME = "$(TARGET_NAME)";
482 | };
483 | name = Debug;
484 | };
485 | 043816721D1A1EBE00D6F1E4 /* Release */ = {
486 | isa = XCBuildConfiguration;
487 | buildSettings = {
488 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
489 | INFOPLIST_FILE = GYZCalendarPicker/Info.plist;
490 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
492 | PRODUCT_BUNDLE_IDENTIFIER = com.GYZ.GYZCalendarPicker;
493 | PRODUCT_NAME = "$(TARGET_NAME)";
494 | };
495 | name = Release;
496 | };
497 | 043816741D1A1EBE00D6F1E4 /* Debug */ = {
498 | isa = XCBuildConfiguration;
499 | buildSettings = {
500 | BUNDLE_LOADER = "$(TEST_HOST)";
501 | INFOPLIST_FILE = GYZCalendarPickerTests/Info.plist;
502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
503 | PRODUCT_BUNDLE_IDENTIFIER = com.GYZ.GYZCalendarPickerTests;
504 | PRODUCT_NAME = "$(TARGET_NAME)";
505 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GYZCalendarPicker.app/GYZCalendarPicker";
506 | };
507 | name = Debug;
508 | };
509 | 043816751D1A1EBE00D6F1E4 /* Release */ = {
510 | isa = XCBuildConfiguration;
511 | buildSettings = {
512 | BUNDLE_LOADER = "$(TEST_HOST)";
513 | INFOPLIST_FILE = GYZCalendarPickerTests/Info.plist;
514 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
515 | PRODUCT_BUNDLE_IDENTIFIER = com.GYZ.GYZCalendarPickerTests;
516 | PRODUCT_NAME = "$(TARGET_NAME)";
517 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GYZCalendarPicker.app/GYZCalendarPicker";
518 | };
519 | name = Release;
520 | };
521 | 043816771D1A1EBE00D6F1E4 /* Debug */ = {
522 | isa = XCBuildConfiguration;
523 | buildSettings = {
524 | INFOPLIST_FILE = GYZCalendarPickerUITests/Info.plist;
525 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
526 | PRODUCT_BUNDLE_IDENTIFIER = com.GYZ.GYZCalendarPickerUITests;
527 | PRODUCT_NAME = "$(TARGET_NAME)";
528 | TEST_TARGET_NAME = GYZCalendarPicker;
529 | };
530 | name = Debug;
531 | };
532 | 043816781D1A1EBE00D6F1E4 /* Release */ = {
533 | isa = XCBuildConfiguration;
534 | buildSettings = {
535 | INFOPLIST_FILE = GYZCalendarPickerUITests/Info.plist;
536 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
537 | PRODUCT_BUNDLE_IDENTIFIER = com.GYZ.GYZCalendarPickerUITests;
538 | PRODUCT_NAME = "$(TARGET_NAME)";
539 | TEST_TARGET_NAME = GYZCalendarPicker;
540 | };
541 | name = Release;
542 | };
543 | /* End XCBuildConfiguration section */
544 |
545 | /* Begin XCConfigurationList section */
546 | 0438163E1D1A1EBE00D6F1E4 /* Build configuration list for PBXProject "GYZCalendarPicker" */ = {
547 | isa = XCConfigurationList;
548 | buildConfigurations = (
549 | 0438166E1D1A1EBE00D6F1E4 /* Debug */,
550 | 0438166F1D1A1EBE00D6F1E4 /* Release */,
551 | );
552 | defaultConfigurationIsVisible = 0;
553 | defaultConfigurationName = Release;
554 | };
555 | 043816701D1A1EBE00D6F1E4 /* Build configuration list for PBXNativeTarget "GYZCalendarPicker" */ = {
556 | isa = XCConfigurationList;
557 | buildConfigurations = (
558 | 043816711D1A1EBE00D6F1E4 /* Debug */,
559 | 043816721D1A1EBE00D6F1E4 /* Release */,
560 | );
561 | defaultConfigurationIsVisible = 0;
562 | defaultConfigurationName = Release;
563 | };
564 | 043816731D1A1EBE00D6F1E4 /* Build configuration list for PBXNativeTarget "GYZCalendarPickerTests" */ = {
565 | isa = XCConfigurationList;
566 | buildConfigurations = (
567 | 043816741D1A1EBE00D6F1E4 /* Debug */,
568 | 043816751D1A1EBE00D6F1E4 /* Release */,
569 | );
570 | defaultConfigurationIsVisible = 0;
571 | defaultConfigurationName = Release;
572 | };
573 | 043816761D1A1EBE00D6F1E4 /* Build configuration list for PBXNativeTarget "GYZCalendarPickerUITests" */ = {
574 | isa = XCConfigurationList;
575 | buildConfigurations = (
576 | 043816771D1A1EBE00D6F1E4 /* Debug */,
577 | 043816781D1A1EBE00D6F1E4 /* Release */,
578 | );
579 | defaultConfigurationIsVisible = 0;
580 | defaultConfigurationName = Release;
581 | };
582 | /* End XCConfigurationList section */
583 | };
584 | rootObject = 0438163B1D1A1EBE00D6F1E4 /* Project object */;
585 | }
586 |
--------------------------------------------------------------------------------