Skip to content

Commit 1c1ba09

Browse files
committed
month ok
1 parent d1bac74 commit 1c1ba09

25 files changed

+1155
-26
lines changed

UIScrollViewCycleTest/UIScrollViewCycleTest.xcodeproj/project.pbxproj

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
54EB8C061D7522A70007B657 /* UIScrollView+SMCScroll.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C051D7522A70007B657 /* UIScrollView+SMCScroll.m */; };
2727
54EB8C091D7525A00007B657 /* SMCCalendarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C081D7525A00007B657 /* SMCCalendarView.m */; };
2828
54EB8C0B1D7527720007B657 /* SMCCalendarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 54EB8C0A1D7527720007B657 /* SMCCalendarView.xib */; };
29+
54EB8C131D7577510007B657 /* HYCalendarHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C0E1D7577510007B657 /* HYCalendarHeader.m */; };
30+
54EB8C141D7577510007B657 /* HYCalendarHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = 54EB8C0F1D7577510007B657 /* HYCalendarHeader.xib */; };
31+
54EB8C151D7577510007B657 /* HYCalendarHeaderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C111D7577510007B657 /* HYCalendarHeaderCell.m */; };
32+
54EB8C161D7577510007B657 /* HYCalendarHeaderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 54EB8C121D7577510007B657 /* HYCalendarHeaderCell.xib */; };
33+
54EB8C201D7577960007B657 /* NSDate+String.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C191D7577960007B657 /* NSDate+String.m */; };
34+
54EB8C211D7577960007B657 /* DateManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C1C1D7577960007B657 /* DateManager.m */; };
35+
54EB8C221D7577960007B657 /* XingZuoDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EB8C1F1D7577960007B657 /* XingZuoDate.m */; };
2936
/* End PBXBuildFile section */
3037

3138
/* Begin PBXContainerItemProxy section */
@@ -80,6 +87,19 @@
8087
54EB8C071D7525A00007B657 /* SMCCalendarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SMCCalendarView.h; sourceTree = "<group>"; };
8188
54EB8C081D7525A00007B657 /* SMCCalendarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SMCCalendarView.m; sourceTree = "<group>"; };
8289
54EB8C0A1D7527720007B657 /* SMCCalendarView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SMCCalendarView.xib; sourceTree = "<group>"; };
90+
54EB8C0D1D7577510007B657 /* HYCalendarHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HYCalendarHeader.h; sourceTree = "<group>"; };
91+
54EB8C0E1D7577510007B657 /* HYCalendarHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HYCalendarHeader.m; sourceTree = "<group>"; };
92+
54EB8C0F1D7577510007B657 /* HYCalendarHeader.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HYCalendarHeader.xib; sourceTree = "<group>"; };
93+
54EB8C101D7577510007B657 /* HYCalendarHeaderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HYCalendarHeaderCell.h; sourceTree = "<group>"; };
94+
54EB8C111D7577510007B657 /* HYCalendarHeaderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HYCalendarHeaderCell.m; sourceTree = "<group>"; };
95+
54EB8C121D7577510007B657 /* HYCalendarHeaderCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HYCalendarHeaderCell.xib; sourceTree = "<group>"; };
96+
54EB8C181D7577960007B657 /* NSDate+String.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+String.h"; sourceTree = "<group>"; };
97+
54EB8C191D7577960007B657 /* NSDate+String.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+String.m"; sourceTree = "<group>"; };
98+
54EB8C1B1D7577960007B657 /* DateManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateManager.h; sourceTree = "<group>"; };
99+
54EB8C1C1D7577960007B657 /* DateManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateManager.m; sourceTree = "<group>"; };
100+
54EB8C1D1D7577960007B657 /* XingZuo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XingZuo.h; sourceTree = "<group>"; };
101+
54EB8C1E1D7577960007B657 /* XingZuoDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XingZuoDate.h; sourceTree = "<group>"; };
102+
54EB8C1F1D7577960007B657 /* XingZuoDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XingZuoDate.m; sourceTree = "<group>"; };
83103
/* End PBXFileReference section */
84104

