datemate

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def datemate(value):
	hoy = datetime.date.today()
	if value.year == hoy.year:
		fecha = format(value, "d F").replace(' 0', ' ')
	else:
		fecha = format(value, "d F Y").replace(' 0', ' ')
	ayer = hoy - datetime.timedelta(1)
	hora = format(value, "g:i A").lower()
	if value.year == hoy.year and value.month == hoy.month and value.day == hoy.day:
		fecha = "today"
	if value.year == ayer.year and value.month == ayer.month and value.day == ayer.day:
		fecha = "yesterday"
	return fecha + " " + "at" + " " + hora

More like this

  1. Time ranges like 7-9 p.m. by sgb 5 years, 4 months ago
  2. Optimized humanize naturalday filter by c2j 3 years, 8 months ago
  3. Human format Date representation by sachingupta006 1 year, 2 months ago
  4. Complete Persian DateTime Widget by serj1975 1 year, 5 months ago
  5. datetime.time/datetime.datetime to Unix Epoch (with microsecond support) by sleepycal 3 years ago

Comments

(Forgotten your password?)