通过UIpickerView实现date(农历)选择器(类似UIdatePicker),可以实现生日提醒等功能

1,需要导入

#import "solarOrLunar.h"
#import "solarActionView.h"
#import "Date+string.h"

源码下载链接: SolarOrLunarDeom

在需要实现的函数中添加

例如:

点击按钮

/*选择农历*/
/**************************************/
- (void)optionDate{/*弹出农历时间选择器*/solarActionView  *actionView =[[solarActionView alloc] initWithViewdelegate:self WithSheetTitle:@"农历" sheetMode:type_lunar];// [actionView initWithDate:[NSDate date]];//设定初始时间[actionView showInView:self.view];
}

对应的回调方法

#pragma mark - ActionSheetViewDetaSource
- (void)actionSheetSolarDate:(NSString *)year Month:(NSString *)month Day:(NSString *)day reserved:(NSString *)reserved{/*reserved=1为闰月*/NSLog(@"lunar:%@-%@-%@-%@",year,month,day,reserved);int year_ =[year intValue];int month_ =[month intValue];int day_ =[day intValue];int reserved_ =[reserved intValue];hjz solar =lunar_to_solar(year_, month_, day_, reserved_);NSLog(@"solar: %d-%d-%d\n",solar.year,solar.month,solar.day);NSString *dateAndTime =[NSString stringWithFormat:@"%d/%d/%d 08:00",solar.year,solar.month,solar.day];NSDateFormatter * dateFormatter = [[NSDateFormatter alloc]init];[dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm"];NSDate *date =[dateFormatter dateFromString:dateAndTime];/*得到转换过来了公历NSDate数据*//*检验时间是否正确dateAndTime = [dateFormatter stringFromDate:date];//得到字符串 选择的日期间NSLog(@"转换后的公历:%@",dateAndTime);*//*对应的天干、地支、属相*/if(year_>1921)NSLog(@"属相日期:%@",[Date_string LunarForSolar:date]);
}- (void)actionSheetTitleDateText:(NSString *)year Month:(NSString *)month day:(NSString *)day{NSLog(@"农历日期:%@年%@月%@日",year,month,day);
}

农历转公历

     NSDateFormatter *formatter = [[NSDateFormatter alloc]init];[formatter setDateFormat:@"yyyy-MM-dd"];NSString *Date = [formatter stringFromDate:[NSDate date]];NSArray *arr=[Date componentsSeparatedByString:@"-"];int year =[arr[0] intValue];int month =[arr[1] intValue];int day =[arr[2] intValue];hjz lunar =solar_to_lunar(year, month, day);//将当前的公历时间转换为农历printf("lunar:=>%d-%d-%d-%d",lunar.year,lunar.month,lunar.day,lunar.reserved);//reserved=1为闰月

公历转农历上面回调中已经实现过了

ios - 农历公历互转 农历选择器相关推荐

  1. JS农历公历互转 阳历阴历互转

    参考https://blog.jjonline.cn/userInterFace/173.html 测试: //农历转公var str = "1990-12-29";var res ...

  2. PHP 农历公历互转,八字排盘,星座,日历,支持从-1000到3000年间的排盘,二十四节气...

    <?php /*** @author szargv@wo.cn** 此日历转换类完全源于以下项目,感谢这两个项目作者的无私分享:* https://github.com/nozomi199/qi ...

  3. 农历公历万年历互查系统

    此文章来源:http://www.k369.com/qt/cx/nongli.htm 此文件为html文件,因为javaeye设置了关键词禁用,里面的"毛领导"用的时候应作修改. ...

  4. iOS 获取公历、农历日期的年月日

    iOS 获取公历.农历日期的年月日 原文地址:http://www.cnblogs.com/silence-cnblogs/p/6368437.html 介绍了用Calendar.DateCompon ...

  5. js 万年历农历转阳历 方法_Python 农历公历算法转换

    背景 日常用python处理各种数据分析工作,最近需要对历年春节期间的数据做一些对比工作,本来只是用了一个简单的日期数组来进行,但后来发现一些数据在农历日期进行对比的时候,会有一些有趣的规律,进而产生 ...

  6. c语言万年历农历转公历,公历日期与农历日期的相互转换程序

    公历日期与农历日期的相互转换程序 //********************************** // 公历日期与农历日期的相互转换程序 // 公元1800年1月25日-2101年1月28日 ...

  7. ABAP 阳历日期与农历日期互转

    ABAP 阳历日期与农历日期互转 背景 项目简介 类工具方法简介 农历日期转公历日期 公历日期转农历日期 测试Demo 公历转农历 农历转公历 项目Github地址 代码 背景 SAP HCM需要一个 ...

  8. 农历php,PHP农历公历转换

    /* 云南省曲靖师范学院计算机科学与工程学院-杨海熙编写 2009-9-3 */ class Lunar { private $_SMDay = array(1 => 31, 28, 31, 3 ...

  9. python万年历差农历程序_Python实现公历(阳历)转农历(阴历)的方法示例

    本文实例讲述了Python实现公历(阳历)转农历(阴历)的方法.分享给大家供大家参考,具体如下: 两个要点: 1.公历转农历用了查表法(第126行) 2.节气用了天文法?(第176行) 运行图(背景是 ...

最新文章

  1. 工作发狂:Mybatis 中$和#千万不要乱用!
  2. 优化标定的加入与实现
  3. mysql脚本下载_Mysql备份脚本
  4. wireshark数据包分析实战
  5. JDK 14 Rampdown:内部版本27
  6. python 读取 Excel 文件的方法 csv.reader
  7. webbrowser实现input tab事件_如何合理构造一个Uploader工具类(设计到实现)
  8. VC 实现文件夹属性的获取与更改
  9. python 命令行解析模块_Python解析命令行读取参数 -- argparse模块
  10. 诺基亚9.3 PureView或再度跳票:搭载高通骁龙875明年发布
  11. (翻译)正确实施DevOps-The Lay of the Land
  12. numpy教程:数学函数和基本统计函数
  13. m1 MacBook 进入自检模式
  14. 初探 Redis 客户端 Lettuce:真香!
  15. 水果店快开业怎么发朋友圈,水果店开业怎么发朋友圈图片
  16. 量子计算与量子信息之量子信息概述
  17. CF545C题解【贪心】
  18. matlab某分子由25个原子组成,清华大学数学实验实验7无约束优化1
  19. c语言数组越界也太难了吧,跨函数越界啥意思?
  20. vue项目中集成腾讯TIM即时通讯(附源码)

热门文章

  1. 都说数据是资产,那么到底什么是数据资产?
  2. cobalt strike profile
  3. 7-13 寻找大富翁 (25 分)
  4. 用Java编写程序实现从键盘读入学生成绩,找出最高分,并输出学生成绩和学生的等级。
  5. 领带打法最新10种(图解)
  6. 学Git?这一篇就够了
  7. 小程序直接跳转公众号的必要条件记录
  8. Dedecms 5.7 SP2后台广告管理处getshell
  9. 苹果手机屏幕如何投射到win10?
  10. Abp vNext 常见问题