From 1040b86001d6f669181931d9730aaaf62695af3b Mon Sep 17 00:00:00 2001 From: Yader Velásquez Date: Tue, 17 Aug 2010 04:51:50 +0000 Subject: new methods and functions for date depending of the calendar widget --- (limited to 'fecha.py') diff --git a/fecha.py b/fecha.py index 6281674..5009c10 100644 --- a/fecha.py +++ b/fecha.py @@ -16,22 +16,30 @@ #You should have received a copy of the GNU General Public License #along with this program. If not, see . -from time import time, localtime, strftime +from time import localtime, strftime, mktime +from datetime import datetime + +def fecha(): + '''return a friendly date''' + fecha = datetime.today() + return fecha.strftime("%d de %B de %Y") class Fecha(object): '''a simple class for get and convert date''' - def __init__(self): + def __init__(self, lista): '''init class''' - self.fecha_unix = time() + self.fecha = datetime(lista[0], lista[1] + 1, lista[2]) #Calendar signal return month -1 def convertir(self): - '''return a friendly date for user''' - return strftime("%d de %b de %Y", localtime(self.fecha_unix)) - - def exportar(self): - '''convert a unix date to int and after to string''' - self.fecha = int(self.fecha_unix) - return str(self.fecha) + '''convert to unix date''' + self.fecha_unix = mktime(self.fecha.timetuple()) + self.fecha_unix = int(self.fecha_unix) + return str(self.fecha_unix) + def formatear(self): + '''date formated''' + self.fecha_unix = mktime(self.fecha.timetuple()) + self.fecha_unix = int(self.fecha_unix) + return strftime("%d de %b de %Y", localtime(self.fecha_unix)) -- cgit v0.9.1