Advertisement
DraKiNs

[COD] Adicionar Dias

Jul 1st, 2011
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.92 KB | None | 0 0
  1. /*----------------------------------------
  2.  *
  3.  *   Give Days (Adicionar Dias)
  4.  *   Criado por DraKiNs (thanks Miki)
  5.  *   (c) Copyright 2011, [iPs]TeaM
  6.  *
  7. /*-------------------------------------- */
  8.  
  9.  
  10. giveDays(iDia,iMes,iAno,iDias)
  11. {
  12.     new
  13.         iMeses[12] = {1,0,2,0,4,0,6,0,8,9,0,11},
  14.         sString[32];
  15.  
  16.     iDia += iDias,iDia -= 1,iMes -= 1, iAno -= 1;
  17.     while(iDia > 30 || iMes > 12) {
  18.         iDia = ((!(iAno%400)||!(iAno%4)&&(iAno%100)) && iMes == 2 && iDia > 29) ? (iMes++,iDia - 31) : iDia; iMes = (iMes > 11) ? (iAno++, iMes - 11) : iMes;
  19.         iDia = (iMeses[iMes] && iDia > 31)  ? (iMes++,iDia - 31) : iDia; iMes = (iMes > 11) ? (iAno++, iMes - 11) : iMes;
  20.         iDia = (!iMeses[iMes] && iDia > 30) ? (iMes++,iDia - 30) : iDia; iMes = (iMes > 11) ? (iAno++, iMes - 11) : iMes;
  21.     }
  22.     iDia += 1, iMes += 1, iAno += 1;
  23.     return format(sString, 32, "%02d/%02d/%02d", iDia , iMes, iAno), sString;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement