]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix off-by-one printing month in logging code
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 24 Oct 2011 16:33:00 +0000 (17:33 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 2 Nov 2011 14:55:35 +0000 (14:55 +0000)
The field 'mon' in 'struct tm' gives months 0-11, where as
humans tend to expect months 1-12. Thus the month number
needing adjusting by 1

* src/util/logging.c: Use human friendly month number

src/util/logging.c

index 9df90030abfba2417982497cf370a65ec871c2d9..17c7e843855e939dc013380fc8c16920faa7ca40 100644 (file)
@@ -628,6 +628,7 @@ virLogFormatTimestamp(void)
     gettimeofday(&cur_time, NULL);
     localtime_r(&cur_time.tv_sec, &time_info);
     time_info.tm_year += 1900;
+    time_info.tm_mon += 1;
 
     if (virAsprintf(&str, "%4d-%02d-%02d %02d:%02d:%02d.%03d",
                     time_info.tm_year, time_info.tm_mon, time_info.tm_mday,