From 93f1ded52049b8ff63c97a6682e028ea420ed355 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 26 Jul 2011 22:05:14 +0200 Subject: Show the date properly --- .../com/sun/star/wizards/agenda/AgendaTemplate.py | 29 ++++++++++------------ wizards/com/sun/star/wizards/text/TextDocument.py | 5 ---- 2 files changed, 13 insertions(+), 21 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py index 3d6c0cf2c0e9..54c482cad2ee 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 194bea1ac960..ad83b4cbc1cc 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) -- cgit