~nchohan/+junk/mytools

« back to all changes in this revision

Viewing changes to sample_apps/tasks/templatefilters.py

  • Committer: root
  • Date: 2010-11-03 07:43:57 UTC
  • Revision ID: root@appscale-image0-20101103074357-xea7ja3sor3x93oc
init

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright 2008 Google Inc.
 
4
#
 
5
# Licensed under the Apache License, Version 2.0 (the "License");
 
6
# you may not use this file except in compliance with the License.
 
7
# You may obtain a copy of the License at
 
8
#
 
9
#     http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
# Unless required by applicable law or agreed to in writing, software
 
12
# distributed under the License is distributed on an "AS IS" BASIS,
 
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
# See the License for the specific language governing permissions and
 
15
# limitations under the License.
 
16
 
 
17
"""Django template filters for the Task List application."""
 
18
 
 
19
__author__ = 'Bret Taylor'
 
20
 
 
21
import datetime
 
22
import time
 
23
 
 
24
from google.appengine.ext.webapp import template
 
25
 
 
26
 
 
27
def rfc3339date(date):
 
28
  """Formats the given date in RFC 3339 format for feeds."""
 
29
  if not date: return ''
 
30
  date = date + datetime.timedelta(seconds=-time.timezone)
 
31
  if time.daylight:
 
32
    date += datetime.timedelta(seconds=time.altzone)
 
33
  return date.strftime('%Y-%m-%dT%H:%M:%SZ')
 
34
 
 
35
 
 
36
# Register the filter functions with Django
 
37
register = template.create_template_register()
 
38
register.filter(rfc3339date)