Skip to content

Instantly share code, notes, and snippets.

@r4dian
Last active February 15, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r4dian/158fc45e1594a19a5f23f970ac51635a to your computer and use it in GitHub Desktop.
Save r4dian/158fc45e1594a19a5f23f970ac51635a to your computer and use it in GitHub Desktop.
var d = new Date('2013-03-14')
var n = new Date()
var year = Math.floor( Math.ceil( Math.abs( n.getTime()-d.getTime() ) / (1000 * 60 * 60 * 24) ) / 365 +1 )
function nth(n){return["st","nd","rd"][((n+90)%100-10)%10-1]||"th"}
console.log("It is the " + year + nth(year) + " Year of Luigi")
from datetime import date
import math
n = (date.today()-date(2013,3,14)).days / 365 +1
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4])
print ( 'It is the', ordinal(int(n)), 'Year of Luigi' )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment