日期运算

来源:互联网 发布:手机阿里云系统好用吗 编辑:程序博客网 时间:2024/06/08 18:13
struct  tm LogServer::setNextTime(int internal)
{
 struct tm when;
    time_t now, result;
    int    days=internal;
    time( &now );
    when = *localtime( &now );
    //printf( "Current time is %s/n", asctime( &when ) );
    when.tm_mday = when.tm_mday + days;
    if( (result = mktime( &when )) != (time_t)-1 )
    {
     //snprintf(ptime,36,asctime( &when ));
        //printf( "In %d days the time will be %s/n", days, asctime( &when ) );
        return when;
    }
 else
  return NULL;
}
原创粉丝点击