获取当前日期下一天的公历年月日
2018-02-05 09:54
399 查看
//获取当前日期下一天的公历年月日 static void get_next_date_str(char *current_date_str, char *next_date_str) { int32_t n = atoi(current_date_str); LOG_INFO("current_date_int:%d,", n); int32_t temp_year = n/10000; int32_t temp_month = (n%10000)/100; int32_t temp_day = (n%10000)%100; LOG_INFO("temp_year:%d,", temp_year); LOG_INFO("temp_month:%d,", temp_month); LOG_INFO("temp_day:%d,", temp_day); if ((temp_month == 4)||(temp_month==6)||(temp_month==9)||(temp_month==11)) //小月处理 { if (temp_day ==30) { temp_day =1; temp_month++; } else { temp_day++; } } else if ((temp_month == 1)||(temp_month==3)||(temp_month==5)||(temp_month==7)||(temp_month==8)||(temp_month==10)) //大月处理 { if (temp_day==31) { temp_day =1; temp_month++; } else { temp_day++; } } else if (temp_month==12) //跨年处理 { if (temp_day==31) { temp_year++; temp_month=1; temp_day=1; } else { temp_day++; } } else if (temp_month==2) //2月处理(没有处理闰月29天情况) { if (temp_day == 28) { temp_day=1; temp_month++; } else { temp_day++; } } sprintf(next_date_str, "%d%02d%02d", temp_year, temp_month, temp_day); LOG_INFO("next_date_str:%s,", next_date_str); }
相关文章推荐
- Java根据出生年月日获取到当前日期的年月日
- iOS 获取公历、农历日期的年月日
- 获取当前年月日与日期的封装
- 输入日期,计算出与当前系统日期相隔多少天(获取系统时间,年月日分别获取,对其进行格式化simpledateformat;输入的日期类似操作)
- JS获取当前时间 格式 年月日 礼拜几 显示阴历日期 节气
- iOS 获取公历、农历日期的年月日的实例代码
- js中的getDate() getMonth() getFullYear()方法;js如何获取当前日期/年月日
- js获取当前日期和昨天日期(年月日)
- 获取当前日期的下一天的日期
- js获取当前时间,日期格式为年月日
- 输入当前日期,获取下一天的日期
- Java获取当前时间年月日、时间格式化打印、字符串转日期
- ios 获取当前的日期,年月日
- UtilDate(一):获取当前日期的年月日时分秒星期
- iOS 获取公历、农历日期的年月日
- [学习笔记]JS获取当前日期,年月日
- [原创]自动获取当前日期下一周的年月日代码
- 传入当前日期获取下一天的日期【时隔2年,我抛弃数据结构和算法已经那么久了,真是不应该啊。我有罪。】
- mysql 获取当前日期及格式化
- Js获取当前日期时间及其它操作