from IPython.display import HTML
HTML('<iframe src=http://raphaeljs.com/polar-clock.html width=630 height=630></iframe>')
HTML('<iframe src=http://randomibis.com/coolclock/justclock.html width=340 height=340></iframe>')
HTML('<iframe src=http://www.uize.com/examples/digital-clock.html width=850 height=600></iframe>')
Question: how many ticks are there since epoch?
import time
nticks = time.time()
print "It is now %f ticks (seconds) past epoch" % nticks
It is now 1353713584.312000 ticks (seconds) past epoch
Index | Attribute | Meaning | Value | Range |
---|---|---|---|---|
0 | tm_year | 4-digit year | 2012 | 1 - 9999 |
1 | tm_mon | montd | 11 | 1 - 12 |
2 | tm_mday | day of montd | 23 | 1 - 31 |
3 | tm_hour | 24 hour | 18 | 0 - 23 |
4 | tm_min | minute | 52 | 0 - 59 |
5 | tm_sec | second | 6 | 0 - 61 (60 or 61 are leap seconds) |
6 | tm_wday | day of week | 4 | 0 - 6 (0 for Monday) |
7 | tm_yday | day of year | 328 | 1 - 366 (Julian day) |
8 | tm_isdst | daylight savings | 0 | -1, 0, 1 (-1 means library determines DST) |
print "Year (Min, Max): (%d, %d)" % (datetime.MINYEAR, datetime.MAXYEAR)
Year (Min, Max): (1, 9999)
localtime = time.localtime(time.time())
print "local time is:\n\t", localtime
local time is: time.struct_time(tm_year=2012, tm_mon=11, tm_mday=23, tm_hour=19, tm_min=3, tm_sec=19, tm_wday=4, tm_yday=328, tm_isdst=0)
print "local time is:\n\t", time.asctime(localtime)
local time is: Fri Nov 23 19:03:19 2012
import datetime
# what timezone are you in
print time.tzname
('Eastern Standard Time', 'Eastern Daylight Time')
N=np.arange(361)
B=360*(N-81)/365.0 * np.pi/180.0
E=9.87*np.sin(2*B) - 7.53*np.cos(B) - 1.5*np.sin(B)
fig=plt.figure()
ax=fig.add_subplot(111)
ax.grid()
ax.set_xlim(-5,365)
ax.set_ylim(-17,20)
ax.set_xlabel('Day of Year')
ax.set_ylabel('Time Adjustment (min)')
ax.set_title('Equation of Time')
ax.plot(N,E,'ro')
plt.show()
where $ B = \frac{360}{365} (N-81) $ in degree and $N$ is the day of year.
import calendar
# set Sunday as 1st column
calendar.setfirstweekday(6)
# show calendar for a month
cal = calendar.month(2012,11)
print cal
November 2012 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
# show calendar for a year
cal2 = calendar.calendar(2012)
print cal2
2012 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 1 2 3 4 1 2 3 8 9 10 11 12 13 14 5 6 7 8 9 10 11 4 5 6 7 8 9 10 15 16 17 18 19 20 21 12 13 14 15 16 17 18 11 12 13 14 15 16 17 22 23 24 25 26 27 28 19 20 21 22 23 24 25 18 19 20 21 22 23 24 29 30 31 26 27 28 29 25 26 27 28 29 30 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 1 2 3 4 5 1 2 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 29 30 27 28 29 30 31 24 25 26 27 28 29 30 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 1 2 3 4 1 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 30 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 1 2 3 1 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 30 31
from IPython.display import YouTubeVideo
YouTubeVideo('MTx6ha6fRwo')
watch the rest: Time - a BBC documentary