85105
/* Begin PBXFrameworksBuildPhase section */
@@ -177,6 +197,9 @@
177197
54EB8BF41D7519660007B657 /* Calendar */ = {
178198
isa = PBXGroup;
179199
children = (
200+
54EB8C171D7577960007B657 /* Category */,
201+
54EB8C1A1D7577960007B657 /* Data */,
202+
54EB8C0C1D7577480007B657 /* Header */,
180203
54EB8BF51D7519BA0007B657 /* SMCMonthView.h */,
181204
54EB8BF61D7519BA0007B657 /* SMCMonthView.m */,
182205
54EB8BF81D7519D30007B657 /* SMCMonthView.xib */,
@@ -195,6 +218,40 @@
195218
path = Calendar;
196219
sourceTree = "<group>";
197220
};
221+
54EB8C0C1D7577480007B657 /* Header */ = {
222+
isa = PBXGroup;
223+
children = (
224+
54EB8C0D1D7577510007B657 /* HYCalendarHeader.h */,
225+
54EB8C0E1D7577510007B657 /* HYCalendarHeader.m */,
226+
54EB8C0F1D7577510007B657 /* HYCalendarHeader.xib */,
227+
54EB8C101D7577510007B657 /* HYCalendarHeaderCell.h */,
228+
54EB8C111D7577510007B657 /* HYCalendarHeaderCell.m */,
229+
54EB8C121D7577510007B657 /* HYCalendarHeaderCell.xib */,
230+
);
231+
path = Header;
232+
sourceTree = "<group>";
233+
};
234+
54EB8C171D7577960007B657 /* Category */ = {
235+
isa = PBXGroup;
236+
children = (
237+
54EB8C181D7577960007B657 /* NSDate+String.h */,
238+
54EB8C191D7577960007B657 /* NSDate+String.m */,
239+
);
240+
path = Category;
241+
sourceTree = "<group>";
242+
};
243+
54EB8C1A1D7577960007B657 /* Data */ = {
244+
isa = PBXGroup;
245+
children = (
246+
54EB8C1B1D7577960007B657 /* DateManager.h */,
247+
54EB8C1C1D7577960007B657 /* DateManager.m */,
248+
54EB8C1D1D7577960007B657 /* XingZuo.h */,
249+
54EB8C1E1D7577960007B657 /* XingZuoDate.h */,
250+
54EB8C1F1D7577960007B657 /* XingZuoDate.m */,
251+
);
252+
path = Data;
253+
sourceTree = "<group>";
254+
};
198255
/* End PBXGroup section */
199256

200257
/* Begin PBXNativeTarget section */
@@ -299,10 +356,12 @@
299356
buildActionMask = 2147483647;
300357
files = (
301358
54EB8BCB1D73FB9E0007B657 /* LaunchScreen.storyboard in Resources */,
359+
54EB8C141D7577510007B657 /* HYCalendarHeader.xib in Resources */,
302360
54EB8C031D751E4B0007B657 /* SMCDayView.xib in Resources */,
303361
54EB8BF91D7519D30007B657 /* SMCMonthView.xib in Resources */,
304362
54EB8C0B1D7527720007B657 /* SMCCalendarView.xib in Resources */,
305363
54EB8BC81D73FB9E0007B657 /* Assets.xcassets in Resources */,
364+
54EB8C161D7577510007B657 /* HYCalendarHeaderCell.xib in Resources */,
306365
54EB8BC61D73FB9E0007B657 /* Main.storyboard in Resources */,
307366
54EB8BFE1D751E010007B657 /* SMCWeekView.xib in Resources */,
308367
);
@@ -330,15 +389,20 @@
330389
buildActionMask = 2147483647;
331390
files = (
332391
54EB8BC31D73FB9E0007B657 /* ViewController.m in Sources */,
392+
54EB8C151D7577510007B657 /* HYCalendarHeaderCell.m in Sources */,
333393
54EB8BFC1D751DF40007B657 /* SMCWeekView.m in Sources */,
334394
54EB8BF71D7519BA0007B657 /* SMCMonthView.m in Sources */,
335395
54EB8C011D751E400007B657 /* SMCDayView.m in Sources */,
336396
54EB8BC01D73FB9E0007B657 /* AppDelegate.m in Sources */,
337397
54EB8BBD1D73FB9E0007B657 /* main.m in Sources */,
398+
54EB8C131D7577510007B657 /* HYCalendarHeader.m in Sources */,
399+
54EB8C221D7577960007B657 /* XingZuoDate.m in Sources */,
338400
54EB8C091D7525A00007B657 /* SMCCalendarView.m in Sources */,
401+
54EB8C211D7577960007B657 /* DateManager.m in Sources */,
339402
54EB8BF31D7517BB0007B657 /* CalendarViewController.m in Sources */,
340403
54EB8C061D7522A70007B657 /* UIScrollView+SMCScroll.m in Sources */,
341404
54EB8BF01D7516E10007B657 /* MainViewController.m in Sources */,
405+
54EB8C201D7577960007B657 /* NSDate+String.m in Sources */,
342406
);
343407
runOnlyForDeploymentPostprocessing = 0;
344408
};

