获取当前日期下一天的公历年月日

//获取当前日期下一天的公历年月日
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);
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值