For anyone using the Arduino Time Library, How is the 2038 rollover being addressed?
Next question: will anyone be using Arduinos in 2038?
jremington:
Next question: will anyone be using Arduinos in 2038?
I don't know about an Arduino, but I hope people will still be using products I am developing now, in 20 years.
jremington:
Next question: will anyone be using Arduinos in 2038?
It's not an Arduino question. It has been a lurking problem in all UNIX based date storage, and Windows date storage, for ever.
We discovered it back in the late 1990's with Windows NT. There was a bug in the BIOS in some Unisys PCs. Sometimes at midnight, the time would race ahead at a tremendous rate, but would stop with an error when a date in 2038 was reached. I forget the exact date, but sometime in February, I think.
Paul
You can relax, all time libraries should use a unsigned 32-bit variable for the time by now. That will take us to the year 2106. Hopefully long before that (I hope at least 30 or 40 years before that) a 64-bit variable will be used. That means we have still 48 years before we should start using a 64-bit variable. Perhaps 128-bit with 64-bit for the whole seconds and 64-bit for the fraction of seconds. Perhaps there will be a different time system by then that can use any date, also a date before 1970.
The Time Library uses "time_t", that is "uint32_t" in the Arduino.
Fun fact: Did you know that the GCC compiler supports 64-bits variables, even for an Arduino Uno with a 8-bit microcontroller ? There are no libraries that support the uint64_t and int64_t, but the compiler can use it and do calculations with it.
Koepel:
The Time Library uses "time_t", that is "uint32_t" in the Arduino.
The Time library didn't specify a uint32_t used an unsigned long which can vary depending on CPU.
#if !defined(__time_t_defined) // avoid conflict with newlib or other posix libc
typedef unsigned long time_t;
#endif
On most processors used on Arduinos today, that is 32 bits. (it might be 64 bits on pic32 and intel)
You can define/create your own time_t typedef and defining __time_t_defined
before you include Time.h but it seems like overkill.
--- bill
Correct.
The "time.h" in the tools section: / hardware / tools / avr / avr / include / util / time.h
has "typedef uint32_t time_t;".
The Arduino Uno does not know "time_t" without including a library.
But when I select the Arduino Zero it does know the "time_t" ![]()
The origin is std::time_t ? That is beyond my knowledge.
Then I found this:
#define _TIME_T_ long /* time() */
in ".arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/include/machine/types.h"
It really does say a "long" :o because some functions return -1 when the date could not be solved. Ouch, we are in trouble for 2038.
Now I'm confused :![]()
This definition is in the most current TimeLib.h
#if !defined(__time_t_defined) // avoid conflict with newlib or other posix libc
typedef unsigned long time_t;
#endif
Perehama:
I don't know about an Arduino, but I hope people will still be using products I am developing now, in 20 years.
Yeah, like the Edsel, the fax machine, the typewriter, internal combustion vehicles, your Arduino-based invention will be here in 20 years.
Koepel:
There are no libraries that support the uint64_t and int64_t, but the compiler can use it and do calculations with it.
For the fun, one can use uint64_t, int64_t and double (double float) and print them as well with a DUE:
uint64_t bignum0 = 0xFFFFFFFFFFFFFFllu;
uint64_t bignum1 = pow(2, 64) - 1;
int64_t bignum2 = - pow(2, 62);
double bignum3 = -12.123456789876543210123;
void setup() {
Serial.begin(250000);
}
void loop() {
printf(" bignum0 = 0x%llx\n", bignum0);
printf(" bignum1 = %llu\n", bignum1);
printf(" bignum2 = %lld\n", bignum2);
Serial.println(bignum3, 15);
delay(1000);
}
BulldogLowell:
Yeah, like the Edsel, the fax machine, the typewriter, internal combustion vehicles, your Arduino-based invention will be here in 20 years.
Photo cameras using spools are still going strong.
Old VW beetles are still in high demand.
Vinyl records are still there or making a comeback.
![]()
Koepel:
You can relax, all time libraries should use a unsigned 32-bit variable for the time by now. That will take us to the year 2106.The Time Library uses "time_t", that is "uint32_t" in the Arduino.
Thank you.