Presently 'sel time set' doesn't account 'minute' difference between timezone. So depending on host timezone it may set time to +/-30 mins. This patch adds minute difference to delta_hour caluclation so that it sets time properly.
output without patch: # ./ipmitool sel time get 03/24/2016 12:34:03 # ./ipmitool sel time set "03/24/2016 12:34:03" 03/24/2016 12:04:03 # ./ipmitool sel time get 03/24/2016 12:06:09 output with patch: # ./ipmitool sel time get 03/30/2016 08:49:47 # ./ipmitool sel time set "03/30/2016 08:09:47" 03/30/2016 08:09:47 # ./ipmitool sel get 03/30/2016 08:09:57 Signed-off-by: Vasant Hegde <hegdevas...@linux.vnet.ibm.com> --- lib/ipmi_sel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c index 910011e..1127929 100644 --- a/lib/ipmi_sel.c +++ b/lib/ipmi_sel.c @@ -2739,24 +2739,26 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string) { //modify UTC time to local time expressed in number of seconds from 1/1/70 0:0:0 1970 GMT struct tm * tm_tmp = {0}; - int gt_year,gt_yday,gt_hour,lt_year,lt_yday,lt_hour; + int gt_year,gt_yday,gt_hour,gt_min,lt_year,lt_yday,lt_hour,lt_min; int delta_hour; tm_tmp=gmtime(&t); gt_year=tm_tmp->tm_year; gt_yday=tm_tmp->tm_yday; gt_hour=tm_tmp->tm_hour; + gt_min=tm_tmp->tm_min; memset(&*tm_tmp, 0, sizeof(struct tm)); tm_tmp=localtime(&t); lt_year=tm_tmp->tm_year; lt_yday=tm_tmp->tm_yday; lt_hour=tm_tmp->tm_hour; + lt_min=tm_tmp->tm_min; delta_hour=lt_hour - gt_hour; if ( (lt_year > gt_year) || ((lt_year == gt_year) && (lt_yday > gt_yday)) ) delta_hour += 24; if ( (lt_year < gt_year) || ((lt_year == gt_year) && (lt_yday < gt_yday)) ) delta_hour -= 24; - t += (delta_hour * 60 * 60); + t += (delta_hour * 60 * 60) + (lt_min - gt_min) * 60; } timei = (uint32_t)t; -- 2.5.0 ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140 _______________________________________________ Ipmitool-devel mailing list Ipmitool-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipmitool-devel