diff options
author | Yader 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) |
commit | 1040b86001d6f669181931d9730aaaf62695af3b (patch) | |
tree | 3aff45e512d44de05aa75b10ea6aab234fcb3113 | |
parent | f54c067c71f61f70d0c205f2baf4d846c3329efe (diff) |
new methods and functions for date depending of the calendar widget
-rw-r--r-- | calendario.py | 14 | ||||
-rw-r--r-- | fecha.py | 28 |
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() @@ -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)) |