|
|
4e2c59 |
From fdd19cb2f65413aacb32f1eca04c2997a892f62d Mon Sep 17 00:00:00 2001
|
|
|
4e2c59 |
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
|
|
|
4e2c59 |
Date: Wed, 30 Mar 2016 14:07:16 +0530
|
|
|
4e2c59 |
Subject: [PATCH] ID:437 - sel: Fix "sel time set <time>"
|
|
|
4e2c59 |
|
|
|
4e2c59 |
Presently 'sel time set' doesn't account 'minute' difference between timezone.
|
|
|
4e2c59 |
So depending on host timezone it may set time to +/-30 mins. This patch adds
|
|
|
4e2c59 |
minute difference to delta_hour caluclation so that it sets time properly.
|
|
|
4e2c59 |
|
|
|
4e2c59 |
output without patch:
|
|
|
4e2c59 |
# ./ipmitool sel time get
|
|
|
4e2c59 |
03/24/2016 12:34:03
|
|
|
4e2c59 |
# ./ipmitool sel time set "03/24/2016 12:34:03"
|
|
|
4e2c59 |
03/24/2016 12:04:03
|
|
|
4e2c59 |
# ./ipmitool sel time get
|
|
|
4e2c59 |
03/24/2016 12:06:09
|
|
|
4e2c59 |
|
|
|
4e2c59 |
output with patch:
|
|
|
4e2c59 |
|
|
|
4e2c59 |
# ./ipmitool sel time get
|
|
|
4e2c59 |
03/30/2016 08:49:47
|
|
|
4e2c59 |
# ./ipmitool sel time set "03/30/2016 08:09:47"
|
|
|
4e2c59 |
03/30/2016 08:09:47
|
|
|
4e2c59 |
# ./ipmitool sel get
|
|
|
4e2c59 |
03/30/2016 08:09:57
|
|
|
4e2c59 |
|
|
|
4e2c59 |
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
|
|
|
4e2c59 |
---
|
|
|
4e2c59 |
lib/ipmi_sel.c | 6 ++++--
|
|
|
4e2c59 |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
4e2c59 |
|
|
|
4e2c59 |
diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c
|
|
|
4e2c59 |
index affaed8..243f268 100644
|
|
|
4e2c59 |
--- a/lib/ipmi_sel.c
|
|
|
4e2c59 |
+++ b/lib/ipmi_sel.c
|
|
|
4e2c59 |
@@ -2726,24 +2726,26 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
|
|
|
4e2c59 |
{
|
|
|
4e2c59 |
//modify UTC time to local time expressed in number of seconds from 1/1/70 0:0:0 1970 GMT
|
|
|
4e2c59 |
struct tm * tm_tmp = {0};
|
|
|
4e2c59 |
- int gt_year,gt_yday,gt_hour,lt_year,lt_yday,lt_hour;
|
|
|
4e2c59 |
+ int gt_year,gt_yday,gt_hour,gt_min,lt_year,lt_yday,lt_hour,lt_min;
|
|
|
4e2c59 |
int delta_hour;
|
|
|
4e2c59 |
tm_tmp=gmtime(&t);
|
|
|
4e2c59 |
gt_year=tm_tmp->tm_year;
|
|
|
4e2c59 |
gt_yday=tm_tmp->tm_yday;
|
|
|
4e2c59 |
gt_hour=tm_tmp->tm_hour;
|
|
|
4e2c59 |
+ gt_min=tm_tmp->tm_min;
|
|
|
4e2c59 |
memset(&*tm_tmp, 0, sizeof(struct tm));
|
|
|
4e2c59 |
tm_tmp=localtime(&t);
|
|
|
4e2c59 |
lt_year=tm_tmp->tm_year;
|
|
|
4e2c59 |
lt_yday=tm_tmp->tm_yday;
|
|
|
4e2c59 |
lt_hour=tm_tmp->tm_hour;
|
|
|
4e2c59 |
+ lt_min=tm_tmp->tm_min;
|
|
|
4e2c59 |
delta_hour=lt_hour - gt_hour;
|
|
|
4e2c59 |
if ( (lt_year > gt_year) || ((lt_year == gt_year) && (lt_yday > gt_yday)) )
|
|
|
4e2c59 |
delta_hour += 24;
|
|
|
4e2c59 |
if ( (lt_year < gt_year) || ((lt_year == gt_year) && (lt_yday < gt_yday)) )
|
|
|
4e2c59 |
delta_hour -= 24;
|
|
|
4e2c59 |
|
|
|
4e2c59 |
- t += (delta_hour * 60 * 60);
|
|
|
4e2c59 |
+ t += (delta_hour * 60 * 60) + (lt_min - gt_min) * 60;
|
|
|
4e2c59 |
}
|
|
|
4e2c59 |
|
|
|
4e2c59 |
timei = (uint32_t)t;
|
|
|
4e2c59 |
--
|
|
|
4e2c59 |
2.5.5
|
|
|
4e2c59 |
|