Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Express age in years
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Aug 31, 2015
1 parent 272eb1a commit 10d9456
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
14 changes: 2 additions & 12 deletions gratipay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@
'eight', 'nine']
ORDINALS = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
'seventh', 'eighth', 'ninth', 'tenth']
MONTHS = [None, 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']

def age():
def age_in_years():
today = datetime.date.today()
nmonths = (12 - BIRTHDAY.month) \
+ (12 * (today.year - BIRTHDAY.year - 1)) \
+ (today.month)
plural = 's' if nmonths != 1 else ''
if nmonths < 10:
nmonths = CARDINALS[nmonths]
else:
nmonths = str(nmonths)
return "%s month%s" % (nmonths, plural)
return (today - BIRTHDAY).days // 365


class NotSane(Exception):
Expand Down
10 changes: 7 additions & 3 deletions www/about/stats.spt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from __future__ import unicode_literals
import datetime
import locale
from aspen import json
from gratipay import age
from gratipay import age_in_years

CARDINALS = ["zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine"]
Expand Down Expand Up @@ -184,8 +184,12 @@ def out():

{% block content %}

<p>Gratipay is <b>{{ age() }}</b> old and has <b>{{ nactive }} active
users</b>.</p>
<p>{{ _( "Gratipay is {b}{age}+ years{_b} old and has {b}{nactive} active users{_b}."
, age=age_in_years()
, nactive=nactive
, b='<b>'|safe
, _b='</b>'|safe
) }}</p>

<p>
{{ ngivers }} participants gave money in the past week.<br />
Expand Down

0 comments on commit 10d9456

Please sign in to comment.