Commit 94fbe2a1 authored by Jim Fulton's avatar Jim Fulton

Skip added strftime method and machinery that allows DTML tags

like:

  <!--#var aDateTime fmt="%Y-%m-%d"-->
parent 3a5d229b
......@@ -84,12 +84,12 @@
##############################################################################
"""Encapsulation of date/time values"""
__version__='$Revision: 1.20 $'[11:-2]
__version__='$Revision: 1.21 $'[11:-2]
import sys,os,regex,DateTimeZone
from string import strip,split,upper,lower,atoi,atof,find,join
from time import time,gmtime,localtime,asctime,tzname
from time import time,gmtime,localtime,asctime,tzname,strftime,mktime
from types import InstanceType,IntType,FloatType,StringType
......@@ -858,6 +858,9 @@ class DateTime:
def _validTime(self,h,m,s):
return h>=0 and h<=23 and m>=0 and m<=59 and s>=0 and s<=59
def __getattr__(self, name):
if '%' in name: return strftimeFormatter(self, name)
raise AttributeError, name
# Conversion and comparison methods
......@@ -1121,6 +1124,8 @@ class DateTime:
"""Return the second"""
return self._second
def strftime(self, format):
return strftime(format, gmtime(self.timeTime()))
# General formats from previous DateTime
......@@ -1299,6 +1304,14 @@ class DateTime:
return float(self._d)
class strftimeFormatter:
def __init__(self, dt, format):
self._dt=dt
self._f=format
def __call__(self): return self._dt.strftime(self._f)
# Module methods
def Timezones():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment