RTEMS | Cannot obtain dates later than 2100 (!339)

Joel Sherrill (@joel) gitlab at rtems.org
Wed Jan 29 22:11:53 UTC 2025



Merge request https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/339 was reviewed by Joel Sherrill

--
  
Joel Sherrill started a new discussion on cpukit/rtems/src/clockgettod.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/339#note_118499

 > +  time_of_day->hour   = current_time_tm->tm_hour;
 > +  time_of_day->minute = current_time_tm->tm_min;
 >    time_of_day->second = time_of_day->minute % RTEMS_SECS_PER_MINUTE;

If this line is still in the code, they should be deleted. You filled in second sabove.

--
  
Joel Sherrill started a new discussion on cpukit/rtems/src/clockgettod.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/339#note_118500

 > -  }
 > +  struct tm buf;
 > +  time_t current_time = time(NULL);

Do not fetch the current time again. You fetched it with _TOD_Get_timeval(). Use the tv_sec field with gmtime_r() and the tv_usec field of that for the ticks math. This lets you have only call to fetch the current time.

--
  
Joel Sherrill started a new discussion on cpukit/rtems/src/clockgettod.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/339#note_118501

 > +  time_t current_time = time(NULL);
 > +  struct tm *current_time_tm; 
 > +  current_time_tm = gmtime_r( &current_time, &buf );

Use now.tv_sec as I suggested above.


-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/339
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250129/ede7a6b7/attachment-0001.htm>


More information about the bugs mailing list