Go Down

Topic: SOLVED How is "adjustTime(adjustment);" command used ? (time library) (Read 1 time) previous topic - next topic

dalai

How is "adjustTime(adjustment);" command used ?

I want to  send a command to my program ,so an hour or a day is added to timer.
Later those commands will be sent by the press of a button

Is this command ok ? adjustTime(hour()++);
Code: [Select]
#include <Time.h>  


void setup()  {
 Serial.begin(9600);

 Serial.println("sending time to arduino");
 setTime(0,0,0,1,1,2000);
}

void loop(){
digitalClockDisplay();
delay(1000);
}

void digitalClockDisplay(){

 Serial.print(day());
 Serial.print(" ");
 Serial.print(hour());
 printDigits(minute());
 printDigits(second());
 Serial.print(" ");
 Serial.print(day());
 Serial.print(" ");
 Serial.print(month());
 Serial.print(" ");
 Serial.print(year());
 Serial.println();
}

void printDigits(int digits){
  Serial.print(":");
 if(digits < 10)
   Serial.print('0');
 Serial.print(digits);
}


johnwasser

I think the 'adjustment' is in seconds.  If you want to adjust he time forward an hour, try an adjustment value of 3600.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

PeterH

You need to look at the documentation for the library, or the examples that come with it, or the source code implementation, to understand how to use the functions provided by the library.
I only provide help via the forum - please do not contact me for private consultancy.

johnwasser


You need to look at the documentation for the library, or the examples that come with it, or the source code implementation, to understand how to use the functions provided by the library.

Sadly, the documentation provides NO help.  Basically it says "use this function to adjust the time".  The Playground article also shows no examples that include adjustTime(). 

It should not be necessary to read the library sources for basic documentation, but all too often it is.  That's one of the drawbacks of community-supplied libraries.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

PaulS

Quote
It should not be necessary to read the library sources for basic documentation, but all too often it is.

That documentation is never wrong, though:

Code: [Select]
void adjustTime(long adjustment){
  sysTime += adjustment;
}

dalai

Is posible to give me a practical exable for adding  1 minute or 1 hour  please ?
only the command
Thank you

dalai



Sadly, the documentation provides NO help.  Basically it says "use this function to adjust the time".  The Playground article also shows no examples that include adjustTime(). 


I am trying to find exambles of that command  for 3 days.
I feal like retarded

dalai

adjustTime(10);  
number "10" is in seconds.
Thank you for your answers

Go Up