text: #include <third_party/fatfs/ff.h>
  #include <ti/drivers/SDFatFS.h>
  #include <time.h>
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  int32_t fatfs_getFatTime(void) {
      time_t seconds;
      uint32_t fatTime;
      struct tm *pTime;
  
      /*
       *  TI time() returns seconds elapsed since 1900, while other tools
       *  return seconds from 1970.  However, both TI and GNU localtime()
       *  sets tm tm_year to number of years since 1900.
       */
      seconds = time(NULL);
  
      pTime = localtime(&seconds);
  
      /*
       *  localtime() sets pTime->tm_year to number of years
       *  since 1900, so subtract 80 from tm_year to get FAT time
       *  offset from 1980.
       */
      fatTime =
          ((uint32_t)(pTime->tm_year - 80) << 25) |
          ((uint32_t)(pTime->tm_mon) << 21) | ((uint32_t)(pTime->tm_mday) << 16) |
          ((uint32_t)(pTime->tm_hour) << 11) | ((uint32_t)(pTime->tm_min) << 5) |
          ((uint32_t)(pTime->tm_sec) >> 1);
  
      return ((int32_t)fatTime);
  }
  
  #ifdef __cplusplus
  }
  #endif
  