#!/usr/bin/env python

import fcntl, struct, os

# Representing
#  struct rtc_time {
#    int tm_sec;
#    int tm_min;
#    int tm_hour;
#    int tm_mday;
#    int tm_mon;
#    int tm_year;
#    int tm_wday;
#    int tm_yday;
#     int tm_isdst;
#  };
# as Python struct.
a=struct.pack('iiiiiiiii', 0,0,0,0,0,0,0,0,0)

fo=open('/dev/rtc')

RTC_RD_TIME=0x80247009

input=fcntl.ioctl(fo.fileno(), RTC_RD_TIME, a)
result=struct.unpack('iiiiiiiii', input)

print "RTC time: " + str(result[2]) + ":" + str(result[1]) + ":" + str(result[0])