-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathtime.c
More file actions
37 lines (28 loc) · 877 Bytes
/
time.c
File metadata and controls
37 lines (28 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2018 Electric Power Research Institute, Inc.
// author: Mark Slicker <mark.slicker@gmail.com>
/** @defgroup time Time
Get/set the time based upon the IEEE 2030.5 Time resource.
@{
*/
/** @brief Set the time and timezone based upon the values of the IEEE 20305.5
Time object.
@param tm is a pointer to a SE_Time_t structure
*/
void set_time (SE_Time_t *tm);
/** @brief Get the current (adjusted) time, syncronized with a IEEE 2030.5
server.
@returns the system time with an added offset to match the time of the
server.
*/
int64_t se_time ();
/** @} */
#include <time.h>
int se_time_offset = 0;
void set_time (SE_Time_t *tm) {
se_time_offset = tm->currentTime - time (NULL);
set_timezone (tm->tzOffset, tm->dstOffset,
tm->dstStartTime, tm->dstEndTime);
}
int64_t se_time () {
return time (NULL) + se_time_offset;
}