#include <string.h>
#include <unistd.h>
-#include "sd-id128.h"
#include "sd-messages.h"
#include "sd-event.h"
#include "sd-bus.h"
#include "strv.h"
#include "def.h"
#include "clock-util.h"
-#include "conf-files.h"
#include "path-util.h"
#include "fileio-label.h"
-#include "label.h"
#include "bus-util.h"
#include "bus-error.h"
#include "bus-common-errors.h"
Context *c = userdata;
int64_t utc;
struct timespec ts;
+ usec_t start;
struct tm* tm;
int r;
if (r == 0)
return 1;
+ /* adjust ts for time spent in program */
+ r = sd_bus_message_get_monotonic_usec(m, &start);
+ if (r < 0 && r != -ENODATA)
+ return r;
+ if (r >= 0)
+ timespec_store(&ts, timespec_load(&ts) + (now(CLOCK_MONOTONIC) - start));
+
/* Set system clock */
if (clock_settime(CLOCK_REALTIME, &ts) < 0) {
log_error_errno(errno, "Failed to set local time: %m");
if (r < 0)
goto finish;
+ (void)sd_bus_negotiate_timestamp(bus, true);
+
r = context_read_data(&context);
if (r < 0) {
log_error_errno(r, "Failed to read time zone data: %m");