Skip to content

Commit

Permalink
time ver1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yltpsd committed Apr 28, 2013
1 parent e192242 commit 022972a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion eatWhat/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.http import HttpResponse
from django.http import Http404, HttpResponse
import datetime


def hello(request):
return HttpResponse("EatWhat?")

Expand All @@ -9,3 +10,11 @@ def current_datetime(request):
html = "<html><body>It is now %s.</body></html>" % now
return HttoResponse(html)

def hours_ahead(request, offset):
try:
offset = int(offset)
except ValueError:
raise Http404()
dt = datetime.datetime.now()+datetime.timedelta(hours=offset)
html = "<html><body>In %s hour(s),it will be %s.</body></html>" % (offset, dt)
return HttpResponse(html)

0 comments on commit 022972a

Please sign in to comment.