UIScrollViewCycleTest/UIScrollViewCycleTest/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</objects>
2323
<point key="canvasLocation" x="97" y="445"/>
2424
</scene>
25-
<!--UIScrollViewTest-->
25+
<!--首页-->
2626
<scene sceneID="ieF-TQ-tex">
2727
<objects>
2828
<tableViewController id="9v1-0e-45E" customClass="MainViewController" sceneMemberID="viewController">
@@ -95,7 +95,7 @@
9595
<outlet property="delegate" destination="9v1-0e-45E" id="LXq-QS-OGt"/>
9696
</connections>
9797
</tableView>
98-
<navigationItem key="navigationItem" title="UIScrollViewTest" id="QpM-hK-xK3"/>
98+
<navigationItem key="navigationItem" title="首页" id="QpM-hK-xK3"/>
9999
<simulatedScreenMetrics key="simulatedDestinationMetrics"/>
100100
</tableViewController>
101101
<placeholder placeholderIdentifier="IBFirstResponder" id="4qm-bR-awt" userLabel="First Responder" sceneMemberID="firstResponder"/>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// NSDate+String.h
3+
// HYLunarCalendar
4+
//
5+
// Created by SMC-MAC on 16/8/24.
6+
// Copyright © 2016年 heyou. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface NSDate (String)
12+
13+
/**
14+
* 获取年月字符串,例:2016年8月
15+
*
16+
* @return 年月
17+
*/
18+
- (NSString*)hy_stringYearMonth;
19+
/**
20+
* 获取年月日字符串,例:2016年8月23日
21+
*
22+
* @return 年月日
23+
*/
24+
- (NSString*)hy_stringYearMonthDay;
25+
26+
/**
27+
* 默认时间格式字符串,例:2016-8-24 18:33:06
28+
*
29+
* @return 默认时间格式字符串
30+
*/
31+
- (NSString*)hy_stringDefault;
32+
33+
/**
34+
* 获取天
35+
*
36+
* @return
37+
*/
38+
- (NSString*)hy_stringDay;
39+
40+
/**
41+
* 默认格式日期字符串转NSDate
42+
*
43+
* @param defaultString
44+
*
45+
* @return
46+
*/
47+
+ (NSDate*)hy_dateFromDefaultString:(NSString*)defaultString;
48+
49+
/**
50+
* 月日字符串转NSDate, 例:8-24
51+
*
52+
* @param 月日
53+
*
54+
* @return
55+
*/
56+
+ (NSDate*)hy_dateFromMDString:(NSString*)mdStr;
57+
58+
@end
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// NSDate+String.m
3+
// HYLunarCalendar
4+
//
5+
// Created by SMC-MAC on 16/8/24.
6+
// Copyright © 2016年 heyou. All rights reserved.
7+
//
8+
9+
#import "NSDate+String.h"
10+
11+
@implementation NSDate (String)
12+
13+
/**
14+
* 获取年月字符串,例:2016年8月
15+
*
16+
* @return 年月
17+
*/
18+
- (NSString*)hy_stringYearMonth {
19+
NSDateFormatter* fmt = [NSDateFormatter new];
20+
[fmt setDateFormat:@"yyyy年M月"];
21+
return [fmt stringFromDate:self];
22+
}
23+
24+
/**
25+
* 获取年月日字符串,例:2016年8月23日
26+
*
27+
* @return 年月日
28+
*/
29+
- (NSString*)hy_stringYearMonthDay {
30+
NSDateFormatter* fmt = [NSDateFormatter new];
31+
[fmt setDateFormat:@"yyyy年M月d日"];
32+
return [fmt stringFromDate:self];
33+
}
34+
35+
/**
36+
* 默认时间格式字符串,例:2016年8月24日 18:33:06
37+
*
38+
* @return 默认时间格式字符串
39+
*/
40+
- (NSString*)hy_stringDefault {
41+
NSDateFormatter* fmt = [NSDateFormatter new];
42+
[fmt setDateFormat:@"yyyy-M-d HH:mm:ss"];
43+
return [fmt stringFromDate:self];
44+
}
45+
46+
/**
47+
* 获取天
48+
*
49+
* @return
50+
*/
51+
- (NSString*)hy_stringDay {
52+
NSDateFormatter* fmt = [NSDateFormatter new];
53+
[fmt setDateFormat:@"d"];
54+
return [fmt stringFromDate:self];
55+
}
56+
57+
/**
58+
* 默认格式日期字符串转NSDate
59+
*
60+
* @param defaultString
61+
*
62+
* @return
63+
*/
64+
+ (NSDate*)hy_dateFromDefaultString:(NSString*)defaultString {
65+
NSDateFormatter* fmt = [NSDateFormatter new];
66+
[fmt setDateFormat:@"yyyy-M-d HH:mm:ss"];
67+
return [fmt dateFromString:defaultString];
68+
}
69+
70+
/**
71+
* 月日字符串转NSDate, 例:8-24
72+
*
73+
* @param 月日
74+
*
75+
* @return
76+
*/
77+
+ (NSDate*)hy_dateFromMDString:(NSString*)mdStr {
78+
NSDateFormatter* fmt = [NSDateFormatter new];
79+
[fmt setDateFormat:@"M月d日"];
80+
return [fmt dateFromString:mdStr];
81+
}
82+
83+
@end
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// DateManager.h
3+
// HYLunarCalendar
4+
//
5+
// Created by SMC-MAC on 16/8/24.
6+
// Copyright © 2016年 heyou. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
11+
12+
/**
13+
* 定义每周的第一天是星期几,1:周日,2:周一
14+
*/
15+
typedef NS_ENUM(NSInteger,WEEK_DAY) {
16+
/**
17+
* 周日
18+
*/
19+
WEEK_DAY_SUNDAY = 1,
20+
/**
21+
* 周一
22+
*/
23+
WEEK_DAY_MONDAY = 2,
24+
/**
25+
* 周二
26+
*/
27+
WEEK_DAY_TUESDAY = 3,
28+
/**
29+
* 周三
30+
*/
31+
WEEK_DAY_WEDNESDAY = 4,
32+
/**
33+
* 周四
34+
*/
35+
WEEK_DAY_THURSDAY = 5,
36+
/**
37+
* 周五
38+
*/
39+
WEEK_DAY_FRIDAY = 6,
40+
/**
41+
* 周六
42+
*/
43+
WEEK_DAY_SATURDAY = 7
44+
45+
};
46+
47+
@interface DateManager : NSObject
48+
/**
49+
* 单例
50+
*
51+
* @return 实例对象
52+
*/
53+
+ (instancetype)sharedInstance;
54+
55+
@property (nonatomic, strong) NSCalendar* calendar;
56+
57+
// 月偏移后的日期
58+
- (NSDate*)dateWithDate:(NSDate*)date monthOffset:(NSInteger)offset;
59+
// 周偏移
60+
- (NSDate*)dateWithDate:(NSDate*)date weekOffset:(NSInteger)offset;
61+
// 天偏移
62+
- (NSDate*)dateWithDate:(NSDate*)date dayOffset:(NSInteger)offset;
63+
// 获取两个时间段之间的月数
64+
- (NSInteger)monthsFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate;
65+
// 当前月的第一天
66+
- (NSDate*)firstDayOfMonth:(NSDate*)date;
67+
// 当前周的第一天
68+
- (NSDate*)firstDayOfWeek:(NSDate*)date;
69+
// 当前月,按周索引日期
70+
- (NSDate*)dateWithDate:(NSDate*)date weekIndex:(NSIndexPath*)indexPath;
71+
// 获取农历日期,例: 初八
72+
- (NSString*)getChineseCalendarDayWithDate:(NSDate *)date;
73+
// 获取农历年月日,例: 甲子年 八月 初八
74+
- (NSString*)getChineseCalendarDefaultStringWithDate:(NSDate *)date;
75+
// 获取农历月日星期,例: 八月初八 星期二
76+
- (NSString*)getChineseCalendarMDWWithDate:(NSDate *)date;
77+
// 是否在同一个月
78+
- (BOOL)isDate:(NSDate*)dateA inSameMonthWithDate:(NSDate*)dateB;
79+
// 是否在同一天
80+
- (BOOL)isDate:(NSDate*)dateA inSameDayWithDate:(NSDate*)dateB;
81+
// 获取星期字符串
82+
- (NSArray<NSString*>*)getWeekdayStrings;
83+
// index = 0 开始,获取星期字符串
84+
- (NSString*)getShortWeekString:(NSInteger)index;
85+
// 获取十二生肖表示的中国年
86+
- (NSString*)getShengXiao:(NSDate*)date;
87+
// 获取星座
88+
- (NSString*)getXingZuo:(NSDate*)date;
89+
@end

0 commit comments

Comments
 (0)