>From 7b5505ef931fb900d365d23026698a6865fd3e83 Mon Sep 17 00:00:00 2001 From: Dan Kenigsberg Date: Sun, 27 Apr 2008 13:09:17 +0300 Subject: [PATCH] when specifying -localtime, -startdate is expressed as local time. --- vl.c | 30 +++++++++++++----------------- 1 files changed, 13 insertions(+), 17 deletions(-) diff --git a/vl.c b/vl.c index 78486cf..7f22152 100644 --- a/vl.c +++ b/vl.c @@ -181,7 +181,7 @@ int nb_nics; NICInfo nd_table[MAX_NICS]; int vm_running; static int rtc_utc = 1; -static int rtc_date_offset = -1; /* -1 means no change */ +static int rtc_date_offset = 0; /* 0 means no change */ int cirrus_vga_enabled = 1; int vmsvga_enabled = 0; #ifdef TARGET_SPARC @@ -1574,15 +1574,11 @@ void qemu_get_timedate(struct tm *tm, int offset) time(&ti); ti += offset; - if (rtc_date_offset == -1) { - if (rtc_utc) - ret = gmtime(&ti); - else - ret = localtime(&ti); - } else { - ti -= rtc_date_offset; + ti -= rtc_date_offset; + if (rtc_utc) ret = gmtime(&ti); - } + else + ret = localtime(&ti); memcpy(tm, ret, sizeof(struct tm)); } @@ -1591,13 +1587,10 @@ int qemu_timedate_diff(struct tm *tm) { time_t seconds; - if (rtc_date_offset == -1) - if (rtc_utc) - seconds = mktimegm(tm); - else - seconds = mktime(tm); - else + if (rtc_utc) seconds = mktimegm(tm) + rtc_date_offset; + else + seconds = mktime(tm) + rtc_date_offset; return seconds - time(NULL); } @@ -8785,7 +8778,7 @@ int main(int argc, char **argv) struct tm tm; time_t rtc_start_date; if (!strcmp(optarg, "now")) { - rtc_date_offset = -1; + rtc_date_offset = 0; } else { if (sscanf(optarg, "%d-%d-%dT%d:%d:%d", &tm.tm_year, @@ -8807,7 +8800,10 @@ int main(int argc, char **argv) } tm.tm_year -= 1900; tm.tm_mon--; - rtc_start_date = mktimegm(&tm); + if (rtc_utc) + rtc_start_date = mktimegm(&tm); + else + rtc_start_date = mktime(&tm); if (rtc_start_date == -1) { date_fail: fprintf(stderr, "Invalid date format. Valid format are:\n" -- 1.5.4.5