//获取当前日期下一天的公历年月日
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);
}
获取当前日期下一天的公历年月日
最新推荐文章于 2023-09-08 18:09:16 发布