Closed
Description
Description
set_time()
should set the time in seconds since 1st January 1970. However, it is behaving very strangely on NRF52832
(UBLOX_EVK_NINA_B1
platform, all default compilation switches): it seems to be adding an offset to the elapsed number of seconds since startup instead! Am I going mad!?
Here is some simple/boring code:
int main()
{
time_t intendedTime;
time_t currentTime;
printf("\nStarting test.\n");
// Set the time to 7 seconds after midnight on 1st Jan 1970
intendedTime = 7;
printf("@ %d setting time to %d.\n", time(NULL), intendedTime);
set_time(intendedTime);
currentTime = time(NULL);
printf("time now is %d (difference %d), waiting 10 seconds...\n", currentTime, intendedTime - currentTime);
// Wait 10 seconds
wait_ms(10000);
// Try again to set the time to 7 seconds after midnight on 1st Jan 1970
intendedTime = 7;
printf("@ %d setting time to %d again.\n", time(NULL), intendedTime);
set_time(intendedTime);
currentTime = time(NULL);
printf("time now is %d (difference %d), waiting 10 seconds...\n", currentTime, intendedTime - currentTime);
// Wait another 10 seconds
wait_ms(10000);
// Try setting the time to midnight on 1st Jan 1970
intendedTime = 0;
printf("@ %d setting time to %d now.\n", time(NULL), intendedTime);
set_time(intendedTime);
currentTime = time(NULL);
printf("time now is %d (difference %d).\n", currentTime, intendedTime - currentTime);
while(1);
}
...and here is the output:
Starting test.
@ 0 setting time to 7.
time now is 7 (difference 0), waiting 10 seconds...
@ 16 setting time to 7 again.
time now is 17 (difference -10), waiting 10 seconds...
@ 26 setting time to 0 now.
time now is 20 (difference -20).
- toolchain: GCC_ARM or ARM
- mbed-os version: 6165386
(HEAD -> master, origin/master, origin/HEAD) Merge pull request #7893 from kivaisan/improve_callback_descriptions
Issue request type
[ ] Question
[ ] Enhancement
[x] Serious bug
[ ] I'm going mad
Metadata
Metadata
Assignees
Labels
No labels