Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/fecha.py
diff options
context:
space:
mode:
authorYader Velásquez <yajosev@gmail.com>2010-08-17 04:51:50 (GMT)
committer Yader Velásquez <yajosev@gmail.com>2010-08-17 04:51:50 (GMT)
commit1040b86001d6f669181931d9730aaaf62695af3b (patch)
tree3aff45e512d44de05aa75b10ea6aab234fcb3113 /fecha.py
parentf54c067c71f61f70d0c205f2baf4d846c3329efe (diff)
new methods and functions for date depending of the calendar widget
Diffstat (limited to 'fecha.py')
-rw-r--r--fecha.py28
1 files changed, 18 insertions, 10 deletions
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 <http://www.gnu.org/licenses/>.
-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))