File tree 1 file changed +2
-17
lines changed 1 file changed +2
-17
lines changed Original file line number Diff line number Diff line change @@ -11,31 +11,16 @@ RTCZero rtc;
11
11
extern " C" {
12
12
int _gettimeofday (struct timeval * tp, void * /* tzvp*/ )
13
13
{
14
- struct tm tm ;
15
-
16
- tm .tm_isdst = -1 ;
17
- tm .tm_yday = 0 ;
18
- tm .tm_wday = 0 ;
19
- tm .tm_year = rtc.getYear () + 100 ;
20
- tm .tm_mon = rtc.getMonth () + 1 ;
21
- tm .tm_mday = rtc.getDay ();
22
- tm .tm_hour = rtc.getHours ();
23
- tm .tm_min = rtc.getMinutes ();
24
- tm .tm_sec = rtc.getSeconds ();
25
-
26
- tp->tv_sec = mktime (&tm );
14
+ tp->tv_sec = rtc.getEpoch ();
27
15
tp->tv_usec = 0 ;
28
16
29
17
return 0 ;
30
18
}
31
19
32
20
int settimeofday (const struct timeval * tp, const struct timezone * /* tzp*/ )
33
21
{
34
- struct tm * tmp = gmtime (&tp->tv_sec );
35
-
36
22
rtc.begin ();
37
- rtc.setDate (tmp->tm_mday , tmp->tm_mon - 1 , tmp->tm_year - 100 );
38
- rtc.setTime (tmp->tm_hour , tmp->tm_min , tmp->tm_sec );
23
+ rtc.setEpoch (tp->tv_sec );
39
24
40
25
return 0 ;
41
26
}
You can’t perform that action at this time.
0 commit comments