Go Down

Topic: Time library, adjustTime() (Read 93 times) previous topic - next topic

DionSoepboer

Hi,

I have some problems using the time library;

I set a time_t variable t and I want to adjust it in an interrupt using the adjustTime() function, but I don't know how to call this function..

The library discription says you can just write adjustTime(adjustment) but this doesn't work for me.

I have read a lot posts but I can't find a usefull answer.

Thanks.

Geek Emeritus

you are not alone:

https://github.com/kachok/arduino-libraries/issues/1

https://forum.arduino.cc/index.php?topic=148753.0

https://forum.arduino.cc/index.php?topic=434602.0

if you get your time from a GPS it adjusts, then the GPS adjusts it back

I had to put a routine in my clock that told me when the interrupt was changed, because it does not always work the way they say it does.

All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

DionSoepboer

#2
Nov 10, 2019, 11:02 pm Last Edit: Nov 10, 2019, 11:07 pm by DionSoepboer
Thank you for responding!

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

I suppose Time_t is used to roll over from hour 0 minute 59 to hour 1 minute 00? If i use the function presented above this isn't the case, it just counts up like an int..

Geek Emeritus

I did not know it expects a long. I always fed it an int. now I have to fiddle with that.
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

bperrybap

I suppose Time_t is used to roll over from hour 0 minute 59 to hour 1 minute 00? If i use the function presented above this isn't the case, it just counts up like an int..
I am not sure what you trying to say.
A time_t value is simply an incrementing value of seconds since the epoch, Different systems use different epochs, but the most common one in use came from Unix which is Jan 1, 1970 GMT.


In terms of adjustTime(), I have described in grueling detail, how adjustTime() works, and it is limitations as you have likely seen in the links referenced above.

Unless the Time library code is modified to use the value passed in as an offset that is always added to the actual time_t value. it cannot be used with a syncprovider.
But even then, in most cases, attempts to modify the time_t value are incorrectly trying to solve a timezone offset issue that should be solved some other way.
i.e. the time_t value should not be modified for the local timezone. That isn't how time is tracked when using epoch based time.

Maybe you could describe what you are really wanting to do, and why you need or are wanting to use adjustTime().


--- bill

Go Up