Pages: [1]   Go Down
Author Topic: SOLVED How is "adjustTime(adjustment);" command used ? (time library)  (Read 1321 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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);
}

« Last Edit: February 13, 2013, 04:10:16 pm by dalai » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8849
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the 'adjustment' is in seconds.  If you want to adjust he time forward an hour, try an adjustment value of 3600.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8849
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void adjustTime(long adjustment){
  sysTime += adjustment;
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: