[PATCH 5/6] common/date.c: Fix off-by-one error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As per http://pubs.opengroup.org/onlinepubs/007908775/xsh/time.h.html
'tm_wday' is zero indexed with zero representing Sunday, this is also
corroborated by the code in rtc_time_to_tm() which used 4 to represent
Thursday.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 common/date.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/date.c b/common/date.c
index 2f23463..129192e 100644
--- a/common/date.c
+++ b/common/date.c
@@ -151,13 +151,13 @@ mktime (unsigned int year, unsigned int mon,

 const char *time_str(struct rtc_time *tm)
 {
-	const char *weekdays[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
+	const char *weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
 	const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
 				 "Sep", "Oct", "Nov", "Dec" };
 	static char buf[128];

 	sprintf(buf, "%s %02d %s %4d %02d:%02d:%02d",
-			weekdays[tm->tm_wday - 1],
+			weekdays[tm->tm_wday],
 			tm->tm_mday,
 			months[tm->tm_mon],
 			tm->tm_year + 1900,
--
2.5.0

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux