[Libreoffice-commits] .: Branch 'feature/gsoc2011_wizards' - wizards/com

Xisco Fauli xfauli at kemper.freedesktop.org
Tue Jul 26 13:06:21 PDT 2011


 wizards/com/sun/star/wizards/agenda/AgendaTemplate.py |   29 ++++++++----------
 wizards/com/sun/star/wizards/text/TextDocument.py     |    5 ---
 2 files changed, 13 insertions(+), 21 deletions(-)

New commits:
commit b52047f0020ac6df3081a6caaa03dd61e6825d1f
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Tue Jul 26 22:05:14 2011 +0200

    Show the date properly

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
index 3d6c0cf..54c482c 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
@@ -5,6 +5,7 @@ from text.TextDocument import *
 from common.FileAccess import FileAccess
 from text.TextSectionHandler import TextSectionHandler
 from TopicsControl import TopicsControl
+from datetime import date as dateTimeObject
 
 from com.sun.star.text.PlaceholderType import TEXT
 from com.sun.star.i18n.NumberFormatIndex import TIME_HHMM, DATE_SYSTEM_LONG
@@ -293,10 +294,11 @@ class AgendaTemplate(TextDocument):
         Get the default locale of the document,
         and create the date and time formatters.
         '''
-        dateUtils = Helper.DateUtils(self.xMSF, AgendaTemplate.document)
-        AgendaTemplate.formatter = dateUtils.formatter
-        AgendaTemplate.dateFormat = dateUtils.getFormat(DATE_SYSTEM_LONG)
-        AgendaTemplate.timeFormat = dateUtils.getFormat(TIME_HHMM)
+        AgendaTemplate.dateUtils = Helper.DateUtils(
+            self.xMSF, AgendaTemplate.document)
+        AgendaTemplate.formatter = AgendaTemplate.dateUtils.formatter
+        AgendaTemplate.dateFormat = AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
+        AgendaTemplate.timeFormat = AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
 
         '''
         get the document properties object.
@@ -448,18 +450,13 @@ class AgendaTemplate(TextDocument):
     def getDateString(self, d):
         if d is None or d == "":
             return ""
-
-        date = Integer(d).intValue.intValue()
-        self.calendar.clear()
-        self.calendar.set(date / 10000, (date % 10000) / 100 - 1, date % 100)
-        date1 = JavaTools.getTimeInMillis(self.calendar)
-        '''
-        docNullTime and date1 are in millis, but
-        I need a day...
-        '''
-        daysDiff = (date1 - self.docNullTime) / self.__class__.DAY_IN_MILLIS + 1
-        return AgendaTemplate.formatter.convertNumberToString(
-            self.dateFormat, daysDiff)
+        date = int(d)
+        year = date / 10000
+        month = (date % 10000) / 100
+        day = date % 100
+        dateObject = dateTimeObject(year, month, day)
+        return AgendaTemplate.dateUtils.format(
+            AgendaTemplate.dateFormat, dateObject)
 
     @classmethod
     def getTimeString(self, s):
diff --git a/wizards/com/sun/star/wizards/text/TextDocument.py b/wizards/com/sun/star/wizards/text/TextDocument.py
index 194bea1..ad83b4c 100644
--- a/wizards/com/sun/star/wizards/text/TextDocument.py
+++ b/wizards/com/sun/star/wizards/text/TextDocument.py
@@ -12,7 +12,6 @@ from common.Configuration import Configuration
 
 from com.sun.star.container import NoSuchElementException
 from com.sun.star.lang import WrappedTargetException
-from com.sun.star.util import DateTime
 from com.sun.star.i18n.NumberFormatIndex import DATE_SYS_DDMMYY
 from com.sun.star.view.DocumentZoomType import ENTIRE_PAGE
 from com.sun.star.beans.PropertyState import DIRECT_VALUE
@@ -214,14 +213,10 @@ class TextDocument(object):
             gn = xNA.getByName("givenname")
             sn = xNA.getByName("sn")
             fullname = str(gn) + " " + str(sn)
-            currentDate = DateTime()
             now = time.localtime(time.time())
             year = time.strftime("%Y", now)
             month = time.strftime("%m", now)
             day = time.strftime("%d", now)
-            currentDate.Day = day
-            currentDate.Year = year
-            currentDate.Month = month
             dateObject = dateTimeObject(int(year), int(month), int(day))
             du = Helper.DateUtils(self.xMSF, TextDocument.xTextDocument)
             ff = du.getFormat(DATE_SYS_DDMMYY)


More information about the Libreoffice-commits mailing list