zoukankan      html  css  js  c++  java
  • lua日期处理函数


    function day_step(old_day,step)
       local y,m,d
       if("0" ~= string.sub(old_day,6,6)) then
          m=string.sub(old_day,6,7)
       else
          m=string.sub(old_day,7,7)
       end

       if("0" ~= string.sub(old_day,9,9)) then
          d=string.sub(old_day,9,10)
       else
          d=string.sub(old_day,10,10)
       end

       y=string.sub(old_day,0,4)
       
       local old_time=os.time{year=y,month=m,day=d}
       local new_time=old_time+86400*step

       local new_day=os.date("*t",new_time)
       local res=""

       if(tonumber(new_day.day)<10 and tonumber(new_day.month)<10)then
          res=new_day.year.."-".."0"..new_day.month.."-".."0"..new_day.day
       elseif tonumber(new_day.month)<10 then
          res=new_day.year.."-".."0"..new_day.month.."-"..new_day.day
       
       elseif tonumber(new_day.day)<10 then
          res=new_day.year.."-"..new_day.month.."-".."0"..new_day.day
       else
          res=new_day.year.."-"..new_day.month.."-"..new_day.day
       end
       return res
    end

  • 相关阅读:
    C语言I博客作业04
    C语言II博客作业04
    C语言II作业03
    C语言II博客作业02
    C语言II博客作业01
    第一周C语言作业
    C语言I博客作业02
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
  • 原文地址:https://www.cnblogs.com/yanzi-meng/p/11274438.html
Copyright © 2011-2022 走看看