Skip to content

Commit

Permalink
Fix milli secs conversion (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSoundy authored and josesimoes committed Jun 25, 2019
1 parent 32603b0 commit 570ba75
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <target_platform.h>
#include <Esp32_os.h>

#define TIME_CONVERSION__TO_USECS 10

// Returns the current date time from the RTC
uint64_t HAL_Time_CurrentDateTime(bool datePartOnly)
{
Expand All @@ -20,7 +22,7 @@ uint64_t HAL_Time_CurrentDateTime(bool datePartOnly)
gettimeofday(&tv, NULL);

// Convert from Unix time(year since 1900) to SYSTEMTIME(Years since 1601)
int64_t time = ((int64_t)tv.tv_sec * (int64_t)TIME_CONVERSION__TO_SECONDS) + ((int64_t)tv.tv_usec * (int64_t)TIME_CONVERSION__TO_MILLISECONDS ) + TIME_UNIX_EPOCH_AS_TICKS;
int64_t time = ((int64_t)tv.tv_sec * (int64_t)TIME_CONVERSION__TO_SECONDS) + ((int64_t)tv.tv_usec * (int64_t)TIME_CONVERSION__TO_USECS) + TIME_UNIX_EPOCH_AS_TICKS;

HAL_Time_ToSystemTime(time, &st );

Expand Down

0 comments on commit 570ba75

Please sign in to comment.