You may have noticed the time that is appended to the top of each of my blogs along the lines of “~2 minutes 50 seconds reading”. This is an approximated reading time for that particular blog.
Why?
This is a built in feature of the Wren blogging platform. A sizable proportion of users don't take the time to read the blogs they are linked to because they misjudge the time it will take them to read the blog. Features like this one keep those readers interested.
How?
The code that makes this calculation is written in Python and is very easy to understand, even for the novis programmer.
#!/usr/bin/python3
from math import floor
if len(text)/200 < 1:
secs = int(float(len(text))*0.3)
readtime = "~{0} seconds reading".format(secs)
else:
mins = int(floor(len(text)/float(200)))
secs = int(((len(text)/float(200))-mins)*60)
readtime = "~{0} minutes {1} seconds reading".format(mins, secs)
It's set to give the time in minutes or seconds dependent on the length of the post, and generally is an easy solution to the problem.