summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-01-11 13:11:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-11 13:11:08 +0100
commit1b59b573e434b19b45b12b07a28d749d72aeb145 (patch)
tree7fa1a5006cb916555621e09571cdb5424edb76fe /common
parent70ef1cef5c1a03a4b130f3916d47c3076880b5d6 (diff)
parent4c9b2e72057ca3d1578b33ff75ad251bb8225a9c (diff)
downloadbarebox-1b59b573e434b19b45b12b07a28d749d72aeb145.tar.gz
Merge branch 'for-next/rtc'
Diffstat (limited to 'common')
-rw-r--r--common/date.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/date.c b/common/date.c
index 6b6b7ab..129192e 100644
--- a/common/date.c
+++ b/common/date.c
@@ -148,3 +148,21 @@ mktime (unsigned int year, unsigned int mon,
)*60 + min /* now have minutes */
)*60 + sec; /* finally seconds */
}
+
+const char *time_str(struct rtc_time *tm)
+{
+ 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],
+ tm->tm_mday,
+ months[tm->tm_mon],
+ tm->tm_year + 1900,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
+ return buf;
+}