Skip to content

Commit b13a07d

Browse files
author
张钦
committed
Fix the precision loss issue in DateTime.h. I think your test was conducted in the UTC timezone, so it was difficult for you to discover this issue. If you are in another timezone, you will notice that the hour, minute, and second data will be lost. For example, in the time judgment of intelligent charging.
1 parent 70ac059 commit b13a07d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/types/DateTime.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class DateTime
8484
m_datetime = _mkgmtime(&t);
8585
#else // _MSC_VER
8686
m_datetime = std::mktime(&t);
87-
m_datetime += t.tm_gmtoff;
8887
m_datetime -= (t.tm_isdst * 3600);
8988
#endif // _MSC_VER
9089
ret = true;
@@ -179,7 +178,7 @@ class DateTime
179178
#ifdef _MSC_VER
180179
gmtime_s(&t, &m_datetime);
181180
#else // _MSC_VER
182-
gmtime_r(&m_datetime, &t);
181+
localtime_r(&m_datetime, &t);
183182
#endif // _MSC_VER
184183
ss << std::put_time(&t, "%Y-%m-%dT%TZ");
185184
return ss.str();

0 commit comments

Comments
 (0)