Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendario.py14
-rw-r--r--fecha.py28
2 files changed, 27 insertions, 15 deletions
diff --git a/calendario.py b/calendario.py
index c044592..03508ec 100644
--- a/calendario.py
+++ b/calendario.py
@@ -17,7 +17,7 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>.
from gettext import gettext as _
-from fecha import Fecha
+from fecha import Fecha, fecha
import gtk
import gobject
@@ -34,10 +34,10 @@ class Calendario:
#calendar widget
self.calendario = gtk.Calendar()
- self.fecha = Fecha()
- self.fecha = _('Hoy es ') + self.fecha.convertir()
+ self.fecha = _('Hoy es ') + fecha()
self.texto_fecha = gtk.Label(self.fecha)
-
+ self.calendario.connect('day_selected', self._dia_selec_cb)
+
#area of daily activities
self.area_texto = gtk.ScrolledWindow()
self.area_texto.set_shadow_type(gtk.SHADOW_IN)
@@ -109,8 +109,12 @@ class Calendario:
'''close gtk'''
gtk.main_quit()
+ def _dia_selec_cb(self, widget, data=None):
+ '''selected day'''
+ self.date = self.calendario.get_date()
-
+
+
if __name__ == "__main__":
foo = Calendario()
foo.main()
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))