Jump to content

somar dias a data tipo time_t


dandantas
 Share

Recommended Posts

boas meus caros

ando aqui a matutar num problema

ora vejamos:

pretendo adicionar um numero de dias a uma data que esta numa estrutura, o tipo de dados é time_t.

time_t hoje, data; //data valor na estrutura e é referente ao passado superior a 90 dias

time(&hoje);

data=data-((hoje-data)/86400-90);

//desta forma pretendo que variavel data fique com o valor data de 90 dias atras.

da para ajudar...é que ja andei aos tombos com isto =)

Link to comment
Share on other sites

time_t hoje, data;
time(&hoje);
data = hoje - 90*24*60*60;

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to comment
Share on other sites

time_t não é uma estrutura se me lembro correctamente.

Exacto, um time_t é um long int disfarçado.

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.